From 0ed4736dd07a7eea28013cf249ec2a6ac6bcfaf4 Mon Sep 17 00:00:00 2001 From: Lynne Date: Sat, 7 Sep 2019 19:37:48 +1000 Subject: [PATCH] if no bots are learning from an account, delete it --- service.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/service.py b/service.py index 346c42e..14069c5 100755 --- a/service.py +++ b/service.py @@ -95,8 +95,12 @@ db = MySQLdb.connect( db=cfg['db_name'] ) -print("Downloading posts") +print("Cleaning up database") +# delete any fedi accounts we no longer need cursor = db.cursor() +cursor.execute("DELETE FROM fedi_accounts WHERE handle NOT IN (SELECT fedi_id FROM bot_learned_accounts);") + +print("Downloading posts") cursor.execute("SELECT `handle`, `outbox` FROM `fedi_accounts` ORDER BY RAND()") accounts = cursor.fetchall() with Pool(8) as p: