Merge pull request #93 from SDSRV-IDP/trungpt/minor_fix

update average processing time
This commit is contained in:
Đỗ Xuân Tân 2024-03-19 16:45:31 +07:00 committed by GitHub Enterprise
commit 98b3e3953e
4 changed files with 55 additions and 56 deletions

View File

@ -46,7 +46,8 @@ class ReportAccumulateByRequest:
}, },
'average_processing_time': { 'average_processing_time': {
'imei': IterAvg(), 'imei': IterAvg(),
'invoice': IterAvg() 'invoice': IterAvg(),
'avg': IterAvg(),
}, },
'usage': { 'usage': {
'imei':0, 'imei':0,
@ -92,7 +93,8 @@ class ReportAccumulateByRequest:
}, },
'average_processing_time': { 'average_processing_time': {
'imei': IterAvg(), 'imei': IterAvg(),
'invoice': IterAvg() 'invoice': IterAvg(),
'avg': IterAvg(),
}, },
'usage': { 'usage': {
'imei': 0, 'imei': 0,
@ -145,6 +147,7 @@ class ReportAccumulateByRequest:
print(f"[WARM]: Weird doctype: {report_file.doc_type}") 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] = 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" doc_type = "imei"
if report_file.doc_type in ["imei", "invoice", "all"]: if report_file.doc_type in ["imei", "invoice", "all"]:
@ -184,6 +187,7 @@ class ReportAccumulateByRequest:
print(f"[WARM]: Weird doctype: {report_file.doc_type}") 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] = 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) day_data["review_progress"].append(report_file.review_status)
return day_data return day_data
@ -248,6 +252,7 @@ class ReportAccumulateByRequest:
_average_OCR_time["invoice"] = 0 if _average_OCR_time["invoice"] is None else _average_OCR_time["invoice"] _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["imei"] = 0 if _average_OCR_time["imei"] is None else _average_OCR_time["imei"]
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 _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": {}, acumulated_acc = {"feedback_accuracy": {},
"reviewed_accuracy": {}} "reviewed_accuracy": {}}

View File

@ -495,9 +495,8 @@ def dict2xlsx(input: json, _type='report'):
'N': 'average_accuracy_rate.purchase_date', 'N': 'average_accuracy_rate.purchase_date',
'O': 'average_accuracy_rate.retailer_name', 'O': 'average_accuracy_rate.retailer_name',
'P': 'average_accuracy_rate.invoice_number', 'P': 'average_accuracy_rate.invoice_number',
'Q': 'average_processing_time.imei', 'Q': 'average_processing_time.avg',
'R': 'average_processing_time.invoice', 'R': 'review_progress'
'S': 'review_progress'
} }
start_index = 5 start_index = 5

Binary file not shown.

View File

@ -63,8 +63,8 @@ services:
- AUTH_TOKEN_LIFE_TIME=${AUTH_TOKEN_LIFE_TIME} - AUTH_TOKEN_LIFE_TIME=${AUTH_TOKEN_LIFE_TIME}
- IMAGE_TOKEN_LIFE_TIME=${IMAGE_TOKEN_LIFE_TIME} - IMAGE_TOKEN_LIFE_TIME=${IMAGE_TOKEN_LIFE_TIME}
- INTERNAL_SDS_KEY=${INTERNAL_SDS_KEY} - INTERNAL_SDS_KEY=${INTERNAL_SDS_KEY}
- ADMIN_USER_NAME=${ADMIN_USER_NAME} - ADMIN_USER_NAME=${FI_USER_NAME}
- ADMIN_PASSWORD=${ADMIN_PASSWORD} - ADMIN_PASSWORD=${FI_PASSWORD}
- STANDARD_USER_NAME=${STANDARD_USER_NAME} - STANDARD_USER_NAME=${STANDARD_USER_NAME}
- STANDARD_PASSWORD=${STANDARD_PASSWORD} - STANDARD_PASSWORD=${STANDARD_PASSWORD}
- S3_ENDPOINT=${S3_ENDPOINT} - S3_ENDPOINT=${S3_ENDPOINT}
@ -89,12 +89,7 @@ services:
depends_on: depends_on:
db-sbt: db-sbt:
condition: service_started condition: service_started
command: sh -c "chmod -R 777 /app; sleep 5; python manage.py collectstatic --no-input && command: "sleep infinity"
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"
minio: minio:
image: minio/minio image: minio/minio
@ -196,7 +191,7 @@ services:
- POSTGRES_PASSWORD=${DB_PASSWORD} - POSTGRES_PASSWORD=${DB_PASSWORD}
- POSTGRES_DB=${DB_SCHEMA} - POSTGRES_DB=${DB_SCHEMA}
ports: ports:
- 5432:5432 - 15432:5432
rabbitmq-sbt: rabbitmq-sbt:
mem_reservation: 600m mem_reservation: 600m
@ -209,46 +204,46 @@ services:
- RABBITMQ_DEFAULT_USER=${RABBITMQ_DEFAULT_USER} - RABBITMQ_DEFAULT_USER=${RABBITMQ_DEFAULT_USER}
- RABBITMQ_DEFAULT_PASS=${RABBITMQ_DEFAULT_PASS} - RABBITMQ_DEFAULT_PASS=${RABBITMQ_DEFAULT_PASS}
# Front-end services # # Front-end services
fe-sbt: # fe-sbt:
restart: always # restart: always
build: # build:
context: cope2n-fe # context: cope2n-fe
shm_size: 10gb # shm_size: 10gb
dockerfile: Dockerfile # dockerfile: Dockerfile
image: sidp/cope2n-fe-fi-sbt:latest # image: sidp/cope2n-fe-fi-sbt:latest
shm_size: 10gb # shm_size: 10gb
privileged: true # privileged: true
ports: # ports:
- 9881:80 # - 9881:80
depends_on: # depends_on:
be-ctel-sbt: # be-ctel-sbt:
condition: service_started # condition: service_started
be-celery-sbt: # be-celery-sbt:
condition: service_started # condition: service_started
environment: # environment:
- VITE_PROXY=http://be-ctel-sbt:${BASE_PORT} # - VITE_PROXY=http://be-ctel-sbt:${BASE_PORT}
- VITE_API_BASE_URL=http://fe-sbt:80 # - VITE_API_BASE_URL=http://fe-sbt:80
volumes: # volumes:
- BE_static:/backend-static # - BE_static:/backend-static
networks: # networks:
- ctel-sbt # - ctel-sbt
dashboard_refresh: # dashboard_refresh:
build: # build:
context: api-cronjob # context: api-cronjob
dockerfile: Dockerfile # dockerfile: Dockerfile
image: sidp/api-caller-sbt:latest # image: sidp/api-caller-sbt:latest
environment: # environment:
- PROXY=http://be-ctel-sbt:9000 # - PROXY=http://be-ctel-sbt:9000
- ADMIN_USER_NAME=${ADMIN_USER_NAME} # - ADMIN_USER_NAME=${ADMIN_USER_NAME}
- ADMIN_PASSWORD=${ADMIN_PASSWORD} # - ADMIN_PASSWORD=${ADMIN_PASSWORD}
depends_on: # depends_on:
be-ctel-sbt: # be-ctel-sbt:
condition: service_healthy # condition: service_healthy
restart: always # restart: always
networks: # networks:
- ctel-sbt # - ctel-sbt
volumes: volumes:
db_data: db_data: