fix: dashboard endpoint for overdue and upcoming issues (#502)

* fix: dashboard endpoint for overdue and upcoming issues

* dev: update for upcoming issue to get target date null issues as well

* dev: update the filter
This commit is contained in:
pablohashescobar 2023-03-24 00:13:48 +05:30 committed by GitHub
parent 3056727190
commit 6c6f9a5bfd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -670,7 +670,7 @@ class UserWorkspaceDashboardEndpoint(BaseAPIView):
workspace__slug=slug, assignees__in=[request.user] workspace__slug=slug, assignees__in=[request.user]
).count() ).count()
pending_issues = Issue.objects.filter( pending_issues_count = Issue.objects.filter(
~Q(state__group__in=["completed", "cancelled"]), ~Q(state__group__in=["completed", "cancelled"]),
workspace__slug=slug, workspace__slug=slug,
assignees__in=[request.user], assignees__in=[request.user],
@ -701,17 +701,19 @@ class UserWorkspaceDashboardEndpoint(BaseAPIView):
) )
overdue_issues = Issue.objects.filter( overdue_issues = Issue.objects.filter(
~Q(state__group__in=["completed", "cancelled"]),
workspace__slug=slug, workspace__slug=slug,
assignees__in=[request.user], assignees__in=[request.user],
target_date__lt=timezone.now(), target_date__lt=timezone.now(),
completed_at__isnull=False, completed_at__isnull=True,
).values("id", "name", "workspace__slug", "project_id", "target_date") ).values("id", "name", "workspace__slug", "project_id", "target_date")
upcoming_issues = Issue.objects.filter( upcoming_issues = Issue.objects.filter(
~Q(state__group__in=["completed", "cancelled"]),
~Q(target_date__gte=timezone.now()),
workspace__slug=slug, workspace__slug=slug,
assignees__in=[request.user], assignees__in=[request.user],
target_date__gte=timezone.now(), completed_at__isnull=True,
completed_at__isnull=False,
).values("id", "name", "workspace__slug", "project_id", "target_date") ).values("id", "name", "workspace__slug", "project_id", "target_date")
return Response( return Response(
@ -719,7 +721,7 @@ class UserWorkspaceDashboardEndpoint(BaseAPIView):
"issue_activities": issue_activities, "issue_activities": issue_activities,
"completed_issues": completed_issues, "completed_issues": completed_issues,
"assigned_issues_count": assigned_issues, "assigned_issues_count": assigned_issues,
"pending_issues_count": pending_issues, "pending_issues_count": pending_issues_count,
"completed_issues_count": completed_issues_count, "completed_issues_count": completed_issues_count,
"issues_due_week_count": issues_due_week, "issues_due_week_count": issues_due_week,
"state_distribution": state_distribution, "state_distribution": state_distribution,