From 628591854de37130079b23eb646fcfa6b0a9c71e Mon Sep 17 00:00:00 2001 From: pablohashescobar <118773738+pablohashescobar@users.noreply.github.com> Date: Wed, 29 Mar 2023 00:23:35 +0530 Subject: [PATCH] fix: search endpoint to return distint results (#566) Co-authored-by: Vamsi Kurama --- apiserver/plane/api/views/search.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/apiserver/plane/api/views/search.py b/apiserver/plane/api/views/search.py index 16652d762..ba75eac91 100644 --- a/apiserver/plane/api/views/search.py +++ b/apiserver/plane/api/views/search.py @@ -26,7 +26,7 @@ class GlobalSearchEndpoint(BaseAPIView): q |= Q(**{f"{field}__icontains": query}) return Workspace.objects.filter( q, workspace_member__member=self.request.user - ).values("name", "id", "slug") + ).distinct().values("name", "id", "slug") def filter_projects(self, query, slug, project_id): fields = ["name"] @@ -37,7 +37,7 @@ class GlobalSearchEndpoint(BaseAPIView): q, Q(project_projectmember__member=self.request.user) | Q(network=2), workspace__slug=slug, - ).values("name", "id", "identifier", "workspace__slug") + ).distinct().values("name", "id", "identifier", "workspace__slug") def filter_issues(self, query, slug, project_id): fields = ["name", "sequence_id"] @@ -54,7 +54,7 @@ class GlobalSearchEndpoint(BaseAPIView): project__project_projectmember__member=self.request.user, workspace__slug=slug, project_id=project_id, - ).values( + ).distinct().values( "name", "id", "sequence_id", @@ -73,7 +73,7 @@ class GlobalSearchEndpoint(BaseAPIView): project__project_projectmember__member=self.request.user, workspace__slug=slug, project_id=project_id, - ).values( + ).distinct().values( "name", "id", "project_id", @@ -90,7 +90,7 @@ class GlobalSearchEndpoint(BaseAPIView): project__project_projectmember__member=self.request.user, workspace__slug=slug, project_id=project_id, - ).values( + ).distinct().values( "name", "id", "project_id", @@ -107,7 +107,7 @@ class GlobalSearchEndpoint(BaseAPIView): project__project_projectmember__member=self.request.user, workspace__slug=slug, project_id=project_id, - ).values( + ).distinct().values( "name", "id", "project_id", @@ -124,7 +124,7 @@ class GlobalSearchEndpoint(BaseAPIView): project__project_projectmember__member=self.request.user, workspace__slug=slug, project_id=project_id, - ).values( + ).distinct().values( "name", "id", "project_id",