• 12 Posts
  • 45 Comments
Joined 1 year ago
cake
Cake day: June 8th, 2023

help-circle






  • From ChatGPT and a huge thank you to @sunaurus@lemm.ee who reached out to us initially about the issue. Unfortunately the SQL he provided seemed a bit of a nuke so I modified it a bit using chatgpt and got the below which got us to 335 users. I will keep a close eye on the ones left

    This got most of them (27k+) SELECT lu.id, p.name, lu.email FROM local_user lu JOIN person p ON lu.person_id = p.id LEFT JOIN community_follower cf on p.id = cf.person_id LEFT JOIN comment c on p.id = c.creator_id LEFT JOIN post on p.id = post.creator_id WHERE cf.id is null AND c.id is null AND post.id is null AND lu.validator_time >= '2023-06-19' AND lu.email IS NOT NULL AND lu.email <> '' AND lu.email ~ '[0-9]{5,}' ORDER BY lu.id DESC;

    This got 1000 or so left by lowering to 4 numbers after an email

    DELETE FROM local_user WHERE id IN (SELECT lu.id FROM local_user lu JOIN person p ON lu.person_id = p.id LEFT JOIN community_follower cf on p.id = cf.person_id LEFT JOIN comment c on p.id = c.creator_id LEFT JOIN post on p.id = post.creator_id WHERE cf.id is null AND c.id is null AND post.id is null AND lu.validator_time >= '2023-06-19' AND lu.email IS NOT NULL AND lu.email <> '' AND lu.email ~ '[0-9]{4,}');

    And this got 500 by looking for usernames with 2 digits after their username. If you’re worried about hitting actual users here use the joins

    SELECT p.name, lu.email FROM local_user lu JOIN person p ON lu.person_id = p.id WHERE lu.person_id >= 356 AND p.name ~ '\d';