summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2017-04-07 16:24:28 +0300
committerLars Wirzenius <liw@liw.fi>2017-04-07 16:24:28 +0300
commit9080acedf2281a37db8d1b70947836c4b5f54d05 (patch)
tree4335fda4ae518db17ef650d5d40a5cbf94d90680
parentfc4ae5c79a1fa7a281bcef9d30d545d52d530fab (diff)
downloaddistix-9080acedf2281a37db8d1b70947836c4b5f54d05.tar.gz
refactor: Split long method into two
-rw-r--r--distixlib/plugins/import_mail_plugin.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/distixlib/plugins/import_mail_plugin.py b/distixlib/plugins/import_mail_plugin.py
index dc13da8..6fc131b 100644
--- a/distixlib/plugins/import_mail_plugin.py
+++ b/distixlib/plugins/import_mail_plugin.py
@@ -172,20 +172,21 @@ class ImportMailPlugin(cliapp.Plugin):
msg_ids = distixlib.get_ids_from_message(msg)
for ticket_id in context.all_ticket_ids:
- if ticket_id in context.cache:
- other_ids = contex.cache.get_msg_ids_for_ticket_id(ticket_id)
- else:
- filenames = context.store.get_message_filenames(ticket_id)
- for filename in filenames:
- other_msg = self._read_mail_message(filename)
- other_ids = distixlib.get_ids_from_message(other_msg)
- context.cache.add_msg_ids_for_ticket_id(
- ticket_id, other_ids)
+ other_ids = self._get_ticket_message_ids(context, ticket_id)
if other_ids.intersection(msg_ids):
ticket_ids.append(ticket_id)
return ticket_ids
+ def _get_ticket_message_ids(self, context, ticket_id):
+ if ticket_id not in context.cache:
+ filenames = context.store.get_message_filenames(ticket_id)
+ for filename in filenames:
+ msg = self._read_mail_message(filename)
+ msg_ids = distixlib.get_ids_from_message(msg)
+ context.cache.add_msg_ids_for_ticket_id(ticket_id, msg_ids)
+ return context.cache.get_msg_ids_for_ticket_id(ticket_id)
+
def _create_ticket_from_msg(self, repo, msg):
ticket_id = repo.invent_new_ticket_id()
subject = self._get_header(msg, 'Subject')