Skip to content

Commit

Permalink
Test with system prefix filter on id field
Browse files Browse the repository at this point in the history
  • Loading branch information
chandra-tacc committed Nov 2, 2023
1 parent f4ee9f5 commit c2830e9
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions server/portal/apps/projects/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c2830e9

Please sign in to comment.