From e4069708be9948ab632ca748f26059df1f8b82b5 Mon Sep 17 00:00:00 2001 From: Robert Latta <robert.latta@geant.org> Date: Fri, 1 May 2020 09:57:44 +0000 Subject: [PATCH] priorised Customer Contacts over Vendor Contacts --- inventory_provider/db/ims_data.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/inventory_provider/db/ims_data.py b/inventory_provider/db/ims_data.py index b5728bfa..3f60614d 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()) -- GitLab