Bulk delete suspended users after import

For that, you should enter into the container with

./launcher enter app

Then, you will need to launch the rails console with

rails c

Once you’re in the rails console, you can delete all suspended users who have zero posts and topics with

User.joins(:user_stat).where("users.suspended_at IS NOT NULL AND user_stats.topic_count = 0 AND user_stats.post_count = 0").destroy_all

Always make sure you have latest db backup whenever you run destroy_all method.

13 Likes