From 8b62bf32852372af29871ee0c0ca6128d2c81a37 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Mon, 2 Nov 2020 23:18:55 +0100 Subject: fixed deletion of inactive users. users are now deleted in a for loop on the result of the read method. --- newspipe/commands.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/newspipe/commands.py b/newspipe/commands.py index 219db8c4..ca586039 100755 --- a/newspipe/commands.py +++ b/newspipe/commands.py @@ -70,7 +70,14 @@ def delete_inactive_users(last_seen): filter = {} filter["last_seen__lt"] = date.today() - relativedelta(months=last_seen) try: - user = UserController().delete(**filter) + users = UserController().read(**filter) + for user in users: + db.session.delete(user) + try: + print("Deleting user {}...".format(user.nickname)) + db.session.commit() + except: + db.session.rollback() print("Inactive users deleted.") except Exception as e: print(e) -- cgit