refactor this code complexity from 32 to 15 allowed, you can use functions to split the…
- User
refactor this code complexity from 32 to 15 allowed, you can use functions to split the problem
def get_specific_response(event_data: object, need_auto: bool, need_manual: bool): status_onboarding = event_data.get('onboardingStatus') # on boarding new_validity = event_data.get('new_validity') # new validity check_status = event_data.get('check_status') or event_data.get('event_status') # update check event = None idnow_status = None mef = { "final_event": False, "status": True, "sub_status": { "http": 200 }, } if status_onboarding: idnow_status = status_onboarding if idnow_status == 'SUCCESS': if not need_auto and not need_manual: mef["final_event"] = True event = 'FILE_CREATED' elif idnow_status == 'CLICKED': event = 'CLICKED' elif idnow_status == 'ERROR': error_cause = event_data.get('errorCause', {}) error_code = error_cause.get('code') if error_code == 'USER_ERROR': mef["sub_status"]["code"] = 'M00127DNIED' mef["sub_status"]["msg"] = error_cause.get('message') else: mef["sub_status"]["code"] = 'T00127NORES' mef["sub_status"]["msg"] = 'Internal error when creating the documents' mef["status"] = False if not need_manual: mef["final_event"] = True event = 'ERROR' elif new_validity: idnow_status = new_validity mef["final_event"] = True if idnow_status == 'VALID': event = 'MANUAL_CHECK_OK' elif idnow_status == 'INVALID': mef["status"] = False event = 'MANUAL_CHECK_KO' elif check_status: idnow_status = check_status if idnow_status == 'OK': event = 'AUTO_CHECK_OK' if not need_manual: mef["final_event"] = True elif idnow_status == 'WARNING': event = 'AUTO_CHECK_WARNING' elif idnow_status == 'ERROR': if not need_manual: mef["final_event"] = True mef["status"] = False event = 'AUTO_CHECK_KO' return { "idnow_status": idnow_status, "event": event, "mef": mef, }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.