~cedric/newspipe

2dcdaa9b8f5174fdde35174ae9fe611ae8d6a1c9 — Cédric Bonhomme 5 months ago b78cf33
new: [commands] Added a function which deletes read articles retrieved since more than 5 days ago.
1 files changed, 18 insertions(+), 1 deletions(-)

M newspipe/commands.py
M newspipe/commands.py => newspipe/commands.py +18 -1
@@ 11,7 11,7 @@ from werkzeug.security import generate_password_hash

import newspipe.models
from newspipe.bootstrap import application, db
from newspipe.controllers import UserController
from newspipe.controllers import UserController, ArticleController

logger = logging.getLogger("commands")



@@ 99,6 99,23 @@ def disable_inactive_users(last_seen):
    print("Inactive users disabled.")


@application.cli.command("delete_read_articles")
def delete_read_articles():
    "Delete read articles retrieved since more than 5 days ago."
    filter = {}
    filter["user_id__ne"] = 1
    filter["readed"] = True
    filter["retrieved_date__lt"] = date.today() - relativedelta(days=5)
    articles = ArticleController().read(**filter)
    for article in articles:
        try:
            db.session.delete(article)
            db.session.commit()
        except:
            db.session.rollback()
    print("Read articles deleted.")


@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')