Bulk topic timers

I didn’t make any notes unfortunately :innocent:

Disclaimer: Please only do any of that if you understand what I’m proposing and if you have a backup of your Discourse instance and know how to apply it. I haven’t tested this myself, so it might need some adjustments.

1. Get the relevant topic IDs

This would get any topic IDs from category with ID 11 which are not deleted and not closed.

SELECT id FROM topics WHERE category_id = 11 AND deleted_at IS NULL AND closed = FALSE ORDER BY id

Lets say, the result is 3, 6, 12, 24

2. Create the topic timers

Next enter the rails console in your container and use something like

auto_close_hours = 720
topic_ids = [3,6,12,24]
Topic.where(id: topic_ids).find_each do |topic| 
	topic.set_or_create_timer(
		TopicTimer.types[:close],
		auto_close_hours,
		based_on_last_post: true
	)
	MessageBus.publish("/topic/#{topic.id}", reload_topic: true)
end

Please test it with one topic first, hope this helps!

2 לייקים