From e1c44d99d50d993283871c9d58857e17430c68d8 Mon Sep 17 00:00:00 2001 From: TLSM Date: Wed, 7 Sep 2022 18:29:40 -0400 Subject: [PATCH] cron.py: hole inactivity criteria, stealth fix. Two bugs: 1) Drafts, deleted posts, and removed posts counted toward hole aliveness. This has been fixed. 2) Foreign key constraints in sub_joins weren't getting deleted, so stealth holes couldn't be deleted. Both of these conspired to keep /h/smuggies alive, so they must be fixed. --- files/helpers/cron.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/files/helpers/cron.py b/files/helpers/cron.py index 4a73500e1..b8f93f44c 100644 --- a/files/helpers/cron.py +++ b/files/helpers/cron.py @@ -50,7 +50,9 @@ def sub_inactive_purge_task(): one_week_ago = time.time() - 604800 active_holes = [x[0] for x in g.db.query(Submission.sub).distinct() \ - .filter(Submission.sub != None, Submission.created_utc > one_week_ago).all()] + .filter(Submission.sub != None, Submission.created_utc > one_week_ago, + Submission.private == False, Submission.is_banned == False, + Submission.deleted_utc == 0).all()] active_holes.append('changelog') # system hole immune from deletion dead_holes = g.db.query(Sub).filter(Sub.name.notin_(active_holes)).all() @@ -82,8 +84,10 @@ def sub_inactive_purge_task(): g.db.add(post) to_delete = mods \ + + g.db.query(Category).filter(Category.sub.in_(names)).all() \ + g.db.query(Exile).filter(Exile.sub.in_(names)).all() \ + g.db.query(SubBlock).filter(SubBlock.sub.in_(names)).all() \ + + g.db.query(SubJoin).filter(SubJoin.sub.in_(names)).all() \ + g.db.query(SubSubscription).filter(SubSubscription.sub.in_(names)).all() for x in to_delete: