User tracking state implementation progress for live unread / new counts

This commit is contained in:
Sam
2013-05-23 15:21:07 +10:00
parent cdbe6f64c7
commit fcc7192fd2
5 changed files with 142 additions and 34 deletions

View File

@ -190,17 +190,23 @@ class TopicQuery
create_list(:new_in_category) {|l| l.where(category_id: category.id).by_newest.first(25)}
end
def self.new_filter(list,treat_as_new_topic_start_date)
list.where("topics.created_at >= :created_at", created_at: treat_as_new_topic_start_date)
.where("tu.last_read_post_number IS NULL")
.where("COALESCE(tu.notification_level, :tracking) >= :tracking", tracking: TopicUser.notification_levels[:tracking])
end
def new_results(list_opts={})
default_list(list_opts)
.where("topics.created_at >= :created_at", created_at: @user.treat_as_new_topic_start_date)
.where("tu.last_read_post_number IS NULL")
.where("COALESCE(tu.notification_level, :tracking) >= :tracking", tracking: TopicUser.notification_levels[:tracking])
TopicQuery.new_filter(default_list(list_opts),@user.treat_as_new_topic_start_date)
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])
end
def unread_results(list_opts={})
default_list(list_opts)
.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])
TopicQuery.unread_filter(default_list(list_opts))
end
protected