aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCédric Bonhomme <kimble.mandel@gmail.com>2013-07-04 07:55:51 +0200
committerCédric Bonhomme <kimble.mandel@gmail.com>2013-07-04 07:55:51 +0200
commite1f35f2d703cba96a7642de36686622a8d06201f (patch)
treee48ab2a53f29a20d72ee20a6a4adc77de9feb354 /source
parentRemoved MongoDB full-search function. (diff)
downloadnewspipe-e1f35f2d703cba96a7642de36686622a8d06201f.tar.gz
newspipe-e1f35f2d703cba96a7642de36686622a8d06201f.tar.bz2
newspipe-e1f35f2d703cba96a7642de36686622a8d06201f.zip
Results of a search are now sorted by date.
Diffstat (limited to 'source')
-rwxr-xr-xsource/pyAggr3g470r.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/source/pyAggr3g470r.py b/source/pyAggr3g470r.py
index 99658213..6543c63c 100755
--- a/source/pyAggr3g470r.py
+++ b/source/pyAggr3g470r.py
@@ -47,6 +47,7 @@ import re
import time
import datetime
+from operator import attrgetter
from collections import defaultdict
from whoosh.index import EmptyIndexError
@@ -178,8 +179,10 @@ class pyAggr3g470r(object):
for result in results:
article = self.mongo.get_articles(result[0], result[1])
search_result[result[0]].append(article)
+ sorted_search_result = {feed_id: sorted(articles, key=lambda t: t['article_date'], reverse=True) \
+ for feed_id, articles in search_result.items()}
tmpl = lookup.get_template("search.html")
- return tmpl.render(search_result=search_result, query=query, feed_id=feed_id, mongo=self.mongo)
+ return tmpl.render(search_result=sorted_search_result, query=query, feed_id=feed_id, mongo=self.mongo)
search.exposed = True
bgstack15