~cedric/newspipe

ca25a7e28e8b016d24ffe0bc4c556d2db30e7bc0 — C├ędric Bonhomme 26 days ago abd6d3f
added a command to delete inactive users (number of months given in parameter).
1 files changed, 16 insertions(+), 1 deletions(-)

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