fix: make datetime aware in get_start_time and get_end_time methods
parent
24b36bf90f
commit
669764492c
|
|
@ -13,6 +13,7 @@ from typing import Dict, List
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models import QuerySet
|
from django.db.models import QuerySet
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
from django.utils import timezone
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
from application.models import ApplicationChatUserStats, Application
|
from application.models import ApplicationChatUserStats, Application
|
||||||
|
|
@ -48,12 +49,14 @@ class ApplicationStatisticsSerializer(serializers.Serializer):
|
||||||
raise AppApiException(500, _('Application id does not exist'))
|
raise AppApiException(500, _('Application id does not exist'))
|
||||||
|
|
||||||
def get_end_time(self):
|
def get_end_time(self):
|
||||||
return datetime.datetime.combine(
|
d = datetime.datetime.strptime(self.data.get('end_time'), '%Y-%m-%d').date()
|
||||||
datetime.datetime.strptime(self.data.get('end_time'), '%Y-%m-%d'),
|
naive = datetime.datetime.combine(d, datetime.time.max)
|
||||||
datetime.datetime.max.time())
|
return timezone.make_aware(naive, timezone.get_default_timezone())
|
||||||
|
|
||||||
def get_start_time(self):
|
def get_start_time(self):
|
||||||
return self.data.get('start_time')
|
d = datetime.datetime.strptime(self.data.get('start_time'), '%Y-%m-%d').date()
|
||||||
|
naive = datetime.datetime.combine(d, datetime.time.min)
|
||||||
|
return timezone.make_aware(naive, timezone.get_default_timezone())
|
||||||
|
|
||||||
def get_customer_count_trend(self, with_valid=True):
|
def get_customer_count_trend(self, with_valid=True):
|
||||||
if with_valid:
|
if with_valid:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue