mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 22:26:29 +08:00
30990006a9
This reduces chances of errors where consumers of strings mutate inputs and reduces memory usage of the app. Test suite passes now, but there may be some stuff left, so we will run a few sites on a branch prior to merging
20 lines
605 B
Ruby
20 lines
605 B
Ruby
# frozen_string_literal: true
|
|
|
|
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
|