Merge branch 'main' of https://code.sdsdev.co.kr/SDSRV-IDP/sbt-idp into BE/review_page

This commit is contained in:
TannedCung 2024-06-19 11:05:17 +07:00
commit ef1523860b

View File

@ -12,6 +12,7 @@ from ..utils.redis import RedisUtils
from ..utils.cache import set_cache, get_cache
from django.utils import timezone
from django.db.models import Q
from itertools import chain
import json
import copy
import os
@ -123,20 +124,17 @@ def create_accuracy_report(report_id, **kwargs):
"retailername": mean_list(request_att["acc"]["reviewed"].get("retailername", [None])),
"sold_to_party": mean_list(request_att["acc"]["reviewed"].get("sold_to_party", [None])),
"invoice_no": mean_list(request_att["acc"]["reviewed"].get("invoice_no", [None]))}
rq_accuracy = {"feedback": [],
"reviewed": []}
rq_accuracy = []
for rpf in _report_files:
for cl in rpf.feedback_accuracy.keys():
rq_accuracy["feedback"] += rpf.feedback_accuracy[cl]
for cl in rpf.reviewed_accuracy.keys():
rq_accuracy["reviewed"] += rpf.reviewed_accuracy[cl]
if sum(len(value_list) for value_list in rpf.reviewed_accuracy.values()):
rq_accuracy += list(chain(*rpf.reviewed_accuracy.values()))
elif sum(len(value_list) for value_list in rpf.feedback_accuracy.values()):
rq_accuracy += list(chain(*rpf.feedback_accuracy.values()))
request.is_required = False
if len(rq_accuracy["reviewed"]) > 0:
request.raw_accuracy = mean_list(rq_accuracy["reviewed"])
elif len(rq_accuracy["feedback"]) > 0:
request.raw_accuracy = mean_list(rq_accuracy["feedback"])
if len(rq_accuracy) > 0:
request.raw_accuracy = mean_list(rq_accuracy)
request.is_required = request.raw_accuracy < settings.NEED_REVIEW if isinstance(request.raw_accuracy, float) else False # No need to review by default
request.save()