From 7cb21817ed06d7b46a06b3f2d43c45ca2bdc2396 Mon Sep 17 00:00:00 2001 From: dx-tan Date: Thu, 4 Apr 2024 15:18:22 +0700 Subject: [PATCH] fix minor bug --- cope2n-api/fwd_api/utils/accuracy.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/cope2n-api/fwd_api/utils/accuracy.py b/cope2n-api/fwd_api/utils/accuracy.py index 55b32b3..ce19ebd 100755 --- a/cope2n-api/fwd_api/utils/accuracy.py +++ b/cope2n-api/fwd_api/utils/accuracy.py @@ -536,6 +536,10 @@ def first_of_list(the_list): return the_list[0] def _feedback_invoice_no_exist(feedback_result): + if feedback_result is None: + return True + if not isinstance(feedback_result, dict): + return True invoice_no = feedback_result.get("invoice_no", None) if invoice_no in ["", [], None]: return False @@ -700,8 +704,7 @@ def calculate_accuracy(key_name: str, inference: Dict[str, Union[str, List]], ta _inference = inference[key_name] _target = target[key_name] _will_acc_be_ignored = _acc_will_be_ignored(key_name, _target, type) - _inference = _accuracy_calculate_formatter(_inference) - _target = _accuracy_calculate_formatter(_target) + _inference, _target = _accuracy_calculate_formatter(_inference, _target) for i, v in enumerate(_inference): # TODO: target[i] is None, "" @@ -860,16 +863,15 @@ def calculate_a_request(report, request): image.reviewed_result["purchase_date"] = att["normalized_data"]["reviewed"]["purchase_date"][rv_max_indexes["purchase_date"]][1] request_att["is_reviewed"].append(att["is_reviewed"]) - if att["is_reviewed"] == -1: # -1 means "not required" + if att["is_reviewed"] !=1: att["acc"]["reviewed"] = {} reviewed_result = {} reason = None counter_measure = None else: - if att["is_reviewed"] == 1: - reviewed_result = image.reviewed_result - reason = image.reason - counter_measure = image.counter_measures + reviewed_result = image.reviewed_result + reason = image.reason + counter_measure = image.counter_measures new_report_file = ReportFile(report=report, subsidiary=_sub, @@ -935,7 +937,7 @@ def calculate_a_request(report, request): except Exception as e: print(f"[ERROR]: failed to calculate request: {request.request_id} - request_file: {image.file_name} because of {e}") continue - + return request_att, report_files def calculate_subcription_file(subcription_request_file):