feat: add cycle id and cycle details in issue list page

This commit is contained in:
pablohashescobar 2022-12-13 23:24:42 +05:30
parent a5f071311d
commit ddde7a7eea
2 changed files with 44 additions and 1 deletions

View File

@ -19,6 +19,8 @@ from plane.db.models import (
IssueLabel, IssueLabel,
Label, Label,
IssueBlocker, IssueBlocker,
Cycle,
CycleIssue,
) )
@ -302,6 +304,38 @@ class IssueAssigneeSerializer(BaseSerializer):
fields = "__all__" 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): class IssueSerializer(BaseSerializer):
project_detail = ProjectSerializer(read_only=True, source="project") project_detail = ProjectSerializer(read_only=True, source="project")
state_detail = StateSerializer(read_only=True, source="state") 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) assignee_details = UserLiteSerializer(read_only=True, source="assignees", many=True)
blocked_issues = BlockedIssueSerializer(read_only=True, many=True) blocked_issues = BlockedIssueSerializer(read_only=True, many=True)
blocker_issues = BlockerIssueSerializer(read_only=True, many=True) blocker_issues = BlockerIssueSerializer(read_only=True, many=True)
issue_cycle = IssueCycleDetailSerializer(read_only=True)
class Meta: class Meta:
model = Issue model = Issue

View File

@ -36,6 +36,7 @@ from plane.db.models import (
IssueProperty, IssueProperty,
Label, Label,
IssueBlocker, IssueBlocker,
CycleIssue,
) )
@ -89,6 +90,12 @@ class IssueViewSet(BaseViewSet):
queryset=IssueBlocker.objects.select_related("block", "blocked_by"), 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): def grouper(self, issue, group_by):
@ -384,7 +391,8 @@ class BulkDeleteIssuesEndpoint(BaseAPIView):
issues.delete() issues.delete()
return Response( 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: except Exception as e:
capture_exception(e) capture_exception(e)