# Bulk topic timers

**URL:** <https://meta.discourse.org/t/bulk-topic-timers/104941>\
**Category:** Feature\
**Tags:** topic-timers\
**Created:** [23 בדצמבר,‏ 2018,‏ 10:14am UTC](https://meta.discourse.org/t/bulk-topic-timers/104941 "2018-12-23T10:14:30Z")\
**Posts on this page:** 1\
**Showing post:** 14

<div class="post-metadata">

**Author:** ![fhe](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fhe/32/113345_2.png) [@fhe](https://meta.discourse.org/u/fhe)\
**Post date:** [15 בדצמבר,‏ 2021,‏ 2:54pm UTC](https://meta.discourse.org/t/bulk-topic-timers/104941/14 "2021-12-15T14:54:40Z")

</div>

I didn’t make any notes unfortunately 😇

> **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

```Ruby
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!

---

_[View the full topic](https://meta.discourse.org/t/bulk-topic-timers/104941)._
