Skip to content

Commit

Permalink
Only log duplicate email & group message when we're not in refresh mode
Browse files Browse the repository at this point in the history
when we're refreshing email addresses and groups, almost all email 
addresses we find will be duplicates.

This change surpresses the warning in refresh mode to work around this.
  • Loading branch information
thinkl33t committed Dec 6, 2023
1 parent e0e655b commit 6df3ad3
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions lifecycle/target_suitecrm.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,16 @@ def _fetch_all_emails(self, refresh=False):
address = ent["attributes"]["email_address"]
_id = ent["id"]
if address in self._emails_to_id:
logging.warning(
(
"Duplicate E-mail address entries found in suitecrm server:"
"Address '%s' has IDs '%s' and '%s'. Using the first one only."
),
address,
self._emails_to_id[address],
_id,
)
if not refresh:
logging.warning(
(
"Duplicate E-mail address entries found in suitecrm server:"
"Address '%s' has IDs '%s' and '%s'. Using the first one only."
),
address,
self._emails_to_id[address],
_id,
)
else:
self._emails_to_id[address] = _id
return self._emails_to_id
Expand All @@ -279,15 +280,16 @@ def _fetch_all_groups(self, refresh=False):
groupname = ent["attributes"]["name"]
_id = ent["id"]
if groupname in self._groups_to_id:
logging.warning(
(
"Duplicate Group entries found in suitecrm server:"
"Group '%s' has IDs '%s' and '%s'. Using the first one only."
),
groupname,
self._groups_to_id[groupname],
_id,
)
if not refresh:
logging.warning(
(
"Duplicate Group entries found in suitecrm server:"
"Group '%s' has IDs '%s' and '%s'. Using the first one only."
),
groupname,
self._groups_to_id[groupname],
_id,
)
else:
self._groups_to_id[groupname] = _id
self._groups_to_attributes[groupname] = ent["attributes"]
Expand Down

0 comments on commit 6df3ad3

Please sign in to comment.