diff --git a/apiserver/plane/app/views/cycle.py b/apiserver/plane/app/views/cycle.py index f5701fc7edd..d4166bb9b68 100644 --- a/apiserver/plane/app/views/cycle.py +++ b/apiserver/plane/app/views/cycle.py @@ -1046,111 +1046,6 @@ def get(self, request, slug): .order_by("-created_at") ) - cycles = CycleSerializer(active_cycles, many=True).data - - for cycle in cycles: - assignee_distribution = ( - Issue.objects.filter( - issue_cycle__cycle_id=cycle["id"], - project_id=cycle["project"], - workspace__slug=slug, - ) - .annotate(display_name=F("assignees__display_name")) - .annotate(assignee_id=F("assignees__id")) - .annotate(avatar=F("assignees__avatar")) - .values("display_name", "assignee_id", "avatar") - .annotate( - total_issues=Count( - "assignee_id", - filter=Q(archived_at__isnull=True, is_draft=False), - ), - ) - .annotate( - completed_issues=Count( - "assignee_id", - filter=Q( - completed_at__isnull=False, - archived_at__isnull=True, - is_draft=False, - ), - ) - ) - .annotate( - pending_issues=Count( - "assignee_id", - filter=Q( - completed_at__isnull=True, - archived_at__isnull=True, - is_draft=False, - ), - ) - ) - .order_by("display_name") - ) + active_cycles = CycleSerializer(active_cycles, many=True).data - label_distribution = ( - Issue.objects.filter( - issue_cycle__cycle_id=cycle["id"], - project_id=cycle["project"], - workspace__slug=slug, - ) - .annotate(label_name=F("labels__name")) - .annotate(color=F("labels__color")) - .annotate(label_id=F("labels__id")) - .values("label_name", "color", "label_id") - .annotate( - total_issues=Count( - "label_id", - filter=Q(archived_at__isnull=True, is_draft=False), - ) - ) - .annotate( - completed_issues=Count( - "label_id", - filter=Q( - completed_at__isnull=False, - archived_at__isnull=True, - is_draft=False, - ), - ) - ) - .annotate( - pending_issues=Count( - "label_id", - filter=Q( - completed_at__isnull=True, - archived_at__isnull=True, - is_draft=False, - ), - ) - ) - .order_by("label_name") - ) - cycle["distribution"] = { - "assignees": assignee_distribution, - "labels": label_distribution, - "completion_chart": {}, - } - if cycle["start_date"] and cycle["end_date"]: - cycle["distribution"][ - "completion_chart" - ] = burndown_plot( - queryset=active_cycles.get(pk=cycle["id"]), - slug=slug, - project_id=cycle["project"], - cycle_id=cycle["id"], - ) - - priority_issues = Issue.objects.filter(issue_cycle__cycle_id=cycle["id"], priority__in=["urgent", "high"]) - # Priority Ordering - priority_order = ["urgent", "high"] - priority_issues = priority_issues.annotate( - priority_order=Case( - *[When(priority=p, then=Value(i)) for i, p in enumerate(priority_order)], - output_field=CharField(), - ) - ).order_by("priority_order")[:5] - - cycle["issues"] = IssueSerializer(priority_issues, many=True).data - - return Response(cycles, status=status.HTTP_200_OK) + return Response(active_cycles, status=status.HTTP_200_OK)