diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2020-11-02 23:18:55 +0100 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2020-11-02 23:18:55 +0100 |
commit | 8b62bf32852372af29871ee0c0ca6128d2c81a37 (patch) | |
tree | 615a435ac83d2eb0bb71e6d513ee3df8a29dba65 | |
parent | fix definition of the filter variable (diff) | |
download | newspipe-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-x | newspipe/commands.py | 9 |
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) |