2019-05-02 17:17:27 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-02-05 13:16:51 -06:00
|
|
|
desc "rebuild the user_actions table"
|
2013-02-25 10:42:20 -06:00
|
|
|
task "user_actions:rebuild" => :environment do
|
2013-02-05 13:16:51 -06:00
|
|
|
MessageBus.off
|
|
|
|
UserAction.delete_all
|
2019-01-03 11:03:01 -06:00
|
|
|
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
|
2016-12-21 22:03:40 -06:00
|
|
|
Notification.all.each do |notification|
|
2019-01-03 11:03:01 -06:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2016-12-21 22:03:40 -06:00
|
|
|
end
|
2013-02-05 13:16:51 -06:00
|
|
|
end
|