improved status output during auto-closing and ignore deleted topic timers

This commit is contained in:
Gerhard Schlager 2017-09-20 23:18:53 +02:00
parent 68d7c08f4d
commit e08b5feb8a
1 changed files with 15 additions and 2 deletions

View File

@ -14,9 +14,14 @@ def close_old_topics(category)
topics_closed = 0
total = topics.count
if total == 0
print " all old topics are closed"
return
end
topics.find_each do |topic|
topic.update_status("closed", true, Discourse.system_user)
print_status("\tClosing topics: ", topics_closed += 1, total)
print_status(" closing old topics: ", topics_closed += 1, total)
end
end
@ -28,15 +33,21 @@ def apply_auto_close(category)
FROM topic_timers
WHERE topic_timers.topic_id = topics.id
AND topic_timers.status_type = ?
AND topic_timers.deleted_at IS NULL
)
SQL
topics_closed = 0
total = topics.count
if total == 0
print " all topics have auto-close applied"
return
end
topics.find_each do |topic|
topic.inherit_auto_close_from_category
print_status("\tApplying auto-close to topics: ", topics_closed += 1, total)
print_status(" applying auto-close to topics: ", topics_closed += 1, total)
end
end
@ -46,7 +57,9 @@ task "topics:apply_autoclose" => :environment do
categories.find_each do |category|
puts "", "Applying auto-close to category '#{category.name}' ..."
close_old_topics(category)
puts ""
apply_auto_close(category)
puts ""
end
puts "", "Done"