diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2016-09-21 07:21:09 +0200 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2016-09-21 07:21:09 +0200 |
commit | de745a40a1ee5d4f2e58abfcd9358e5436e62730 (patch) | |
tree | 50a295518fe426d57ad04d8e85ba828436f221be /src/web | |
parent | set the limit of days to 1000 (for the tests). (diff) | |
download | newspipe-de745a40a1ee5d4f2e58abfcd9358e5436e62730.tar.gz newspipe-de745a40a1ee5d4f2e58abfcd9358e5436e62730.tar.bz2 newspipe-de745a40a1ee5d4f2e58abfcd9358e5436e62730.zip |
Added more comments.
Diffstat (limited to 'src/web')
-rw-r--r-- | src/web/views/views.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/web/views/views.py b/src/web/views/views.py index 57f9e9c9..ecb4f888 100644 --- a/src/web/views/views.py +++ b/src/web/views/views.py @@ -50,21 +50,24 @@ def popular(): """ Return the most popular feeds for the last nb_days days. """ + # try to get the 'recent' popular websites, created after + # 'not_created_before' + # ie: not_added_before = date_last_added_feed - nb_days nb_days = int(request.args.get('nb_days', 1000)) 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 + date_last_added_feed = last_added_feed.all()[0].created_date else: - last_added_feed_date = datetime.now() - not_before = last_added_feed_date - timedelta(days=nb_days) - filters = {} - filters['created_date__gt'] = not_before + date_last_added_feed = datetime.now() + not_added_before = date_last_added_feed - timedelta(days=nb_days) + filters = {} + filters['created_date__gt'] = not_added_before feeds = FeedController().count_by_link(**filters) sorted_feeds = sorted(feeds.items(), key=operator.itemgetter(1), reverse=True) - return render_template('popular.html', popular=sorted_feeds[:100]) + return render_template('popular.html', popular=sorted_feeds) @current_app.route('/about', methods=['GET']) |