From 4cd6e3968011768ba5b1b483b4245ce6cc8ce201 Mon Sep 17 00:00:00 2001 From: Jordan Prescott Date: Fri, 17 May 2024 14:35:40 +0100 Subject: [PATCH] big fix when numbers are not assigned --- odins_spear/reports/call_flow.py | 13 +++++++------ odins_spear/reports/report_utils/helpers.py | 21 ++++++++++++--------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/odins_spear/reports/call_flow.py b/odins_spear/reports/call_flow.py index d82978e..738a32c 100644 --- a/odins_spear/reports/call_flow.py +++ b/odins_spear/reports/call_flow.py @@ -82,16 +82,17 @@ def main(api, service_provider_id: str, group_id: str, number: str, number_type: try: stranded_calls_settings = api.get.group_call_center_stranded_calls(call_center.service_user_id) - call_center.stranded_call_unavailable_action = stranded_calls_settings["action"] - call_center.stranded_call_unavailable_transfer_to_phone_number = stranded_calls_settings["transferPhoneNumber"] \ - if call_center.stranded_call_unavailable_action == "Transfer" else None + call_center.stranded_calls_action = stranded_calls_settings["action"] + call_center.stranded_calls_transfer_to_phone_number = stranded_calls_settings["transferPhoneNumber"] \ + if call_center.stranded_calls_action == "Transfer" else None except Exception: - call_center.stranded_call_unavailable_action = None - call_center.stranded_call_unavailable_transfer_to_phone_number = None + call_center.stranded_calls_action = None + call_center.stranded_calls_transfer_to_phone_number = None try: stranded_calls_unavailable_settings = api.get.group_call_center_stranded_calls_unavailable(call_center.service_user_id) - call_center.stranded_call_unavailable_action = stranded_calls_unavailable_settings["action"] + action_value = stranded_calls_unavailable_settings["action"] + call_center.stranded_call_unavailable_action = None if action_value == 'None' else action_value call_center.stranded_call_unavailable_transfer_to_phone_number = stranded_calls_unavailable_settings["transferPhoneNumber"] \ if call_center.stranded_call_unavailable_action == "Transfer" else None except Exception: diff --git a/odins_spear/reports/report_utils/helpers.py b/odins_spear/reports/report_utils/helpers.py index 0787a19..da6c687 100644 --- a/odins_spear/reports/report_utils/helpers.py +++ b/odins_spear/reports/report_utils/helpers.py @@ -15,13 +15,16 @@ def find_entity_with_number_type(number: str, number_type: str, broadwork_entiti """ for entity in broadwork_entities: - if number_type == 'dn' and number in entity.phone_number: - return entity - elif number_type == 'extension' and number in entity.extension: - return entity - elif number_type == 'alias': - for alias in entity.aliases: - if re.search(rf'\b{re.escape(alias)}\b', number): - return entity - + try: + if number_type == 'dn' and number in entity.phone_number: + return entity + elif number_type == 'extension' and number in entity.extension: + return entity + elif number_type == 'alias': + for alias in entity.aliases: + if re.search(rf'\b{re.escape(alias)}\b', number): + return entity + except TypeError: + # issue when entity does not have a number, extenion, or alias assigned + continue return None \ No newline at end of file