aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2020-11-02 23:18:55 +0100
committerCédric Bonhomme <cedric@cedricbonhomme.org>2020-11-02 23:18:55 +0100
commit8b62bf32852372af29871ee0c0ca6128d2c81a37 (patch)
tree615a435ac83d2eb0bb71e6d513ee3df8a29dba65
parentfix definition of the filter variable (diff)
downloadnewspipe-8b62bf32852372af29871ee0c0ca6128d2c81a37.tar.gz
newspipe-8b62bf32852372af29871ee0c0ca6128d2c81a37.tar.bz2
newspipe-8b62bf32852372af29871ee0c0ca6128d2c81a37.zip
fixed deletion of inactive users. users are now deleted in a for loop on the result of the read method.
-rwxr-xr-xnewspipe/commands.py9
1 files changed, 8 insertions, 1 deletions
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)
bgstack15