太好了,这有帮助!鉴于我们已经偏离主题,这可能应该移到一个新主题。但这是我(在 ChatGPT 的帮助下)提出的查询,它只返回了给出/收到表情符号的用户、表情符号数量、表情符号日期以及指向特定帖子的 URL。我唯一无法实现的是使帖子 URL 可点击,这似乎仅限于主题 URL。
WITH reaction_pairs AS (
SELECT
p.user_id AS received_reaction_user_id,
dru.user_id AS gave_reaction_user_id,
dr.post_id,
t.id AS topic_id,
t.slug AS topic_slug,
p.post_number,
dru.created_at AS reaction_date
FROM
discourse_reactions_reactions dr
JOIN discourse_reactions_reaction_users dru ON dr.id = dru.reaction_id
JOIN posts p ON dr.post_id = p.id
JOIN topics t ON p.topic_id = t.id
WHERE
dr.reaction_value = 'Your_Specific_Reaction_Here'
)
SELECT
ur1.id AS user_id,
ur2.username AS "给出表情符号的用户",
'Your_Community_URL' || 't/' || rp.topic_slug || '/' || rp.topic_id || '/' || rp.post_number AS "帖子 URL",
rp.reaction_date AS "表情符号日期",
COUNT(*) AS "表情符号数量"
FROM
reaction_pairs rp
JOIN users ur1 ON rp.received_reaction_user_id = ur1.id
JOIN users ur2 ON rp.gave_reaction_user_id = ur2.id
GROUP BY
ur1.id,
ur2.username,
rp.topic_slug,
rp.topic_id,
rp.post_number,
rp.reaction_date
ORDER BY
"表情符号数量" DESC, "表情符号日期" DESC