new rake task to defer all flags

This commit is contained in:
Arpit Jalan 2017-09-15 14:18:24 +05:30
parent 8b7089c126
commit 041ace5d3b
1 changed files with 20 additions and 0 deletions

View File

@ -202,3 +202,23 @@ task 'posts:delete_all_likes' => :environment do
DirectoryItem.update_all(likes_given: 0, likes_received: 0) # clear user directory likes stats
puts "", "#{likes_deleted} likes deleted!", ""
end
desc 'Defer all flags'
task 'posts:defer_all_flags' => :environment do
active_flags = FlagQuery.flagged_post_actions('active')
flags_deferred = 0
total = active_flags.count
active_flags.each do |post_action|
begin
PostAction.defer_flags!(Post.find(post_action.post_id), Discourse.system_user)
print_status(flags_deferred += 1, total)
rescue
# skip
end
end
puts "", "#{flags_deferred} flags deferred!", ""
end