Thanks that helped! This should probably be moved to a new topic since we’re derailing. But here’s the query I came up with (with the help of ChatGPT) that simply returns the users who gave/received the reaction, how many reactions, the date of reaction, and the url to the specific post. The only thing I couldn’t seem to do is make the URL to the post clickable, it seems that’s limited to topic URLs.
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 "User Who Gave Reaction",
'Your_Community_URL' || 't/' || rp.topic_slug || '/' || rp.topic_id || '/' || rp.post_number AS "Post URL",
rp.reaction_date AS "Reaction Date",
COUNT(*) AS "Number of Reactions"
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
"Number of Reactions" DESC, "Reaction Date" DESC