Fix: misalign timezone on download file
This commit is contained in:
parent
91ba1e9e7a
commit
d6518c85e5
@ -7,6 +7,7 @@ from django.utils import timezone
|
||||
from django.db.models import Q
|
||||
import uuid
|
||||
import os
|
||||
import pytz
|
||||
from fwd import settings
|
||||
from drf_spectacular.utils import extend_schema, OpenApiParameter, OpenApiTypes
|
||||
# from drf_spectacular.types import OpenApiString
|
||||
@ -504,7 +505,8 @@ class AccuracyViewSet(viewsets.ViewSet):
|
||||
raise NotFoundException(excArgs=f"report: {report_id}")
|
||||
report = Report.objects.filter(report_id=report_id).first()
|
||||
# download from s3 to local
|
||||
tmp_file = "/tmp/" + report.subsidiary + "_" + report.start_at.strftime("%Y%m%d") + "_" + report.end_at.strftime("%Y%m%d") + "_created_on_" + report.created_at.strftime("%Y%m%d") + ".xlsx"
|
||||
target_timezone = pytz.timezone(settings.TIME_ZONE)
|
||||
tmp_file = "/tmp/" + report.subsidiary + "_" + report.start_at.astimezone(target_timezone).strftime("%Y%m%d") + "_" + report.end_at.astimezone(target_timezone).strftime("%Y%m%d") + "_created_on_" + report.created_at.astimezone(target_timezone).strftime("%Y%m%d") + ".xlsx"
|
||||
os.makedirs("/tmp", exist_ok=True)
|
||||
if not report.S3_file_name:
|
||||
raise NotFoundException(excArgs="S3 file name")
|
||||
|
Loading…
Reference in New Issue
Block a user