Fix: skip create auto daily report
This commit is contained in:
parent
1ebc83ff02
commit
72953c318a
@ -349,14 +349,15 @@ class AccuracyViewSet(viewsets.ViewSet):
|
|||||||
@action(detail=False, url_path="report_list", methods=["GET"])
|
@action(detail=False, url_path="report_list", methods=["GET"])
|
||||||
def get_report_list(self, request):
|
def get_report_list(self, request):
|
||||||
if request.method == 'GET':
|
if request.method == 'GET':
|
||||||
daily_report_only = request.GET.get('daily_report_only', False)
|
exclude_daily_report = request.GET.get('exclude_daily_report', True)
|
||||||
start_date_str = request.GET.get('start_date', "")
|
start_date_str = request.GET.get('start_date', "")
|
||||||
end_date_str = request.GET.get('end_date', "")
|
end_date_str = request.GET.get('end_date', "")
|
||||||
page_number = int(request.GET.get('page', 1))
|
page_number = int(request.GET.get('page', 1))
|
||||||
page_size = int(request.GET.get('page_size', 10))
|
page_size = int(request.GET.get('page_size', 10))
|
||||||
|
|
||||||
|
reports = None
|
||||||
if not start_date_str or not end_date_str:
|
if not start_date_str or not end_date_str:
|
||||||
reports = Report.objects.all().order_by('created_at').reverse()
|
reports = Report.objects
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
start_date = timezone.datetime.strptime(start_date_str, '%Y-%m-%dT%H:%M:%S%z')
|
start_date = timezone.datetime.strptime(start_date_str, '%Y-%m-%dT%H:%M:%S%z')
|
||||||
@ -364,14 +365,15 @@ class AccuracyViewSet(viewsets.ViewSet):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
raise InvalidException(excArgs="Date format")
|
raise InvalidException(excArgs="Date format")
|
||||||
base_query = Q(created_at__range=(start_date, end_date))
|
base_query = Q(created_at__range=(start_date, end_date))
|
||||||
if daily_report_only:
|
reports = Report.objects.filter(base_query)
|
||||||
base_query &= Q(is_daily_report=True)
|
|
||||||
reports = Report.objects.filter(base_query).order_by('created_at').reverse()
|
if exclude_daily_report:
|
||||||
|
reports = Report.objects.filter(is_daily_report=False)
|
||||||
|
reports = reports.order_by('created_at').reverse()
|
||||||
|
|
||||||
paginator = Paginator(reports, page_size)
|
paginator = Paginator(reports, page_size)
|
||||||
page = paginator.get_page(page_number)
|
page = paginator.get_page(page_number)
|
||||||
|
|
||||||
|
|
||||||
data = []
|
data = []
|
||||||
for report in page:
|
for report in page:
|
||||||
acc_keys = ["purchase_date", "retailername", "imei_number", "avg"]
|
acc_keys = ["purchase_date", "retailername", "imei_number", "avg"]
|
||||||
|
@ -252,6 +252,7 @@ class ReportAccumulateByRequest:
|
|||||||
feedback_accuracy=acumulated_acc["feedback_accuracy"],
|
feedback_accuracy=acumulated_acc["feedback_accuracy"],
|
||||||
reviewed_accuracy=acumulated_acc["reviewed_accuracy"],
|
reviewed_accuracy=acumulated_acc["reviewed_accuracy"],
|
||||||
)
|
)
|
||||||
|
if is_daily_report:
|
||||||
new_report.save()
|
new_report.save()
|
||||||
data = extract_report_detail_list(self.data[month][1][day]["report_files"], lower=True)
|
data = extract_report_detail_list(self.data[month][1][day]["report_files"], lower=True)
|
||||||
data_workbook = dict2xlsx(data, _type='report_detail')
|
data_workbook = dict2xlsx(data, _type='report_detail')
|
||||||
|
Loading…
Reference in New Issue
Block a user