Merge pull request #107 from SDSRV-IDP/minor_fix

fix minor bug
This commit is contained in:
Phan Thành Trung 2024-04-04 15:20:29 +07:00 committed by GitHub Enterprise
commit 131c63454a

View File

@ -536,6 +536,10 @@ def first_of_list(the_list):
return the_list[0] return the_list[0]
def _feedback_invoice_no_exist(feedback_result): 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) invoice_no = feedback_result.get("invoice_no", None)
if invoice_no in ["", [], None]: if invoice_no in ["", [], None]:
return False return False
@ -700,8 +704,7 @@ def calculate_accuracy(key_name: str, inference: Dict[str, Union[str, List]], ta
_inference = inference[key_name] _inference = inference[key_name]
_target = target[key_name] _target = target[key_name]
_will_acc_be_ignored = _acc_will_be_ignored(key_name, _target, type) _will_acc_be_ignored = _acc_will_be_ignored(key_name, _target, type)
_inference = _accuracy_calculate_formatter(_inference) _inference, _target = _accuracy_calculate_formatter(_inference, _target)
_target = _accuracy_calculate_formatter(_target)
for i, v in enumerate(_inference): for i, v in enumerate(_inference):
# TODO: target[i] is None, "" # 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] 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"]) 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"] = {} att["acc"]["reviewed"] = {}
reviewed_result = {} reviewed_result = {}
reason = None reason = None
counter_measure = None counter_measure = None
else: else:
if att["is_reviewed"] == 1: reviewed_result = image.reviewed_result
reviewed_result = image.reviewed_result reason = image.reason
reason = image.reason counter_measure = image.counter_measures
counter_measure = image.counter_measures
new_report_file = ReportFile(report=report, new_report_file = ReportFile(report=report,
subsidiary=_sub, subsidiary=_sub,
@ -935,7 +937,7 @@ def calculate_a_request(report, request):
except Exception as e: except Exception as e:
print(f"[ERROR]: failed to calculate request: {request.request_id} - request_file: {image.file_name} because of {e}") print(f"[ERROR]: failed to calculate request: {request.request_id} - request_file: {image.file_name} because of {e}")
continue continue
return request_att, report_files return request_att, report_files
def calculate_subcription_file(subcription_request_file): def calculate_subcription_file(subcription_request_file):