Please eval short Ruby script to suspend inactive users

Thanks for your interest, @pfaffman !

There are user records with no last_seen_at, created months ago, approved=False, active=False, and they are not being purged.
There are user records with last_seen_at > 7 days (months old) and 0 views, and they are not being purged.

Whatever the criteria being used with that grace period flag, it is not selecting these records.
Can someone post the exact query that is being used there so that I can understand what other factors are involved there?

No, looking at the DB directly there are user records that fit each criterion but not all. It seems the users table in the database is inconsistent. There are records with non-zero topics_entered or posts_read_count, but with views=0. There are records with topics_entered=0 and posts_read_count=0, but views is non-zero.

The key point to remember is that as this site was being developed the settings weren’t optimal and humans and bots were registering. The OR clause seems to get all of these. Now that the site is stablized with (I hope) sane settings, I don’t expect new registrations to result in the same anomalies.

I intend to run the script many times with different criteria. I will query records first, outside of the environment, and then run the silence script to target only the records I really want. In a couple weeks I’ll do a final run, just select silenced records (anyone who actually came back will get the flag removed), and purge all of them:

UserDestroyer.new(admin_user).destroy(user, reassign_to: archive_user)

My overall question is whether the v0.0.2 script, with its approach to selection, logging, and silencing, is correct for a Discourse system. I don’t know if there is something else to be done in a loop like this. I’ve never created and run my own script so this is request to check me for noobish knucklehead mistakes.

Thanks!!