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"])
|
||||
def get_report_list(self, request):
|
||||
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', "")
|
||||
end_date_str = request.GET.get('end_date', "")
|
||||
page_number = int(request.GET.get('page', 1))
|
||||
page_size = int(request.GET.get('page_size', 10))
|
||||
|
||||
reports = None
|
||||
if not start_date_str or not end_date_str:
|
||||
reports = Report.objects.all().order_by('created_at').reverse()
|
||||
reports = Report.objects
|
||||
else:
|
||||
try:
|
||||
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:
|
||||
raise InvalidException(excArgs="Date format")
|
||||
base_query = Q(created_at__range=(start_date, end_date))
|
||||
if daily_report_only:
|
||||
base_query &= Q(is_daily_report=True)
|
||||
reports = Report.objects.filter(base_query).order_by('created_at').reverse()
|
||||
reports = Report.objects.filter(base_query)
|
||||
|
||||
if exclude_daily_report:
|
||||
reports = Report.objects.filter(is_daily_report=False)
|
||||
reports = reports.order_by('created_at').reverse()
|
||||
|
||||
paginator = Paginator(reports, page_size)
|
||||
page = paginator.get_page(page_number)
|
||||
|
||||
|
||||
data = []
|
||||
for report in page:
|
||||
acc_keys = ["purchase_date", "retailername", "imei_number", "avg"]
|
||||
|
@ -252,7 +252,8 @@ class ReportAccumulateByRequest:
|
||||
feedback_accuracy=acumulated_acc["feedback_accuracy"],
|
||||
reviewed_accuracy=acumulated_acc["reviewed_accuracy"],
|
||||
)
|
||||
new_report.save()
|
||||
if is_daily_report:
|
||||
new_report.save()
|
||||
data = extract_report_detail_list(self.data[month][1][day]["report_files"], lower=True)
|
||||
data_workbook = dict2xlsx(data, _type='report_detail')
|
||||
local_workbook = save_workbook_file(report_id + ".xlsx", new_report, data_workbook)
|
||||
|
Loading…
Reference in New Issue
Block a user