summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorBruno Wagner <bwagner@thoughtworks.com>2014-10-16 17:47:03 +0200
committerBruno Wagner <bwagner@thoughtworks.com>2014-10-16 17:48:56 +0200
commit19f89c970b214d2b131cbc4124b1630b0f330efa (patch)
treea68dce1a6584fde8f272a2ace60e9ec6cf2bdaf3 /service
parenta8f3d31bd41def7a334b5a2f4f260ec77ce76d2c (diff)
Fixed the pagination on the front-end and added real total mail count ot the search result
Diffstat (limited to 'service')
-rw-r--r--service/pixelated/adapter/search.py5
-rw-r--r--service/pixelated/controllers/mails_controller.py4
2 files changed, 5 insertions, 4 deletions
diff --git a/service/pixelated/adapter/search.py b/service/pixelated/adapter/search.py
index a5b31c67..ad5c3bbb 100644
--- a/service/pixelated/adapter/search.py
+++ b/service/pixelated/adapter/search.py
@@ -134,8 +134,9 @@ class SearchEngine(object):
window = int(window)
with self._index.searcher() as searcher:
- results = searcher.search_page(query, page, pagelen=window)
- return [mail['ident'] for mail in results]
+ tags_facet = sorting.FieldFacet('tag', allow_overlap=True, maptype=sorting.Count)
+ results = searcher.search_page(query, page, pagelen=window, groupedby=tags_facet)
+ return [mail['ident'] for mail in results], sum(results.results.groups().values())
def prepare_query(self, query):
query = (
diff --git a/service/pixelated/controllers/mails_controller.py b/service/pixelated/controllers/mails_controller.py
index f6414f27..d1de4973 100644
--- a/service/pixelated/controllers/mails_controller.py
+++ b/service/pixelated/controllers/mails_controller.py
@@ -29,13 +29,13 @@ class MailsController:
self._search_engine = search_engine
def mails(self, _request=request):
- mail_ids = self._search_engine.search(_request.args.get('q'), _request.args.get('w'), _request.args.get('p'))
+ mail_ids, total = self._search_engine.search(_request.args.get('q'), _request.args.get('w'), _request.args.get('p'))
mails = self._mail_service.mails(mail_ids)
mails = sorted(mails, key=lambda mail: dateparser.parse(mail.date), reverse=True)
response = {
"stats": {
- "total": len(mails),
+ "total": total,
"read": 0,
"starred": 0,
"replied": 0