From ae3bd2b13ad59107912af394f49b56b343b95fbc Mon Sep 17 00:00:00 2001 From: dx-tan <dx.tan@samsung.com> Date: Tue, 6 Feb 2024 11:08:46 +0700 Subject: [PATCH] Fix: subtotal on dashboard --- cope2n-api/fwd_api/utils/accuracy.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cope2n-api/fwd_api/utils/accuracy.py b/cope2n-api/fwd_api/utils/accuracy.py index 6d500fd..331d991 100644 --- a/cope2n-api/fwd_api/utils/accuracy.py +++ b/cope2n-api/fwd_api/utils/accuracy.py @@ -178,6 +178,7 @@ class ReportAccumulateByRequest: this_day = request.created_at.strftime("%Y%m%d") if not self.data.get(this_month, None): self.data[this_month] = [copy.deepcopy(self.total_format), {}] + self.data[this_month][0]["extraction_date"] = "Subtotal (" + request.created_at.strftime("%Y-%m") + ")" if not self.data[this_month][1].get(this_day, None): self.data[this_month][1][this_day] = copy.deepcopy(self.day_format)[0] self.data[this_month][1][this_day]['extraction_date'] = request.created_at.strftime("%Y-%m-%d") @@ -207,7 +208,9 @@ class ReportAccumulateByRequest: # extract data for month in report_data.keys(): fine_data.append(report_data[month][0]) - for day in report_data[month][1].keys(): + day_keys = list(report_data[month][1].keys()) + day_keys.sort(reverse = True) + for day in day_keys: fine_data.append(report_data[month][1][day]) # save daily reports report_id = root_report_id + "_" + day