fix api dashboard

This commit is contained in:
Chaiyawut Thengket 2023-11-27 16:07:35 +07:00
parent cb7067de48
commit fd58eabcab

View File

@ -35,14 +35,12 @@ class DashboardStatsTodoViewSet(viewsets.GenericViewSet, mixins.ListModelMixin):
# Task assign last week compared with this week
tasks_assigned_last_week = Todo.objects.filter(
user=user,
completion_date__gte=start_date - timedelta(days=7),
completion_date__lte=start_date
).count()
creation_date__range = (start_date, start_date - timedelta(days=7))
)
tasks_assigned_this_week = Todo.objects.filter(
user=user,
completion_date__gte=start_date,
completion_date__lte=end_date
creation_date__range = (start_date, end_date)
).count()
# Completed tasks from last week compared with this week
@ -84,12 +82,6 @@ class DashboardStatsTodoViewSet(viewsets.GenericViewSet, mixins.ListModelMixin):
completion_date__lte=today_end
).count()
total_tasks_today = Todo.objects.filter(
user=user,
start_event__gte=today_start,
end_event__lte=today_end
).count()
data = {
"completed_last_7_days": completed_last_7_days,
"tasks_assigned_last_week": tasks_assigned_last_week,