From ff3f1897bc8bfaf9f2c0636c9bd76251b10c62aa Mon Sep 17 00:00:00 2001 From: Nikhil <118773738+pablohashescobar@users.noreply.github.com> Date: Mon, 31 Jul 2023 17:49:07 +0530 Subject: [PATCH] feat: user cycle stats (#1723) * feat: user cycle stats * dev: revert capture exception --- apiserver/plane/api/views/workspace.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/apiserver/plane/api/views/workspace.py b/apiserver/plane/api/views/workspace.py index 3404bbf19..a9822aa0b 100644 --- a/apiserver/plane/api/views/workspace.py +++ b/apiserver/plane/api/views/workspace.py @@ -73,7 +73,7 @@ from plane.db.models import ( IssueSubscriber, Project, Label, - State, + CycleIssue, ) from plane.api.permissions import ( WorkSpaceBasePermission, @@ -1140,6 +1140,19 @@ class WorkspaceUserProfileStatsEndpoint(BaseAPIView): .count() ) + upcoming_cycles = CycleIssue.objects.filter( + workspace__slug=slug, + cycle__start_date__gt=timezone.now().date(), + issue__assignees__in=[user_id,] + ).values("cycle__name", "cycle__id", "cycle__project_id") + + present_cycle = CycleIssue.objects.filter( + workspace__slug=slug, + cycle__start_date__lt=timezone.now().date(), + cycle__end_date__gt=timezone.now().date(), + issue__assignees__in=[user_id,] + ).values("cycle__name", "cycle__id", "cycle__project_id") + return Response( { "state_distribution": state_distribution, @@ -1149,6 +1162,8 @@ class WorkspaceUserProfileStatsEndpoint(BaseAPIView): "completed_issues": completed_issues_count, "pending_issues": pending_issues_count, "subscribed_issues": subscribed_issues_count, + "present_cycles": present_cycle, + "upcoming_cycles": upcoming_cycles, } ) except Exception as e: @@ -1394,6 +1409,7 @@ class WorkspaceUserProfileIssuesEndpoint(BaseAPIView): status=status.HTTP_400_BAD_REQUEST, ) + class WorkspaceLabelsEndpoint(BaseAPIView): permission_classes = [ WorkspaceEntityPermission,