数据浏览器 - 投票计数

大家好!

我正在使用 Data Explorer 插件,并尝试获取我们 Feedback 类别中的主题。使用以下查询,我可以很好地实现此目的:

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

我不确定的是如何也包含与 Topic Voting 插件关联的投票计数。有人知道如何在上面的查询中为每个帖子包含它吗?

1 个赞

Topic Voting 表是 discourse_voting_topic_votesdiscourse_voting_votes。您可以使用类似以下内容包含每个主题的投票数::+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

Data & reporting 类别中还有另外几个查询可能对您有用 - Topics tagged topic-voting

5 个赞

谢谢 @JammyDodger:heart:

2 个赞

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