diff options
author | Victor Shyba <victor.shyba@gmail.com> | 2015-08-30 17:53:17 -0300 |
---|---|---|
committer | Victor Shyba <victor.shyba@gmail.com> | 2015-08-30 17:53:17 -0300 |
commit | 97b50f5b886928c70edcbcea149ced10f7065f19 (patch) | |
tree | 320b7e75096a5b52c0fe672920cf66a1fff08459 | |
parent | 386398020f172be82bf27dd03c509e91c7e2a6d8 (diff) |
[refactor] Move search mails into searchable_mailstore
This is needed in order to be able to remove search engine from
mail_service. As #430
-rw-r--r-- | service/pixelated/adapter/mailstore/searchable_mailstore.py | 12 | ||||
-rw-r--r-- | service/pixelated/adapter/services/mail_service.py | 11 |
2 files changed, 14 insertions, 9 deletions
diff --git a/service/pixelated/adapter/mailstore/searchable_mailstore.py b/service/pixelated/adapter/mailstore/searchable_mailstore.py index 0c5310eb..d53f13d7 100644 --- a/service/pixelated/adapter/mailstore/searchable_mailstore.py +++ b/service/pixelated/adapter/mailstore/searchable_mailstore.py @@ -32,6 +32,18 @@ class SearchableMailStore(object): # implementes MailStore setattr(cls, method_name, delegator) @defer.inlineCallbacks + def search_mails(self, query, window_size, page): + mail_ids, total = self._search_engine.search(query, window_size, page) + + try: + mails = yield self.get_mails(mail_ids) + defer.returnValue((mails, total)) + except Exception, e: + import traceback + traceback.print_exc() + raise + + @defer.inlineCallbacks def add_mail(self, mailbox_name, mail): stored_mail = yield self._delegate.add_mail(mailbox_name, mail) self._search_engine.index_mail(stored_mail) diff --git a/service/pixelated/adapter/services/mail_service.py b/service/pixelated/adapter/services/mail_service.py index a96b85f0..4ff42046 100644 --- a/service/pixelated/adapter/services/mail_service.py +++ b/service/pixelated/adapter/services/mail_service.py @@ -34,15 +34,8 @@ class MailService(object): @defer.inlineCallbacks def mails(self, query, window_size, page): - mail_ids, total = self.search_engine.search(query, window_size, page) - - try: - mails = yield self.mail_store.get_mails(mail_ids) - defer.returnValue((mails, total)) - except Exception, e: - import traceback - traceback.print_exc() - raise + mails, total = yield self.mail_store.search_mails(query, window_size, page) + defer.returnValue((mails, total)) @defer.inlineCallbacks def update_tags(self, mail_id, new_tags): |