I thought this would be really complicated, but turns out there’s a handy “participant_count” column in the database
Top topics by number of unique participants over the last year
-- [params]
-- string :interval = 1 year
SELECT id as topic_id, participant_count
FROM topics
WHERE bumped_at >= CURRENT_DATE - INTERVAL :interval
ORDER BY participant_count DESC
Average number of unique participants over the last year
-- [params]
-- string :interval = 1 year
SELECT avg(participant_count)
FROM topics
WHERE bumped_at >= CURRENT_DATE - INTERVAL :interval
Is there documentation anywhere of what the different variables, like participant_count actually represent?
The top topics query is returning numbers that don’t match the “Frequent posters” image in the thread. I’m wondering if it includes likes or some other activity.
Sorry for the very long delay. I do have some examples now. Sometimes the query is right, sometimes the count displayed in the thread is right. Sometimes they report the same number and are both right!
I noticed that when the counts differ, the threads have had posts split off to new threads.
In above example (both images are from same topic) the first image includes hidden post users since logged in as admin. So it have 21 Frequent Posters. In second image while looking at the topic as anonymous user it correctly shows 17 Frequent users by excluding hidden posts.
For staffs we will render hidden (deleted) posts. That’s why it included them too in “Frequent Posters” list. Should we hide them?
I tested this functionality. I am unable to reproduce it. As I described in previous post the counts are differ (for staffs) only if the topic had deleted posts.
Like it named as “Frequent Posters” currently we only displaying top 24 users who frequently posted. So if a topic had more than 24 users it will filter and display only top 24 participants.