mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
feat: return workspace member count on user workspace endpoint (#162)
This commit is contained in:
parent
8474b400b0
commit
c97e8f68bb
@ -12,6 +12,7 @@ from plane.db.models import Workspace, WorkspaceMember, Team, WorkspaceMemberInv
|
||||
class WorkSpaceSerializer(BaseSerializer):
|
||||
|
||||
owner = UserLiteSerializer(read_only=True)
|
||||
total_members = serializers.IntegerField(read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = Workspace
|
||||
|
@ -10,7 +10,7 @@ from django.utils import timezone
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core.validators import validate_email
|
||||
from django.contrib.sites.shortcuts import get_current_site
|
||||
from django.db.models import CharField
|
||||
from django.db.models import CharField, Count
|
||||
from django.db.models.functions import Cast
|
||||
|
||||
# Third party modules
|
||||
@ -119,7 +119,8 @@ class UserWorkSpacesEndpoint(BaseAPIView):
|
||||
workspace_member__member=request.user,
|
||||
)
|
||||
.select_related("owner")
|
||||
)
|
||||
).annotate(total_members=Count("workspace_member"))
|
||||
|
||||
serializer = WorkSpaceSerializer(self.filter_queryset(workspace), many=True)
|
||||
return Response(serializer.data, status=status.HTTP_200_OK)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user