aboutsummaryrefslogtreecommitdiff
path: root/src/web/views
diff options
context:
space:
mode:
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