diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 8864f245..cfc223e8 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,7 @@ Version History v5.14.9 ------- +* Remove JIRA fields ids mapping ``_ * Bump urllib3 from 1.26.17 to 1.26.18 in /manager ``_ v5.14.8 diff --git a/manager/api/tests/test_jira.py b/manager/api/tests/test_jira.py index 0b4d5199..9838b09a 100644 --- a/manager/api/tests/test_jira.py +++ b/manager/api/tests/test_jira.py @@ -99,22 +99,39 @@ def setUp(self): request_narrative = { "components": ",".join( - OLE_JIRA_OBS_COMPONENTS_FIELDS[ - : math.ceil(random.random() * len(OLE_JIRA_OBS_COMPONENTS_FIELDS)) + list( + OLE_JIRA_OBS_COMPONENTS_FIELDS[ + : math.ceil( + random.random() * (len(OLE_JIRA_OBS_COMPONENTS_FIELDS) - 1) + ) + ] + ) + ), + "components_ids": ",".join( + [str(n) for n in range(1, math.ceil(random.random() * 100))] + ), + "primary_software_components": ",".join( + OLE_JIRA_OBS_PRIMARY_SOFTWARE_COMPONENT_FIELDS[ + math.ceil( + random.random() + * (len(OLE_JIRA_OBS_PRIMARY_SOFTWARE_COMPONENT_FIELDS) - 1) + ) ] ), - "primary_software_components": OLE_JIRA_OBS_PRIMARY_SOFTWARE_COMPONENT_FIELDS[ - math.ceil( - random.random() - * len(OLE_JIRA_OBS_PRIMARY_SOFTWARE_COMPONENT_FIELDS) - ) - ], - "primary_hardware_components": OLE_JIRA_OBS_PRIMARY_HARDWARE_COMPONENT_FIELDS[ - math.ceil( - random.random() - * len(OLE_JIRA_OBS_PRIMARY_HARDWARE_COMPONENT_FIELDS) - ) - ], + "primary_software_components_ids": ",".join( + [str(math.ceil(random.random() * 100))] + ), + "primary_hardware_components": ",".join( + OLE_JIRA_OBS_PRIMARY_HARDWARE_COMPONENT_FIELDS[ + math.ceil( + random.random() + * (len(OLE_JIRA_OBS_PRIMARY_HARDWARE_COMPONENT_FIELDS) - 1) + ) + ] + ), + "primary_hardware_components_ids": ",".join( + [str(math.ceil(random.random() * 100))] + ), "date_begin": "2022-07-03T19:58:13.00000", "date_end": "2022-07-04T19:25:13.00000", "time_lost": 10, diff --git a/manager/manager/utils.py b/manager/manager/utils.py index 2066fc93..a48b4033 100644 --- a/manager/manager/utils.py +++ b/manager/manager/utils.py @@ -395,6 +395,7 @@ def jira_ticket(request_data): return Response({"ack": "Error reading request type"}, status=400) tags_data = request_data.get("tags").split(",") if request_data.get("tags") else [] + components_ids = ( request_data.get("components_ids").split(",") if request_data.get("components_ids") @@ -403,17 +404,18 @@ def jira_ticket(request_data): primary_software_components_ids = ( request_data.get("primary_software_components_ids").split(",") if request_data.get("primary_software_components_ids") - else [] + else None ) primary_hardware_components_ids = ( request_data.get("primary_hardware_components_ids").split(",") if request_data.get("primary_hardware_components_ids") - else [] + else None ) try: jira_payload = { "fields": { + "issuetype": {"id": 12302}, "project": {"id": os.environ.get("JIRA_PROJECT_ID")}, "labels": [ "LOVE", @@ -425,9 +427,17 @@ def jira_ticket(request_data): if int(request_data.get("level", 0)) >= 100 else "off", "customfield_16702": float(request_data.get("time_lost", 0)), - "customfield_17204": {"id": str(primary_software_components_ids[0])}, - "customfield_17205": {"id": str(primary_hardware_components_ids[0])}, - "issuetype": {"id": 12302}, + # Default values of the following fields are set to -1 + "customfield_17204": { + "id": str(primary_software_components_ids[0]) + if primary_software_components_ids + else "-1" + }, + "customfield_17205": { + "id": str(primary_hardware_components_ids[0]) + if primary_hardware_components_ids + else "-1" + }, }, "update": { "components": [{"set": [{"id": str(id)} for id in components_ids]}]