mirror of
https://github.com/makeplane/plane.git
synced 2026-08-29 10:08:51 +02:00
feat(api): enhance workspace module query to include member IDs (#9541)
Added an annotation to the WorkspaceModulesEndpoint to aggregate member IDs into an array, ensuring that only active members are included. This change improves the data structure returned by the API, allowing for better handling of member information in the frontend. Updated the corresponding utility function to handle potential null values for member IDs.
This commit is contained in:
@@ -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 modules
|
||||
from 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"))
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user