Merge pull request #138 from SDSRV-IDP/BE/Fix_report_page

Be/fix report page
This commit is contained in:
Phan Thành Trung 2024-06-18 15:58:00 +07:00 committed by GitHub Enterprise
commit a710ceeb84
2 changed files with 9 additions and 11 deletions

View File

@ -987,7 +987,7 @@ class AccuracyViewSet(viewsets.ViewSet):
if isinstance(v, str) and v == '':
v = None
if k == "purchase_date" and v is not None:
v = v.split("")
v = v.split(",")
if not isinstance(sample_result[k], list):
sample_result[k] = v
elif v:

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()