From 9f902d2485088c3dbf852a6fa0aaed580760ccb5 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Tue, 20 Sep 2016 23:18:16 +0200 Subject: the number of days can be give in the url --- src/web/views/views.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/web') diff --git a/src/web/views/views.py b/src/web/views/views.py index 81ae081d..abebff15 100644 --- a/src/web/views/views.py +++ b/src/web/views/views.py @@ -48,15 +48,16 @@ def handle_sqlalchemy_assertion_error(error): @etag_match def popular(): """ - Return the most popular feeds for the last 30 days. + Return the most popular feeds for the last nb_days days. """ + nb_days = int(request.args.get('nb_days', 365)) last_added_feed = FeedController().read().\ order_by(desc('created_date')).limit(1) if last_added_feed: last_added_feed_date = last_added_feed.all()[0].created_date else: last_added_feed_date = datetime.now() - not_before = last_added_feed_date - timedelta(days=30) + not_before = last_added_feed_date - timedelta(days=nb_days) filters = {} filters['created_date__gt'] = not_before -- cgit