diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2016-09-20 23:18:16 +0200 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2016-09-20 23:18:16 +0200 |
commit | 9f902d2485088c3dbf852a6fa0aaed580760ccb5 (patch) | |
tree | 0441886104246b11851ad7d3f4d468158987358e /src/web/views/views.py | |
parent | Return the most popular feeds for the last 30 days (before the date of the la... (diff) | |
download | newspipe-9f902d2485088c3dbf852a6fa0aaed580760ccb5.tar.gz newspipe-9f902d2485088c3dbf852a6fa0aaed580760ccb5.tar.bz2 newspipe-9f902d2485088c3dbf852a6fa0aaed580760ccb5.zip |
the number of days can be give in the url
Diffstat (limited to 'src/web/views/views.py')
-rw-r--r-- | src/web/views/views.py | 5 |
1 files changed, 3 insertions, 2 deletions
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 |