For adding topic timers, e.g., close topic 1 month after last update, it would be great to have a bulk option. This would allow for adding topic timers to multiple topics at once, without going into each individual topic.
Interesting idea. Are you referring to this modal?
If so, an edge cases to consider: What happens if there’s already a topic timer on one (or more) of the selected topics?
Yes, exactly this modal.
I’d find it natural to have the same behavior as if the set topic timer action is performed again on a topic that already has one, i.e., overwrite the existing timer.
May I ask why the “Auto-close topic hours” setting on the category isn’t enough?
Are you adding these timers on topics spanning multiple categories?
Absolutely. I’ve added this setting (720 hours and ticked Don’t close until the last post in the topic is at least this old) and it seems to affect only newly added topics, not those that are currently in this category.
I wanted to bulk add the topic timer to the topics that already existed in the category.
I thought we had a rails command to apply the category setting retroactively too all topics within the category, but I’m failing to find it right now. I’ll keep looking…
This is a pretty unique request, why not consume the api, my feeling is that your own custom sword here will fit way better
Thanks for the suggestion.
I’ve went with a combination of database queries to identify the relevant topic IDs and requests to the timer API.
Acabo de encontrar este tema, buscando la misma funcionalidad.
¿Alguien puede compartir cómo podría aplicar un temporizador a todos los temas dentro de una categoría? Ya he creado cientos de temas de documentación y acabo de descubrir esta función y quiero aplicarla retroactivamente.
Si todavía no es posible hacerlo a través del front-end, ¿pueden proporcionar alguna orientación sobre cómo hacerlo a través de la API? Aún no estoy muy familiarizado con ella.
¡Gracias!
@fhe ¿hay alguna posibilidad de que compartas lo que hiciste para lograr esto?
Lamentablemente no tomé ninguna nota ![]()
Descargo de responsabilidad: Por favor, haz todo eso solo si entiendes lo que propongo y si tienes una copia de seguridad de tu instancia de Discourse y sabes cómo aplicarla. No lo he probado yo mismo, así que podría necesitar algunos ajustes.
1. Obtener los IDs de tema relevantes
Esto obtendría cualquier ID de tema de la categoría con ID 11 que no esté eliminada y no esté cerrada.
SELECT id FROM topics WHERE category_id = 11 AND deleted_at IS NULL AND closed = FALSE ORDER BY id
Digamos que el resultado es 3, 6, 12, 24
2. Crear los temporizadores de tema
A continuación, introduce la consola de Rails en tu contenedor y usa algo como
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
¡Por favor, pruébalo primero con un tema, espero que esto ayude!
