~cedric/newspipe

8b62bf32852372af29871ee0c0ca6128d2c81a37 — C├ędric Bonhomme 26 days ago f7a761e
fixed deletion of inactive users. users are now deleted in a for loop on the result of the read method.
1 files changed, 8 insertions(+), 1 deletions(-)

M newspipe/commands.py
M newspipe/commands.py => newspipe/commands.py +8 -1
@@ 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)