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.
방금 이 주제를 발견했습니다. 같은 기능을 찾고 있었거든요.
카테고리 내 모든 주제에 타이머를 적용하는 방법을 공유해 주실 수 있나요? 이미 수백 개의 문서(Doculation) 주제를 생성해 두었는데, 이 기능을 이제야 알게 되어 소급 적용하고 싶습니다.
여전히 프론트엔드에서 이 기능을 사용할 수 없다면, API를 통해 어떻게 해야 하는지 안내해 주실 수 있을까요? 아직 API에 익숙하지 않아서요.
감사합니다!
@fhe 이걸 어떻게 구현하셨는지 공유해 주실 수 있을까요?
아쉽게도 메모를 하지 않았습니다 ![]()
면책 조항: 제가 제안하는 내용을 이해하고, Discourse 인스턴스의 백업을 가지고 있으며 백업 적용 방법을 알고 있는 경우에만 아래 내용을 실행하시기 바랍니다. 제가 직접 테스트하지 않았으므로 조정 사항이 필요할 수 있습니다.
1. 관련 주제 ID 가져오기
이 쿼리는 ID가 11인 카테고리에서 삭제되지 않고 닫히지 않은 주제 ID를 가져옵니다.
SELECT id FROM topics WHERE category_id = 11 AND deleted_at IS NULL AND closed = FALSE ORDER BY id
결과가 3, 6, 12, 24라고 가정해 보겠습니다.
2. 주제 타이머 생성
다음으로 컨테이너에서 rails 콘솔을 실행하고 다음과 같은 코드를 사용하세요.
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
먼저 하나의 주제로 테스트해 보시기 바랍니다. 도움이 되길 바랍니다!
