查找特定月份内标记为“已解决”的帖子

我在企业环境中运行 Discourse,将其用作订单和文档系统。我使用标签来判断订单(主题)是进行中还是已完成。但我需要一种方法来识别在三月等特定月份完成的订单。

我不希望为每个月都使用一个标签,例如 tag: March19。

希望在相应类别中限制可见标签的数量,以方便订单的创建和维护。

我曾想过使用井号标签(hashtags):当订单完成时,交付订单的人可以在帖子末尾评论 #march19,这样就可以通过该标签进行搜索。但似乎我的 Discourse 中井号标签并未按预期工作,该功能是否为了标签系统的优势而被移除了?

还有其他插件或方法可以实现这一目标吗?
需要一些建议 :slight_smile:

If you have admin privileges you could use the data explorer plugin.

Thanks, good suggestion but I am not so familiar with database inquiries so do not know if I even know where to start with it. Can anyone use / view the results of a request through data explorer in any way? Would be good if everyone could sort out examples delivered things in March easily and not just administrators.

Here is a starting point.

-- [params]
-- int :months_ago = 1

WITH query_period AS
(SELECT date_trunc('month', CURRENT_DATE) - INTERVAL ':months_ago months' AS period_start,
                                                    date_trunc('month', CURRENT_DATE) - INTERVAL ':months_ago months' + INTERVAL '1 month' - INTERVAL '1 second' AS period_end)
select posts.*
from posts
inner join ( 
	select topic_id, value::int accepted_answer_post_id 
	from topic_custom_fields 
	where name = 'accepted_answer_post_id'
	order by name 
) solved_by_post
on posts.id = solved_by_post.accepted_answer_post_id
inner join query_period
on posts.created_at >= query_period.period_start
AND posts.created_at <= query_period.period_end
order by posts.created_at desc 

solved-topics-in-month.dcquery (1).json (1.1 KB)

You could run a cron job at the start of each month to get the results and then create a new topic … ‘Orders Completed in March 2019’ with links to each result in the topic.