Merge branch 'perf/cycle-module-endpoints' of github.com:makeplane/plane into perf/cycle-module-endpoints

This commit is contained in:
rahulramesha 2024-02-20 12:21:19 +05:30
commit 7078863189
4 changed files with 17 additions and 33 deletions

View File

@ -72,6 +72,7 @@ from .issue import (
)
from .module import (
ModuleDetailSerializer,
ModuleWriteSerializer,
ModuleSerializer,
ModuleIssueSerializer,

View File

@ -142,7 +142,6 @@ class ModuleIssueSerializer(BaseSerializer):
class ModuleLinkSerializer(BaseSerializer):
created_by_detail = UserLiteSerializer(read_only=True, source="created_by")
class Meta:
model = ModuleLink
@ -216,6 +215,15 @@ class ModuleSerializer(DynamicBaseSerializer):
read_only_fields = fields
class ModuleDetailSerializer(ModuleSerializer):
link_module = ModuleLinkSerializer(read_only=True, many=True)
class Meta(ModuleSerializer.Meta):
fields = ModuleSerializer.Meta.fields + ['link_module']
class ModuleFavoriteSerializer(BaseSerializer):
module_detail = ModuleFlatSerializer(source="module", read_only=True)

View File

@ -87,8 +87,8 @@ class IssueListEndpoint(BaseAPIView):
ProjectEntityPermission,
]
def post(self, request, slug, project_id):
issues = request.data.get("issues", [])
def get(self, request, slug, project_id):
issues = request.GET.get("issues", False)
if not issues:
return Response(
@ -96,6 +96,8 @@ class IssueListEndpoint(BaseAPIView):
status=status.HTTP_400_BAD_REQUEST,
)
issues = [issue for issue in issues.split(",") if issue != ""]
queryset = (
Issue.issue_objects.filter(
workspace__slug=slug, project_id=project_id, pk__in=issues
@ -147,7 +149,7 @@ class IssueListEndpoint(BaseAPIView):
order_by_param = request.GET.get("order_by", "-created_at")
issue_queryset = self.get_queryset().filter(**filters)
issue_queryset = queryset.filter(**filters)
# Priority Ordering
if order_by_param == "priority" or order_by_param == "-priority":

View File

@ -25,6 +25,7 @@ from plane.app.serializers import (
ModuleFavoriteSerializer,
IssueSerializer,
ModuleUserPropertiesSerializer,
ModuleDetailSerializer,
)
from plane.app.permissions import (
ProjectEntityPermission,
@ -337,35 +338,7 @@ class ModuleViewSet(WebhookMixin, BaseViewSet):
.order_by("label_name")
)
data = queryset.values( # Required fields
"id",
"workspace_id",
"project_id",
# Model fields
"name",
"description",
"description_text",
"description_html",
"start_date",
"target_date",
"status",
"lead_id",
"member_ids",
"view_props",
"sort_order",
"external_source",
"external_id",
# computed fields
"is_favorite",
"total_issues",
"cancelled_issues",
"completed_issues",
"started_issues",
"unstarted_issues",
"backlog_issues",
"created_at",
"updated_at",
).first()
data = ModuleDetailSerializer(queryset.first()).data
data["distribution"] = {
"assignees": assignee_distribution,
"labels": label_distribution,