"clean up inactive users after days" meaning and statistics

This is described as:

Number of days before an inactive user (trust level 0 without any posts) is removed. To disable clean up set to 0.

Can you confirm that these are the criteria (TL0 and 0 posts)? Is any account taken of when they last logged in and/or read a post, or does the number of days start from registration?

Is there a data explorer query to show TL0 users who have 0 posts alongside the relevant number of days? This would be to give an idea of the effect of choosing specific numbers for this setting. Thanks.

There are some additional criteria: admins and moderators aren’t deleted
Also the last seen and the registration date are checked.

I think something like this should return the number of users that would be deleted

-- [params]
-- int :active_days_ago

SELECT COUNT(*)
FROM users
WHERE last_posted_at IS NULL
  AND trust_level = 0
  AND admin = false
  AND moderator = false
  AND created_at < CURRENT_DATE - :active_days_ago
  AND (last_seen_at < CURRENT_DATE - :active_days_ago OR last_seen_at IS NULL)
  AND NOT EXISTS (
    SELECT 1 FROM posts WHERE posts.user_id = users.id
  )
  AND NOT EXISTS (
    SELECT 1 FROM topics WHERE topics.user_id = users.id
  )

To see which users would be deleted this should work

-- [params]
-- int :active_days_ago

SELECT 
    id as user_id,
    DATE_PART('day', CURRENT_DATE - created_at) AS days_since_created,
    DATE_PART('day', CURRENT_DATE - last_seen_at) AS days_since_seen
FROM users
WHERE last_posted_at IS NULL
  AND trust_level = 0
  AND admin = false
  AND moderator = false
  AND created_at < CURRENT_DATE - :active_days_ago
  AND (last_seen_at < CURRENT_DATE - :active_days_ago OR last_seen_at IS NULL)
  AND NOT EXISTS (
    SELECT 1 FROM posts WHERE posts.user_id = users.id
  )
  AND NOT EXISTS (
    SELECT 1 FROM topics WHERE topics.user_id = users.id
  )
ORDER BY days_since_seen
4 Likes

Thanks. I’ll try that.

The admin setting text needs to be updated as it’s wrong.

What’s last_seen_at based on? Logging in, or (being logged in) viewing any page of the forum?

It is this. The last time they were actively viewing the forums.

1 Like