aboutsummaryrefslogtreecommitdiff
path: root/src/web/views
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2016-09-20 18:05:33 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2016-09-20 18:05:33 +0200
commit0b82405c091aad39ade4a57978e7997b7f9d5dd3 (patch)
treec34920bd6eab63e0779777d7e4e54223dff5cf46 /src/web/views
parentsimple test of a 'popular' page. (diff)
downloadnewspipe-0b82405c091aad39ade4a57978e7997b7f9d5dd3.tar.gz
newspipe-0b82405c091aad39ade4a57978e7997b7f9d5dd3.tar.bz2
newspipe-0b82405c091aad39ade4a57978e7997b7f9d5dd3.zip
Improved the way we count feeds by link.
Diffstat (limited to 'src/web/views')
-rw-r--r--src/web/views/views.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/web/views/views.py b/src/web/views/views.py
index c3425a17..ceb1ab10 100644
--- a/src/web/views/views.py
+++ b/src/web/views/views.py
@@ -1,5 +1,5 @@
import logging
-from collections import Counter
+import operator
from flask import (request, render_template, flash,
url_for, redirect, current_app)
from flask_babel import gettext
@@ -45,12 +45,10 @@ def handle_sqlalchemy_assertion_error(error):
@current_app.route('/popular', methods=['GET'])
@etag_match
def popular():
- feeds = FeedController().read().all()
- counter = Counter()
- for feed in feeds:
- counter[feed.link] += 1
- print(counter.most_common(50))
- return render_template('popular.html', popular=counter.most_common(50))
+ feeds = FeedController().count_by_link()
+ sorted_feeds = sorted(feeds.items(), key=operator.itemgetter(1),
+ reverse=True)
+ return render_template('popular.html', popular=sorted_feeds)
@current_app.route('/about', methods=['GET'])
bgstack15