Does read-only mode prevent users from getting the devotee badge?

To answer your first question, I would expect putting a site into read only mode to affect users ability to get the Devotee badge. When a site is in read only mode, no new data is written to the database, so details about the user’s visits will not be recorded when the site is in read only mode.

Give this query a try. It returns the days that a user has not visited the site between a given start and end date:

Days without visits for user

--[params]
-- date :start_date
-- date :end_date
-- string :username

WITH days AS (
SELECT date_trunc('day', day)::date AS day
FROM generate_series(:start_date::date, :end_date::date, '1 day') AS day
),
users_visits AS (
SELECT
visited_at
FROM user_visits uv
JOIN users u ON u.id = uv.user_id
WHERE u.username = :username
AND visited_at BETWEEN :start_date AND :end_date
),
visits_days AS (
SELECT
day,
visited_at
FROM days 
LEFT JOIN users_visits uv
ON uv.visited_at = day
ORDER BY day DESC
)

SELECT day AS days_without_visits
FROM visits_days WHERE visited_at IS NULL
ORDER BY day DESC

If you would like to award the badge to some users who do not technically qualify for it, have a look at How to award a non-custom badge through the console. Note, that approach is only possible on self-hosted sites. For sites on our hosting, we can grant the badges listed in that topic for you.

4 Likes