A summary of votes by topic, including tags

That’s okay. :slight_smile: It would go in this bit here: (just change it to your own site address instead of Meta)

-- [params]
-- int :category_id 

WITH tag_names AS (
    SELECT t.id topic_id,
    string_agg(tags.name, ', ' ORDER BY tags.name) AS "tags"
    FROM topics t
    JOIN topic_tags tt ON tt.topic_id = t.id
    JOIN tags ON tags.id = tt.tag_id
    GROUP BY t.id
)

SELECT t.created_at::date,
       dvtvc.topic_id,
       t.title,
       'https://meta.discourse.org/t/' || t.slug || '/' || 
       t.id AS topic_url,
       votes_count,
       t.posts_count,
       tn.tags,
       t.closed
FROM discourse_voting_topic_vote_count dvtvc
JOIN topics t ON t.id = dvtvc.topic_id
LEFT JOIN tag_names tn ON dvtvc.topic_id = tn.topic_id
WHERE t.category_id = :category_id
AND votes_count > 0
ORDER BY t.created_at DESC