diff options
author | Victor Shyba <victor.shyba@gmail.com> | 2014-08-11 17:23:31 -0300 |
---|---|---|
committer | Victor Shyba <victor.shyba@gmail.com> | 2014-08-11 17:23:31 -0300 |
commit | 690975d4bcc80a14cf85649cb8db163424b93cf2 (patch) | |
tree | b9a621ffed379f01b9d263673bbe5ab4ba6651dc /service/app | |
parent | 0d2f72acbf0541cb01b0d4321278539ff1120802 (diff) |
sorting mails by date
Diffstat (limited to 'service/app')
-rw-r--r-- | service/app/pixelated_user_agent.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/service/app/pixelated_user_agent.py b/service/app/pixelated_user_agent.py index eed47554..4286bb34 100644 --- a/service/app/pixelated_user_agent.py +++ b/service/app/pixelated_user_agent.py @@ -1,12 +1,13 @@ import json import datetime -import requests +import dateutil.parser as dateparser from flask import Flask, request, Response import app.search_query as search_query from app.adapter.mail_service import MailService from app.adapter.mail_converter import MailConverter + app = Flask(__name__, static_url_path='', static_folder='../../web-ui/app') mail_service = MailService() @@ -15,7 +16,7 @@ account = None def from_iso8061_to_date(iso8061): - return datetime.datetime.strptime(iso8061, "%Y-%m-%dT%H:%M:%S") + return datetime.datetime.strptime(iso8061, "%Y-%m-%dT%H:%M:%S%z") def respond_json(entity): @@ -60,7 +61,7 @@ def mails(): if "inbox" in query['tags']: mails = [mail for mail in mails if (lambda mail: "trash" not in mail['tags'])(mail)] - # mails = sorted(mails, key=lambda mail: mail['header']['date'], reverse=True) + mails = sorted(mails, key=lambda mail: dateparser.parse(mail['header']['date']), reverse=True) response = { "stats": { |