summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuda Dornelles <ddornell@thoughtworks.com>2014-10-10 17:49:02 +0200
committerDuda Dornelles <ddornell@thoughtworks.com>2014-10-10 17:49:02 +0200
commitad25adcd9311cb09421cec27d4f5a6e68b854ad7 (patch)
treebee0108de5c916acf91f0e3807c2606e83d28d3a
parent29aafc91d741ca0854994535763fb19bfb196085 (diff)
Sorting mails by date - again
-rw-r--r--service/pixelated/adapter/pixelated_mail.py3
-rw-r--r--service/pixelated/user_agent.py3
2 files changed, 6 insertions, 0 deletions
diff --git a/service/pixelated/adapter/pixelated_mail.py b/service/pixelated/adapter/pixelated_mail.py
index 95f417d2..4b207059 100644
--- a/service/pixelated/adapter/pixelated_mail.py
+++ b/service/pixelated/adapter/pixelated_mail.py
@@ -242,6 +242,9 @@ class PixelatedMail:
def get_bcc(self):
return self.headers['Bcc']
+ def get_date(self):
+ return self.headers['Date']
+
def remove_all_tags(self):
self.update_tags(set([]))
diff --git a/service/pixelated/user_agent.py b/service/pixelated/user_agent.py
index 1bab0281..d97d5905 100644
--- a/service/pixelated/user_agent.py
+++ b/service/pixelated/user_agent.py
@@ -37,6 +37,7 @@ from pixelated.adapter.soledad_querier import SoledadQuerier
from pixelated.adapter.search import SearchEngine
from pixelated.adapter.tag_service import TagService
from pixelated.adapter.draft_service import DraftService
+import dateutil.parser as dateparser
static_folder = os.path.abspath(os.path.join(os.path.abspath(__file__), "..", "..", "web-ui", "app"))
@@ -97,6 +98,8 @@ def mails():
mail_ids = search_engine.search(request.args.get('q'))
mails = mail_service.mails(mail_ids)
+ mails = sorted(mails, key=lambda mail: dateparser.parse(mail.get_date()), reverse=True)
+
response = {
"stats": {
"total": len(mails),