From 13eb7ea06c1a6edc93cf26310e931abc4504e632 Mon Sep 17 00:00:00 2001 From: PhanThanhTrung Date: Thu, 7 Mar 2024 13:42:10 +0700 Subject: [PATCH] return None to acc and speed --- cope2n-api/fwd_api/api/accuracy_view.py | 5 ++++- .../celery_worker/process_report_tasks.py | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/cope2n-api/fwd_api/api/accuracy_view.py b/cope2n-api/fwd_api/api/accuracy_view.py index c947a57..fc60961 100755 --- a/cope2n-api/fwd_api/api/accuracy_view.py +++ b/cope2n-api/fwd_api/api/accuracy_view.py @@ -413,7 +413,10 @@ class AccuracyViewSet(viewsets.ViewSet): for key in acc_keys: fb = report.feedback_accuracy.get(key, 0) if report.feedback_accuracy else 0 rv = report.reviewed_accuracy.get(key, 0) if report.reviewed_accuracy else 0 - acc[key] = report.combined_accuracy.get(key, 0) if report.combined_accuracy else max([fb, rv]) + if report.report_type not in ["BILLING", "billing"]: + acc[key] = report.combined_accuracy.get(key, 0) if report.combined_accuracy else max([fb, rv]) + else: + acc[key] = None data.append({ "ID": report.id, "Created Date": report.created_at, 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 45f7b84..e450a25 100755 --- a/cope2n-api/fwd_api/celery_worker/process_report_tasks.py +++ b/cope2n-api/fwd_api/celery_worker/process_report_tasks.py @@ -353,6 +353,22 @@ def create_billing_report(report_id, **kwargs): billing_data = create_billing_data(subscription_requests) report.number_request = len(subscription_requests) report.number_images = len(billing_data) + + acumulated_acc = {"feedback": {}, + "reviewed": {}, + "acumulated": {}} + for acc_type in ["feedback", "reviewed", "acumulated"]: + for key in ["imei_number", "purchase_date", "retailername", "sold_to_party"]: + acumulated_acc[acc_type][key] = None + acumulated_acc[acc_type][key + "_count"] = None + acumulated_acc[acc_type]["avg"] = None + + report.feedback_accuracy = acumulated_acc["feedback"] + report.reviewed_accuracy = acumulated_acc["reviewed"] + report.combined_accuracy = acumulated_acc["acumulated"] + + report.average_OCR_time = {"invoice": None, "imei": None, + "invoice_count": None, "imei_count": None, "avg": None} report.status = "Ready" report.save() data_workbook = dict2xlsx(billing_data, _type='billing_report')