mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 02:22:40 +08:00
FEATURE: new rake task to watch all replied topics
This commit is contained in:
@ -66,3 +66,23 @@ task "topics:apply_autoclose" => :environment do
|
|||||||
|
|
||||||
puts "", "Done"
|
puts "", "Done"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
task "topics:watch_all_replied_topics" => :environment do
|
||||||
|
puts "Setting all topics to Watching on which a user has posted at least once..."
|
||||||
|
topics = Topic.where("archetype != ?", Archetype.private_message)
|
||||||
|
total = topics.count
|
||||||
|
count = 0
|
||||||
|
|
||||||
|
topics.find_each do |t|
|
||||||
|
t.topic_users.where(posted: true).find_each do |tp|
|
||||||
|
tp.update!(notification_level: TopicUser.notification_levels[:watching], notifications_reason_id: TopicUser.notification_reasons[:created_post])
|
||||||
|
end
|
||||||
|
print_status(count += 1, total)
|
||||||
|
end
|
||||||
|
|
||||||
|
puts "", "Done"
|
||||||
|
end
|
||||||
|
|
||||||
|
def print_status(current, max)
|
||||||
|
print "\r%9d / %d (%5.1f%%)" % [current, max, ((current.to_f / max.to_f) * 100).round(1)]
|
||||||
|
end
|
||||||
|
Reference in New Issue
Block a user