Data Explorer - Conteggio voti

Ciao a tutti!

Sto usando il plugin Data Explorer e sto tentando di ottenere argomenti all’interno della nostra categoria Feedback - riesco a farlo bene con la seguente query:

SELECT
    t.id AS topic_id,
    t.title AS topic_title,
    t.excerpt,
    t.like_count,
    ('https://our_community.com/t/' || t.slug || '/' || t.id) AS url
FROM
    topics t
WHERE
    t.category_id = 95
AND
    t.created_at > NOW() - INTERVAL '2 years'
AND deleted_at IS NULL

Quello che non mi è chiaro è come includere anche il conteggio dei voti associato al plugin Topic Voting. Qualcuno sa come potrei includerlo per ogni post nella query sopra?

1 Mi Piace

Le tabelle di Votazione Argomenti sono discourse_voting_topic_votes e discourse_voting_votes. Puoi includere il numero di voti per ciascun argomento con qualcosa di simile a questo: :+1:


SELECT
    t.id AS topic_id,
    t.title AS topic_title,
    dvtv.votes_count,
    t.excerpt,
    t.like_count,
    ('https://our_community.com/t/' || t.slug || '/' || t.id) AS url
FROM 
    topics t
JOIN 
    discourse_voting_topic_vote_count dvtv ON t.id = dvtv.topic_id
WHERE 
    t.category_id = 95
AND 
    t.created_at > NOW() - INTERVAL '2 years'
AND deleted_at IS NULL

Ci sono anche un paio di query aggiuntive che potresti trovare utili nella categoria Data & reporting - Topics tagged topic-voting

5 Mi Piace

Grazie @JammyDodger ! :heart:

2 Mi Piace

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.