我没有一个非常强大的 Discourse 实例可以进行彻底的测试,但我认为这个 Data Explorer 查询可能会为您指明正确的方向。(也许其他人可以帮忙完善一下!)
SELECT count(*)
FROM post_actions AS pac
JOIN posts p on p.id = pac.post_id
JOIN topics t on t.id = p.topic_id
WHERE pac.post_action_type_id in ('3','4','7','8')
AND pac.created_at >= NOW() - INTERVAL '20 MINUTE'
AND t.category_id = '4'
SELECT count(*)
FROM post_actions AS pac
JOIN posts p on p.id = pac.post_id
JOIN topics t on t.id = p.topic_id
JOIN categories c on c.id = t.category_id
WHERE pac.post_action_type_id in ('3','4','7','8')
AND pac.created_at >= NOW() - INTERVAL '20 MINUTE'
AND c.name = 'General'
--[params]
-- int_list :category_ids
-- text :interval = 20min
SELECT t.category_id, count(pa.id) count
from post_actions pa
INNER JOIN posts p on p.id = pa.post_id
INNER JOIN topics t on t.id = p.topic_id
WHERE post_action_type_id in (3, 4, 6, 7, 8)
AND t.category_id in (:category_ids)
AND pa.created_at >= now() - interval :interval
GROUP BY t.category_id