From ca25a7e28e8b016d24ffe0bc4c556d2db30e7bc0 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Mon, 2 Nov 2020 23:05:02 +0100 Subject: added a command to delete inactive users (number of months given in parameter). --- newspipe/commands.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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') -- cgit