Skip to content

Commit

Permalink
Merge branch 'main' into bug/WP-356-site-search
Browse files Browse the repository at this point in the history
  • Loading branch information
chandra-tacc authored Nov 7, 2023
2 parents 634ffbb + 7c0ba55 commit 8cb62c6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ const DataFilesProjectsList = ({ modal }) => {
Header: 'ID',
headerStyle: { textAlign: 'left' },
accessor: 'name',
Cell: (el) => <span>{el.value.split('-').slice(-1)[0]}</span>,
Cell: (el) => (
<span>{el.value ? el.value.split('-').slice(-1)[0] : ''}</span>
),
},
];

Expand Down
11 changes: 9 additions & 2 deletions server/portal/apps/projects/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,17 @@ 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 = [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
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,12 @@ def list_projects(client):

fields = "id,host,description,notes,updated,owner,rootDir"
query = f"id.like.{settings.PORTAL_PROJECTS_SYSTEM_PREFIX}.*"
# use limit as -1 to allow search to corelate with
# all projects available to the api user
listing = client.systems.getSystems(listType='ALL',
search=query,
select=fields)
select=fields,
limit=-1)

serialized_listing = map(lambda prj: {
"id": prj.id,
Expand Down

0 comments on commit 8cb62c6

Please sign in to comment.