diff options
-rwxr-xr-x | newspipe/commands.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/newspipe/commands.py b/newspipe/commands.py index 40bd583e..03d5053e 100755 --- a/newspipe/commands.py +++ b/newspipe/commands.py @@ -3,7 +3,8 @@ import logging import os -from datetime import datetime +from dateutil.relativedelta import relativedelta +from datetime import datetime, date import click from werkzeug.security import generate_password_hash @@ -62,6 +63,20 @@ def delete_user(user_id=None): print(e) +@application.cli.command("delete_inactive_users") +@click.option('--last-seen', default=6, help='Number of months since last seen.') +def delete_inactive_users(last_seen): + "Delete inactive users." + filter["last_seen__lt"] = date.today() - relativedelta(months=last_seen) + try: + user = UserController().read(**filter).all() + for us in user: + print(us.nickname) + print("Inactive users deleted.") + except Exception as e: + print(e) + + @application.cli.command("fetch_asyncio") @click.option('--user-id', default=None, help='Id of the user') @click.option('--feed-id', default=None, help='If of the feed') |