From 0ba11942bf19941fe09b3c2de33e3f6155edcf34 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Tue, 17 Nov 2015 10:27:57 +0100 Subject: minor improvements when deleting old articles, this was stupid... --- pyaggr3g470r/views/views.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'pyaggr3g470r') diff --git a/pyaggr3g470r/views/views.py b/pyaggr3g470r/views/views.py index cf405fe4..2e5d01fb 100644 --- a/pyaggr3g470r/views/views.py +++ b/pyaggr3g470r/views/views.py @@ -612,12 +612,10 @@ def expire_articles(): """ current_time = datetime.datetime.utcnow() weeks_ago = current_time - datetime.timedelta(weeks=int(request.args.get('weeks', 10))) - articles_to_delete = Article.query.filter( - and_(Article.user_id == g.user.id, - or_(Article.date < weeks_ago, - Article.retrieved_date < weeks_ago))) - for article in articles_to_delete: - db.session.delete(article) + Article.query.filter( + and_(Article.user_id == g.user.id, + or_(Article.date < weeks_ago, + Article.retrieved_date < weeks_ago))).delete() flash(gettext('Articles deleted.'), 'info') db.session.commit() return redirect(redirect_url()) -- cgit