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?
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?
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: