diff --git a/cope2n-api/fwd_api/celery_worker/process_report_tasks.py b/cope2n-api/fwd_api/celery_worker/process_report_tasks.py index 5ffd09b..c738c82 100755 --- a/cope2n-api/fwd_api/celery_worker/process_report_tasks.py +++ b/cope2n-api/fwd_api/celery_worker/process_report_tasks.py @@ -110,7 +110,7 @@ def create_accuracy_report(report_id, **kwargs): if request.status != 200 or not (request.reviewed_result or request.feedback_result): # Failed requests or lack of reviewed_result/feedback_result continue - request_att, _report_files, _att = calculate_a_request(report, request) + request_att, _report_files, _atts = calculate_a_request(report, request) report_files += _report_files report_engine.add(request, _report_files, report) request.feedback_accuracy = {"imei_number": mean_list(request_att["acc"]["feedback"].get("imei_number", [None])), @@ -125,10 +125,11 @@ def create_accuracy_report(report_id, **kwargs): "invoice_no": mean_list(request_att["acc"]["reviewed"].get("invoice_no", [None]))} rq_accuracy = {"feedback": [], "reviewed": []} - - for t in _att["acc"].keys(): - for cl in _att["acc"][t].keys(): - rq_accuracy[t] += _att["acc"][t][cl] + + for _att in _atts: + for t in _att["acc"].keys(): + for cl in _att["acc"][t].keys(): + rq_accuracy[t] += _att["acc"][t][cl] # for rpf in _report_files: # for cl in rpf.feedback_accuracy.keys(): diff --git a/cope2n-api/fwd_api/utils/accuracy.py b/cope2n-api/fwd_api/utils/accuracy.py index 5d7383f..1d5e938 100755 --- a/cope2n-api/fwd_api/utils/accuracy.py +++ b/cope2n-api/fwd_api/utils/accuracy.py @@ -797,7 +797,7 @@ def calculate_a_request(report, request): 0: "No", 1: "Yes"} return review_status.get(input, "N/A") - + atts = [] request_att = {"acc": {"feedback": {"imei_number": [], "purchase_date": [], "retailername": [], @@ -829,6 +829,7 @@ def calculate_a_request(report, request): for image in images: status, att = calculate_subcription_file(image) + atts.append(att) att["acc"]["feedback"], fb_max_indexes = acc_maximize_list_values(att["acc"]["feedback"]) att["acc"]["reviewed"], rv_max_indexes = acc_maximize_list_values(att["acc"]["reviewed"]) @@ -945,7 +946,7 @@ def calculate_a_request(report, request): print(f"[ERROR]: failed to calculate request: {request.request_id} - request_file: {image.file_name} because of {e}") continue - return request_att, report_files, att + return request_att, report_files, atts def calculate_subcription_file(subcription_request_file): att = {"acc": {"feedback": {},