update message bus to support per client filtering

start work on user_tracking_state
fix can_ban? in guardian
expose protected scopes on topic_query we need
move guardian spec to use build as opposed to creating topics / posts / users
start work on user tracking spec
This commit is contained in:
Sam
2013-05-21 16:39:51 +10:00
parent 4ccd89f7df
commit b5eff93a9d
6 changed files with 136 additions and 28 deletions

View File

@ -190,6 +190,19 @@ class TopicQuery
create_list(:new_in_category) {|l| l.where(category_id: category.id).by_newest.first(25)}
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])
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])
end
protected
def create_list(filter, list_opts={})
@ -240,18 +253,6 @@ class TopicQuery
result
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])
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])
end
def random_suggested_results_for(topic, count, exclude_topic_ids)
results = default_list(unordered: true, per_page: count)