aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2020-11-02 23:05:02 +0100
committerCédric Bonhomme <cedric@cedricbonhomme.org>2020-11-02 23:05:02 +0100
commitca25a7e28e8b016d24ffe0bc4c556d2db30e7bc0 (patch)
tree0f8677afa4faa498fa31b8bc022d516ee8ce1e1a
parentadded a command to delete a user with its id. (diff)
downloadnewspipe-ca25a7e28e8b016d24ffe0bc4c556d2db30e7bc0.tar.gz
newspipe-ca25a7e28e8b016d24ffe0bc4c556d2db30e7bc0.tar.bz2
newspipe-ca25a7e28e8b016d24ffe0bc4c556d2db30e7bc0.zip
added a command to delete inactive users (number of months given in parameter).
-rwxr-xr-xnewspipe/commands.py17
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')
bgstack15