FIX: whisper no longer experimental

- Regular users are not notified of whispers
- Regular users no longer have "stuck" topics in unread
- Additional tracking for staff highest post number
- Remove a bunch of unused columns in topics table
This commit is contained in:
Sam
2016-12-02 17:03:31 +11:00
parent 3f3a0d7b14
commit c04d4171ff
21 changed files with 324 additions and 103 deletions

View File

@ -242,9 +242,12 @@ class TopicQuery
.where("COALESCE(tu.notification_level, :tracking) >= :tracking", tracking: TopicUser.notification_levels[:tracking])
end
def self.unread_filter(list)
list.where("tu.last_read_post_number < topics.highest_post_number")
.where("COALESCE(tu.notification_level, :regular) >= :tracking", regular: TopicUser.notification_levels[:regular], tracking: TopicUser.notification_levels[:tracking])
def self.unread_filter(list, opts)
col_name = opts[:staff] ? "highest_staff_post_number" : "highest_post_number"
list.where("tu.last_read_post_number < topics.#{col_name}")
.where("COALESCE(tu.notification_level, :regular) >= :tracking",
regular: TopicUser.notification_levels[:regular], tracking: TopicUser.notification_levels[:tracking])
end
def prioritize_pinned_topics(topics, options)
@ -320,7 +323,7 @@ class TopicQuery
end
def unread_results(options={})
result = TopicQuery.unread_filter(default_results(options.reverse_merge(:unordered => true)))
result = TopicQuery.unread_filter(default_results(options.reverse_merge(:unordered => true)), staff: @user.try(:staff?))
.order('CASE WHEN topics.user_id = tu.user_id THEN 1 ELSE 2 END')
self.class.results_filter_callbacks.each do |filter_callback|
@ -656,7 +659,7 @@ class TopicQuery
end
def unread_messages(params)
TopicQuery.unread_filter(messages_for_groups_or_user(params[:my_group_ids]))
TopicQuery.unread_filter(messages_for_groups_or_user(params[:my_group_ids]), staff: @user.try(:staff?))
.limit(params[:count])
end