Search now also includes Files and URLs
All checks were successful
Build containers when image tags change / build-if-image-changed (., web, containers, main container, git.baumann.gr/adebaumann/labhelper) (push) Successful in 2m53s
Build containers when image tags change / build-if-image-changed (data-loader, loader, initContainers, init-container, git.baumann.gr/adebaumann/labhelper-data-loader) (push) Successful in 5s
All checks were successful
Build containers when image tags change / build-if-image-changed (., web, containers, main container, git.baumann.gr/adebaumann/labhelper) (push) Successful in 2m53s
Build containers when image tags change / build-if-image-changed (data-loader, loader, initContainers, init-container, git.baumann.gr/adebaumann/labhelper-data-loader) (push) Successful in 5s
This commit is contained in:
@@ -143,8 +143,12 @@ def search_api(request):
|
||||
things = Thing.objects.filter(
|
||||
Q(name__icontains=query) |
|
||||
Q(description__icontains=query) |
|
||||
Q(thing_type__name__icontains=query)
|
||||
).select_related('thing_type', 'box')[:50]
|
||||
Q(thing_type__name__icontains=query) |
|
||||
Q(files__title__icontains=query) |
|
||||
Q(files__file__icontains=query) |
|
||||
Q(links__title__icontains=query) |
|
||||
Q(links__url__icontains=query)
|
||||
).prefetch_related('files', 'links').select_related('thing_type', 'box').distinct()[:50]
|
||||
|
||||
results = [
|
||||
{
|
||||
@@ -153,6 +157,20 @@ def search_api(request):
|
||||
'type': thing.thing_type.name,
|
||||
'box': thing.box.id,
|
||||
'description': thing.description[:100] if thing.description else '',
|
||||
'files': [
|
||||
{
|
||||
'title': f.title,
|
||||
'filename': f.filename(),
|
||||
}
|
||||
for f in thing.files.all()
|
||||
],
|
||||
'links': [
|
||||
{
|
||||
'title': l.title,
|
||||
'url': l.url,
|
||||
}
|
||||
for l in thing.links.all()
|
||||
],
|
||||
}
|
||||
for thing in things
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user