diff --git a/inventory_provider/db/ims_data.py b/inventory_provider/db/ims_data.py index b5728bfa60eccc9041af41bdcdac1133e41d149c..3f60614d7636a4f33f8ce0667a2e2cdd4d345ea4 100644 --- a/inventory_provider/db/ims_data.py +++ b/inventory_provider/db/ims_data.py @@ -222,10 +222,14 @@ def otrs_get_customer_users_rows(ds): 'city', 'country', 'comments'] def get_all_cus_user_rows(): - yield from otrs_get_customer_contacts(ds) - yield from otrs_get_vendor_contacts(ds) + yielded_customer_emails = set() + for c in otrs_get_customer_contacts(ds): + yielded_customer_emails.add(c['email']) + yield c + for c in otrs_get_vendor_contacts(ds): + if c['email'] not in yielded_customer_emails: + yield c sorted_cus = sorted(get_all_cus_user_rows(), key=lambda x: x['email']) - # this will be used to prioritisation for cu in sorted_cus: yield list(cu.values())