diff --git a/apiserver/plane/api/serializers/issue.py b/apiserver/plane/api/serializers/issue.py index 6677f47cb..6315564ce 100644 --- a/apiserver/plane/api/serializers/issue.py +++ b/apiserver/plane/api/serializers/issue.py @@ -19,6 +19,8 @@ from plane.db.models import ( IssueLabel, Label, IssueBlocker, + Cycle, + CycleIssue, ) @@ -302,6 +304,38 @@ class IssueAssigneeSerializer(BaseSerializer): fields = "__all__" +class CycleBaseSerializer(BaseSerializer): + + class Meta: + model = Cycle + fields = "__all__" + read_only_fields = [ + "workspace", + "project", + "created_by", + "updated_by", + "created_at", + "updated_at", + ] + +class IssueCycleDetailSerializer(BaseSerializer): + + cycle_detail = CycleBaseSerializer(read_only=True, source="cycle") + + class Meta: + model = CycleIssue + fields = "__all__" + read_only_fields = [ + "workspace", + "project", + "created_by", + "updated_by", + "created_at", + "updated_at", + ] + + + class IssueSerializer(BaseSerializer): project_detail = ProjectSerializer(read_only=True, source="project") state_detail = StateSerializer(read_only=True, source="state") @@ -310,6 +344,7 @@ class IssueSerializer(BaseSerializer): assignee_details = UserLiteSerializer(read_only=True, source="assignees", many=True) blocked_issues = BlockedIssueSerializer(read_only=True, many=True) blocker_issues = BlockerIssueSerializer(read_only=True, many=True) + issue_cycle = IssueCycleDetailSerializer(read_only=True) class Meta: model = Issue diff --git a/apiserver/plane/api/views/issue.py b/apiserver/plane/api/views/issue.py index c6c30e867..e5465b15f 100644 --- a/apiserver/plane/api/views/issue.py +++ b/apiserver/plane/api/views/issue.py @@ -36,6 +36,7 @@ from plane.db.models import ( IssueProperty, Label, IssueBlocker, + CycleIssue, ) @@ -89,6 +90,12 @@ class IssueViewSet(BaseViewSet): queryset=IssueBlocker.objects.select_related("block", "blocked_by"), ) ) + .prefetch_related( + Prefetch( + "issue_cycle", + queryset=CycleIssue.objects.select_related("cycle", "issue"), + ), + ) ) def grouper(self, issue, group_by): @@ -384,7 +391,8 @@ class BulkDeleteIssuesEndpoint(BaseAPIView): issues.delete() return Response( - {"message": f"{total_issues} issues were deleted"}, status=status.HTTP_200_OK + {"message": f"{total_issues} issues were deleted"}, + status=status.HTTP_200_OK, ) except Exception as e: capture_exception(e)