Does Discourse track consecutive days active?

AI-generated summary

The discussion explores whether Discourse tracks consecutive days active, referencing Reddit’s similar feature. MikeNolan asks if such data is available in the admin panel. NateDhaliwal confirms that Discourse does track consecutive days via badges like Enthusiast, Aficionado, and Devotee, based on visits (e.g., liking a post or replying). Lilly provides a SQL query example using the user_visits table to calculate streaks, and suggests combining it with the user_actions table for more comprehensive tracking. MikeNolan thanks the contributors and notes he’ll keep the information in mind.

A member of our Discourse forum has asked if Discourse has a way to show/recognize consecutive days visiting in or posting in a Discourse forum. I don’t see that information anywhere in the admin’s user information, is it kept anywhere?

FWIW, reddit has this feature.

Well, yes, as there are badges like Enthusiast, Aficionado, and Devotee that are for consecutive days visited. Visited = liked a post/replied once IIRC.

You can probably make a data explorer query. here is the user_visits table schema here:

maybe something like this? :thinking:

WITH consecutive_visits AS (
    SELECT
        user_id,
        visited_at,
        visited_at - INTERVAL '1 day' * ROW_NUMBER() OVER (PARTITION BY user_id ORDER BY visited_at) AS grp
    FROM
        user_visits
),
visit_streaks AS (
    SELECT
        user_id,
        COUNT(*) AS streak_length
    FROM
        consecutive_visits
    GROUP BY
        user_id, grp
)
SELECT
    user_id,
    MAX(streak_length) AS longest_streak
FROM
    visit_streaks
GROUP BY
    user_id
ORDER BY
    longest_streak DESC
LIMIT 100

or perhaps you could combine with the user_actions table instead (visits with likes and posts?), which is here:

Thanks, I’ll keep that in mind.