From c2830e91316184d43b70841e5a8109fe812dd46f Mon Sep 17 00:00:00 2001 From: Chandra Y Date: Thu, 2 Nov 2023 18:41:59 -0500 Subject: [PATCH] Test with system prefix filter on id field --- server/portal/apps/projects/views.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/server/portal/apps/projects/views.py b/server/portal/apps/projects/views.py index fe25e2bc5..1746071f1 100644 --- a/server/portal/apps/projects/views.py +++ b/server/portal/apps/projects/views.py @@ -84,16 +84,19 @@ def get(self, request): search = search.query(ngram_query | wildcard_query) search = search.extra(from_=int(offset), size=int(limit)) + search = search.filter('prefix', **{'id': f'{settings.PORTAL_PROJECTS_SYSTEM_PREFIX}'}) res = search.execute() - hits = list(map(lambda hit: hit.id, res)) - listing = [] - # Filter search results to projects specific to user - if hits: - client = request.user.tapis_oauth.client - listing = list_projects(client) - filtered_list = filter(lambda prj: prj['id'] in hits, listing) - listing = list(filtered_list) + hits = [hit.to_dict() for hit in res] + listing = hits + # hits = list(map(lambda hit: hit.id, res)) + # listing = [] + # # Filter search results to projects specific to user + # if hits: + # client = request.user.tapis_oauth.client + # listing = list_projects(client) + # filtered_list = filter(lambda prj: prj['id'] in hits, listing) + # listing = list(filtered_list) else: client = request.user.tapis_oauth.client listing = list_projects(client)