How to rest multiple topics bump date
I don’t know what the use case is, but it seems to me, as far as with using the web UI, it would be easy enough to reset the bump date of individual topics when they were bumped. I’m not seeing how “bulk bump date reset” would ever be needed let alone a common enough need for it to need to have a UI.
Anyway, if you’ve somehow managed to get in a situation where you want to work in bulk, it should be possible to do using the CLI
Thanks for the reply.
I use a bot to fetch RSS blog/Podcast to Discourse, when the feed changed, the topics will be updated automatically and bump up. I have to reset one by one so I think it’s should be better if I can bulk reset.
What do you means CLI? Bulk reset via the database? Thanks.
我刚才正在找这个功能。
这是因为我在整理和重新安排论坛内容时,大量旧帖子被顶到了顶部。现在我不得不逐个进入帖子并重置置顶时间。
https://github.com/discourse/discourse/blob/master/app/models/topic.rb
如果我没理解错的话,Topics 表中有一个 bumped_at 字段,其类型为 datetime,且不能为空。该字段的初始非空值即为 created_at 非空值。据我所知,该 datetime 值是 Ruby 的 now 方法获取的当前时间。
我认为,如果你能尽可能明确以下几点:
- 操作前是什么状态
- 你具体做了什么
- 你希望达到什么目的
那么你就有很大机会构造出一个合适的查询语句。多少数据量算“大量”?如果只是一次性操作,也许直接手动处理会更简单。
(遗憾的是,并没有一个名为 “prior_to_bump_date” 的字段
)
我也是!
如何从 rails 控制台手动重置“bump date”?将相关主题的 bumped_at 恢复为 updated_at?