discourse/lib/tasks/user_actions.rake
Sam Saffron 30990006a9 DEV: enable frozen string literal on all files
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
2019-05-13 09:31:32 +08:00

42 lines
1001 B
Ruby

# frozen_string_literal: true
desc "rebuild the user_actions table"
task "user_actions:rebuild" => :environment do
MessageBus.off
UserAction.delete_all
PostAction.all.each do |i|
if i.deleted_at.nil?
UserActionManager.post_action_created(i)
else
UserActionManager.post_action_destroyed(i)
end
end
Topic.all.each { |i| UserActionManager.log_topic(i) }
Post.all.each do |i|
if i.deleted_at.nil?
UserActionManager.post_created(i)
else
UserActionManager.post_destroyed(i)
end
end
Notification.all.each do |notification|
if notification.post.deleted_at.nil?
UserActionManager.notification_created(
notification.post,
notification.user,
notification.notification_type,
notification.user
)
else
UserActionManager.notification_destroyed(
notification.post,
notification.user,
notification.notification_type,
notification.user
)
end
end
end