User trust level filter not working for vote plugin?

AI-generated summary

The user Matt0x01 reports an issue with a SQL query related to the vote plugin, specifically that a trust level filter isn’t working as expected. They provide a query attempting to filter topics by category and user trust level, but it includes redundant joins and incorrect logic. Matt0x01 later updates that the issue was resolved by using the voting_votes table and applying a count function.

Issue in title. Any idea how to fix?

SELECT 
dvc.votes_count AS vote_count,
t.id AS topic_id


FROM topics t
    INNER JOIN discourse_voting_topic_vote_count dvc ON dvc.topic_id = t.id
    INNER JOIN users u ON t.user_id = u.id
    INNER JOIN post_actions pa ON pa.user_id = u.id
    INNER JOIN users u2 ON pa.user_id = u2.id
WHERE t.category_id = 20
    AND u2.trust_level >= 1
    
GROUP BY dvc.votes_count, t.id, pa.user_id
ORDER BY vote_count DESC

EDIT: Solved. Used voting_votes and count function