From 462e614340706a614661e5989d191a3894070a04 Mon Sep 17 00:00:00 2001 From: PhanThanhTrung Date: Tue, 19 Mar 2024 16:35:26 +0700 Subject: [PATCH] update average processing time --- cope2n-api/fwd_api/utils/accuracy.py | 15 +++-- cope2n-api/fwd_api/utils/file.py | 5 +- cope2n-api/report.xlsx | Bin 7016 -> 6993 bytes docker-compose-dev.yml | 91 +++++++++++++-------------- 4 files changed, 55 insertions(+), 56 deletions(-) diff --git a/cope2n-api/fwd_api/utils/accuracy.py b/cope2n-api/fwd_api/utils/accuracy.py index 6b31911..6fa60d9 100755 --- a/cope2n-api/fwd_api/utils/accuracy.py +++ b/cope2n-api/fwd_api/utils/accuracy.py @@ -46,7 +46,8 @@ class ReportAccumulateByRequest: }, 'average_processing_time': { 'imei': IterAvg(), - 'invoice': IterAvg() + 'invoice': IterAvg(), + 'avg': IterAvg(), }, 'usage': { 'imei':0, @@ -92,7 +93,8 @@ class ReportAccumulateByRequest: }, 'average_processing_time': { 'imei': IterAvg(), - 'invoice': IterAvg() + 'invoice': IterAvg(), + 'avg': IterAvg(), }, 'usage': { 'imei': 0, @@ -144,7 +146,8 @@ class ReportAccumulateByRequest: if not total["average_processing_time"].get(report_file.doc_type, None): print(f"[WARM]: Weird doctype: {report_file.doc_type}") total["average_processing_time"][report_file.doc_type] = IterAvg() - total["average_processing_time"][report_file.doc_type].add_avg(report_file.time_cost, 1) if report_file.time_cost else 0 + total["average_processing_time"][report_file.doc_type].add_avg(report_file.time_cost, 1) if report_file.time_cost else 0 + total["average_processing_time"]["avg"].add_avg(report_file.time_cost, 1) if report_file.time_cost else 0 doc_type = "imei" if report_file.doc_type in ["imei", "invoice", "all"]: @@ -183,7 +186,8 @@ class ReportAccumulateByRequest: if not day_data["average_processing_time"].get(report_file.doc_type, None): print(f"[WARM]: Weird doctype: {report_file.doc_type}") day_data["average_processing_time"][report_file.doc_type] = IterAvg() - day_data["average_processing_time"][report_file.doc_type].add_avg(report_file.time_cost, 1) if report_file.time_cost else 0 + day_data["average_processing_time"][report_file.doc_type].add_avg(report_file.time_cost, 1) if report_file.time_cost else 0 + day_data["average_processing_time"]['avg'].add_avg(report_file.time_cost, 1) if report_file.time_cost else 0 day_data["review_progress"].append(report_file.review_status) return day_data @@ -248,7 +252,8 @@ class ReportAccumulateByRequest: _average_OCR_time["invoice"] = 0 if _average_OCR_time["invoice"] is None else _average_OCR_time["invoice"] _average_OCR_time["imei"] = 0 if _average_OCR_time["imei"] is None else _average_OCR_time["imei"] - _average_OCR_time["avg"] = (_average_OCR_time["invoice"]*_average_OCR_time["invoice_count"] + _average_OCR_time["imei"]*_average_OCR_time["imei_count"])/(_average_OCR_time["imei_count"] + _average_OCR_time["invoice_count"]) if (_average_OCR_time["imei_count"] + _average_OCR_time["invoice_count"]) > 0 else None + if "avg" not in _average_OCR_time: + _average_OCR_time["avg"] = (_average_OCR_time["invoice"]*_average_OCR_time["invoice_count"] + _average_OCR_time["imei"]*_average_OCR_time["imei_count"])/(_average_OCR_time["imei_count"] + _average_OCR_time["invoice_count"]) if (_average_OCR_time["imei_count"] + _average_OCR_time["invoice_count"]) > 0 else None acumulated_acc = {"feedback_accuracy": {}, "reviewed_accuracy": {}} for acc_type in ["feedback_accuracy", "reviewed_accuracy"]: diff --git a/cope2n-api/fwd_api/utils/file.py b/cope2n-api/fwd_api/utils/file.py index fa2a1cd..c0903cf 100755 --- a/cope2n-api/fwd_api/utils/file.py +++ b/cope2n-api/fwd_api/utils/file.py @@ -495,9 +495,8 @@ def dict2xlsx(input: json, _type='report'): 'N': 'average_accuracy_rate.purchase_date', 'O': 'average_accuracy_rate.retailer_name', 'P': 'average_accuracy_rate.invoice_number', - 'Q': 'average_processing_time.imei', - 'R': 'average_processing_time.invoice', - 'S': 'review_progress' + 'Q': 'average_processing_time.avg', + 'R': 'review_progress' } start_index = 5 diff --git a/cope2n-api/report.xlsx b/cope2n-api/report.xlsx index 92da45f2608946c38042e19ca90cb26f641a4de9..19105099518a444ebdcb8593b921601f2e20e40d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IMAGE_TOKEN_LIFE_TIME} - INTERNAL_SDS_KEY=${INTERNAL_SDS_KEY} - - ADMIN_USER_NAME=${ADMIN_USER_NAME} - - ADMIN_PASSWORD=${ADMIN_PASSWORD} + - ADMIN_USER_NAME=${FI_USER_NAME} + - ADMIN_PASSWORD=${FI_PASSWORD} - STANDARD_USER_NAME=${STANDARD_USER_NAME} - STANDARD_PASSWORD=${STANDARD_PASSWORD} - S3_ENDPOINT=${S3_ENDPOINT} @@ -89,12 +89,7 @@ services: depends_on: db-sbt: condition: service_started - command: sh -c "chmod -R 777 /app; sleep 5; python manage.py collectstatic --no-input && - python manage.py makemigrations && - python manage.py migrate && - python manage.py compilemessages && - gunicorn fwd.asgi:application -k uvicorn.workers.UvicornWorker --timeout 300 -b 0.0.0.0:9000" # pre-makemigrations on prod - # command: bash -c "tail -f > /dev/null" + command: "sleep infinity" minio: image: minio/minio @@ -196,7 +191,7 @@ services: - POSTGRES_PASSWORD=${DB_PASSWORD} - POSTGRES_DB=${DB_SCHEMA} ports: - - 5432:5432 + - 15432:5432 rabbitmq-sbt: mem_reservation: 600m @@ -209,46 +204,46 @@ services: - RABBITMQ_DEFAULT_USER=${RABBITMQ_DEFAULT_USER} - RABBITMQ_DEFAULT_PASS=${RABBITMQ_DEFAULT_PASS} - # Front-end services - fe-sbt: - restart: always - build: - context: cope2n-fe - shm_size: 10gb - dockerfile: Dockerfile - image: sidp/cope2n-fe-fi-sbt:latest - shm_size: 10gb - privileged: true - ports: - - 9881:80 - depends_on: - be-ctel-sbt: - condition: service_started - be-celery-sbt: - condition: service_started - environment: - - VITE_PROXY=http://be-ctel-sbt:${BASE_PORT} - - VITE_API_BASE_URL=http://fe-sbt:80 - volumes: - - BE_static:/backend-static - networks: - - ctel-sbt + # # Front-end services + # fe-sbt: + # restart: always + # build: + # context: cope2n-fe + # shm_size: 10gb + # dockerfile: Dockerfile + # image: sidp/cope2n-fe-fi-sbt:latest + # shm_size: 10gb + # privileged: true + # ports: + # - 9881:80 + # depends_on: + # be-ctel-sbt: + # condition: service_started + # be-celery-sbt: + # condition: service_started + # environment: + # - VITE_PROXY=http://be-ctel-sbt:${BASE_PORT} + # - VITE_API_BASE_URL=http://fe-sbt:80 + # volumes: + # - BE_static:/backend-static + # networks: + # - ctel-sbt - dashboard_refresh: - build: - context: api-cronjob - dockerfile: Dockerfile - image: sidp/api-caller-sbt:latest - environment: - - PROXY=http://be-ctel-sbt:9000 - - ADMIN_USER_NAME=${ADMIN_USER_NAME} - - ADMIN_PASSWORD=${ADMIN_PASSWORD} - depends_on: - be-ctel-sbt: - condition: service_healthy - restart: always - networks: - - ctel-sbt + # dashboard_refresh: + # build: + # context: api-cronjob + # dockerfile: Dockerfile + # image: sidp/api-caller-sbt:latest + # environment: + # - PROXY=http://be-ctel-sbt:9000 + # - ADMIN_USER_NAME=${ADMIN_USER_NAME} + # - ADMIN_PASSWORD=${ADMIN_PASSWORD} + # depends_on: + # be-ctel-sbt: + # condition: service_healthy + # restart: always + # networks: + # - ctel-sbt volumes: db_data: