Skip to content

Commit

Permalink
Add filter to only list required entities
Browse files Browse the repository at this point in the history
  • Loading branch information
sangeethailango committed Jan 2, 2025
1 parent 40a18f7 commit 6fbb36c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 6 additions & 5 deletions apiserver/plane/app/serializers/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from .base import BaseSerializer, DynamicBaseSerializer
from .user import UserLiteSerializer, UserAdminLiteSerializer


from plane.db.models import (
Workspace,
WorkspaceMember,
Expand All @@ -18,7 +19,7 @@
Issue,
Page,
Project,
ProjectMember,
ProjectMember
)
from plane.utils.constants import RESTRICTED_WORKSPACE_SLUGS

Expand Down Expand Up @@ -153,18 +154,18 @@ class Meta:
fields = ["member"]

class ProjectRecentVisitSerializer(serializers.ModelSerializer):
project_members = serializers.SerializerMethodField()

project_members = serializers.SerializerMethodField()
class Meta:
model = Project
fields = ["id", "name", "logo_props", "project_members"]

def get_project_members(self, obj):
members = ProjectMember.objects.filter(project_id=obj.id)
members = ProjectMember.objects.filter(project_id=obj.id)

serializer = ProjectMemberSerializer(members, many=True)
return serializer.data

class PageRecentVisitSerializer(serializers.ModelSerializer):
project_id = serializers.SerializerMethodField()

Expand Down
3 changes: 2 additions & 1 deletion apiserver/plane/app/views/workspace/recent_visit.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ def get_serializer_class(self):

@allow_permission([ROLE.ADMIN, ROLE.MEMBER, ROLE.GUEST], level="WORKSPACE")
def list(self, request, slug):
user_recent_visits = UserRecentVisit.objects.filter(workspace__slug=slug)
user_recent_visits = UserRecentVisit.objects.filter(workspace__slug=slug).filter(entity_name__in=["issue","page","project"])

serializer = WorkspaceRecentVisitSerializer(user_recent_visits, many=True)

return Response(serializer.data, status=status.HTTP_200_OK)

0 comments on commit 6fbb36c

Please sign in to comment.