summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2017-03-25 13:21:46 +0200
committerLars Wirzenius <liw@liw.fi>2017-03-25 14:33:00 +0200
commitca1b29cfdde31f20677d30a72fbf880e29fef396 (patch)
tree49b68a95131935aea2055e6ffcaafc79b0eb92ad
parent22b4825f3fc5653f5d1064df86d05582c37e85ac (diff)
downloaddistix-ca1b29cfdde31f20677d30a72fbf880e29fef396.tar.gz
Refacctor: Make _find_tickets... reaturn ticket ids
-rw-r--r--distixlib/plugins/import_mail_plugin.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/distixlib/plugins/import_mail_plugin.py b/distixlib/plugins/import_mail_plugin.py
index 2bf9586..d9dd3d5 100644
--- a/distixlib/plugins/import_mail_plugin.py
+++ b/distixlib/plugins/import_mail_plugin.py
@@ -90,15 +90,15 @@ class ImportMailPlugin(cliapp.Plugin):
def _import_msg_to_ticket_store(
self, repo, ticket_store, all_ticket_ids, msg, cache, key, value):
- referenced_tickets = self._find_tickets_with_mails_referenced_by_msg(
+ referenced_ids = self._find_tickets_with_mails_referenced_by_msg(
ticket_store, all_ticket_ids, msg, cache)
msg_ids = self._get_message_ids(msg)
filenames = []
- if referenced_tickets:
- for ticket in referenced_tickets:
- if not self._contains_message(
- ticket_store, ticket.get_ticket_id(), msg):
+ if referenced_ids:
+ for ticket_id in referenced_ids:
+ if not self._contains_message(ticket_store, ticket_id, msg):
+ ticket = ticket_store.get_ticket(ticket_id)
ticket.add_message(msg)
self._set_key_value(ticket, key, value)
cache.add_msg_ids_for_ticket_id(
@@ -137,7 +137,7 @@ class ImportMailPlugin(cliapp.Plugin):
def _find_tickets_with_mails_referenced_by_msg(
self, store, all_ticket_ids, msg, cache):
- tickets = []
+ ticket_ids = []
msg_ids = self._get_message_ids(msg)
for ticket_id in all_ticket_ids:
@@ -151,10 +151,9 @@ class ImportMailPlugin(cliapp.Plugin):
other_ids = self._get_message_ids(other_msg)
cache.add_msg_ids_for_ticket_id(ticket_id, other_ids)
if other_ids.intersection(msg_ids):
- ticket = store.get_ticket(ticket_id)
- tickets.append(ticket)
+ ticket_ids.append(ticket_id)
- return tickets
+ return ticket_ids
def _get_message_ids(self, msg):
header_names = ('Message-Id', 'In-Reply-To', 'References')