π₯π₯π₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.
TypeScript boardsbug-trackerdjangodockerganttissue-trackerjirajira-alternativekanbanlinearpostgresqlproduct-managementproject-managementproject-planningpythonreactredistypesciptvitework-management
feat(api): enhance workspace module query to include member IDs (#9541)
Atul Tameshwaria18177ce5e01
diff --git a/apps/api/plane/app/views/workspace/module.py b/apps/api/plane/app/views/workspace/module.pyindex ea217809b9..0ace291286 100644--- a/apps/api/plane/app/views/workspace/module.py+++ b/apps/api/plane/app/views/workspace/module.py@@ -3,7 +3,10 @@# See the LICENSE file for details.# Django imports-from django.db.models import Prefetch, Q, Count+from django.contrib.postgres.aggregates import ArrayAgg+from django.contrib.postgres.fields import ArrayField+from django.db.models import Prefetch, Q, Count, UUIDField, Value+from django.db.models.functions import Coalesce# Third party modulesfrom rest_framework import status@@ -109,6 +112,19 @@ class WorkspaceModulesEndpoint(BaseAPIView):distinct=True,))+ .annotate(+ member_ids=Coalesce(+ ArrayAgg(+ "members__id",+ distinct=True,+ filter=Q(+ members__id__isnull=False,+ modulemember__deleted_at__isnull=True,+ ),+ ),+ Value([], output_field=ArrayField(UUIDField())),+ )+ ).order_by(self.kwargs.get("order_by", "-created_at")))diff --git a/packages/utils/src/module.ts b/packages/utils/src/module.tsindex c446836107..bd96120308 100644--- a/packages/utils/src/module.ts+++ b/packages/utils/src/module.ts@@ -30,8 +30,8 @@ export const orderModules = (modules: IModule[], orderByKey: TModuleOrderByOptiolet orderedModules: IModule[] = [];if (modules.length === 0 || !orderByKey) return [];- if (orderByKey === "name") orderedModules = [...modules].sort((a, b) => naturalSort(a.name, b.name));- if (orderByKey === "-name") orderedModules = [...modules].sort((a, b) => naturalSort(b.name, a.name));+ if (orderByKey === "name") orderedModules = [...modules].toSorted((a, b) => naturalSort(a.name, b.name));+ if (orderByKey === "-name") orderedModules = [...modules].toSorted((a, b) => naturalSort(b.name, a.name));if (["progress", "-progress"].includes(orderByKey))orderedModules = sortBy(modules, [(m) => {@@ -71,7 +71,7 @@ export const shouldFilterModule = (if (filterKey === "lead" && filters.lead && filters.lead.length > 0)fallsInFilters = fallsInFilters && filters.lead.includes(`${module.lead_id}`);if (filterKey === "members" && filters.members && filters.members.length > 0) {- const memberIds = module.member_ids;+ const memberIds = module.member_ids ?? [];fallsInFilters = fallsInFilters && filters.members.some((memberId) => memberIds.includes(memberId));}if (filterKey === "start_date" && filters.start_date && filters.start_date.length > 0) {