Merge pull request #25 from SDSRV-IDP/enhancment/accuracy_calculation
Enhancment/accuracy calculation
This commit is contained in:
commit
e6b0a55f71
@ -132,9 +132,12 @@ def process_csv_feedback(csv_file_path, feedback_id):
|
||||
else:
|
||||
None
|
||||
else:
|
||||
_predict_result = {"retailername": None, "sold_to_party": None, "purchase_date": [], "imei_number": [_predict_result["imei_number"][image.index_in_request]]}
|
||||
_feedback_result = {"retailername": None, "sold_to_party": None, "purchase_date": None, "imei_number": [_feedback_result["imei_number"][image.index_in_request]]} if _feedback_result else None
|
||||
_reviewed_result = {"retailername": None, "sold_to_party": None, "purchase_date": None, "imei_number": [_reviewed_result["imei_number"][image.index_in_request]]} if _reviewed_result else None
|
||||
try:
|
||||
_predict_result = {"retailername": None, "sold_to_party": None, "purchase_date": [], "imei_number": [_predict_result["imei_number"][image.index_in_request]]}
|
||||
_feedback_result = {"retailername": None, "sold_to_party": None, "purchase_date": None, "imei_number": [_feedback_result["imei_number"][image.index_in_request]]} if _feedback_result else None
|
||||
_reviewed_result = {"retailername": None, "sold_to_party": None, "purchase_date": None, "imei_number": [_reviewed_result["imei_number"][image.index_in_request]]} if _reviewed_result else None
|
||||
except Exception as e:
|
||||
print (f"[ERROR]: {request_id} - {e}")
|
||||
image.predict_result = _predict_result
|
||||
image.feedback_result = _feedback_result
|
||||
image.reviewed_result = _reviewed_result
|
||||
|
@ -206,7 +206,9 @@ class ReportAccumulateByRequest:
|
||||
save_data = {"file": {"overview": f"{root_report_id}/{root_report_id}.xlsx"},
|
||||
"data": fine_data} # {"sub_report_id": "S3 location", "data": fine_data}
|
||||
# extract data
|
||||
for month in report_data.keys():
|
||||
month_keys = list(report_data.keys())
|
||||
month_keys.sort(reverse=True)
|
||||
for month in month_keys:
|
||||
fine_data.append(report_data[month][0])
|
||||
day_keys = list(report_data[month][1].keys())
|
||||
day_keys.sort(reverse = True)
|
||||
|
@ -22,7 +22,7 @@ from ..celery_worker.client_connector import c_connector
|
||||
import imagesize
|
||||
import csv
|
||||
from openpyxl import load_workbook
|
||||
from openpyxl.styles import Font, Border, Side, PatternFill, NamedStyle
|
||||
from openpyxl.styles import Font, Border, Side, PatternFill, NamedStyle, numbers
|
||||
|
||||
s3_client = S3Util.MinioS3Client(
|
||||
endpoint=settings.S3_ENDPOINT,
|
||||
@ -496,6 +496,8 @@ def dict2xlsx(input: json, _type='report'):
|
||||
if _type == 'report':
|
||||
if subtotal['subs'] == '+':
|
||||
ws[key + str(start_index)].font = font_black_bold
|
||||
if key_index in [6, 8, 9, 10, 11, 12, 13]:
|
||||
ws[key + str(start_index)].number_format = numbers.FORMAT_NUMBER_00
|
||||
if key_index == 0 or (key_index >= 9 and key_index <= 15):
|
||||
ws[key + str(start_index)].fill = fill_gray
|
||||
elif key_index == 1:
|
||||
@ -503,12 +505,20 @@ def dict2xlsx(input: json, _type='report'):
|
||||
elif key_index >= 4 and key_index <= 8:
|
||||
ws[key + str(start_index)].fill = fill_yellow
|
||||
else:
|
||||
if 'average_accuracy_rate' in mapping[key] and type(value) in [int, float] and value < 95:
|
||||
ws[key + str(start_index)].style = normal_cell_red
|
||||
elif 'average_processing_time' in mapping[key] and type(value) in [int, float] and value > 2.0:
|
||||
ws[key + str(start_index)].style = normal_cell_red
|
||||
elif 'bad_percent' in mapping[key] and type(value) in [int, float] and value > 10:
|
||||
ws[key + str(start_index)].style = normal_cell_red
|
||||
if 'average_accuracy_rate' in mapping[key] and type(value) in [int, float]:
|
||||
if value < 95:
|
||||
ws[key + str(start_index)].style = normal_cell_red
|
||||
ws[key + str(start_index)].number_format = numbers.FORMAT_NUMBER_00
|
||||
elif 'average_processing_time' in mapping[key] and type(value) in [int, float]:
|
||||
if value > 2.0:
|
||||
ws[key + str(start_index)].style = normal_cell_red
|
||||
ws[key + str(start_index)].number_format = numbers.FORMAT_NUMBER_00
|
||||
elif 'bad_percent' in mapping[key] and type(value) in [int, float]:
|
||||
if value > 10:
|
||||
ws[key + str(start_index)].style = normal_cell_red
|
||||
ws[key + str(start_index)].number_format = numbers.FORMAT_NUMBER_00
|
||||
elif 'percent' in mapping[key] and type(value) in [int, float]:
|
||||
ws[key + str(start_index)].number_format = numbers.FORMAT_NUMBER_00
|
||||
else :
|
||||
ws[key + str(start_index)].style = normal_cell
|
||||
elif _type == 'report_detail':
|
||||
|
Loading…
Reference in New Issue
Block a user