mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-24 06:22:31 -05:00
18 lines
577 B
Ruby
18 lines
577 B
Ruby
class TrackedTopicsUpdater
|
|
|
|
def initialize(user_id, threshold)
|
|
@id = user_id
|
|
@threshold = threshold
|
|
end
|
|
|
|
def call
|
|
topic_users = TopicUser.where(notifications_reason_id: nil, user_id: @id)
|
|
if @threshold < 0
|
|
topic_users.update_all({notification_level: TopicUser.notification_levels[:regular]})
|
|
else
|
|
topic_users.update_all(["notification_level = CASE WHEN total_msecs_viewed < ? THEN ? ELSE ? END",
|
|
@threshold, TopicUser.notification_levels[:regular], TopicUser.notification_levels[:tracking]])
|
|
end
|
|
end
|
|
end
|
|
|