Fixed BUG-136, now can search with a * or % as wildcards, and fix bug where no search results broke pa

This commit is contained in:
2024-12-31 15:13:17 +11:00
parent b34b71bf32
commit 37c0125fbd
4 changed files with 10 additions and 4 deletions

View File

@@ -234,6 +234,8 @@ def GetEntriesInFolderView( OPT, prefix ):
################################################################################
def GetEntriesInSearchView( OPT ):
search_term=OPT.orig_search_term
# turn * wildcard into sql wildcard of %
search_term=search_term.replace('*', '%' )
if 'AI:' in OPT.orig_search_term:
search_term = search_term.replace('AI:','')
join=f"Entry.query.join(File).join(FaceFileLink).join(Face).join(FaceRefimgLink).join(Refimg).join(PersonRefimgLink).join(Person).filter(Person.tag.ilike('%{search_term}%'))"
@@ -265,6 +267,11 @@ def GetEntriesInSearchView( OPT ):
if add_it:
all_entries.append(a)
# nothing found, just return now
if len(all_entries) == 0:
OPT.num_entries = 0
return []
# for all searches first_entry is worked out when first_eid not set yet & offset is 0 and we have some entries
if OPT.first_eid == 0 and OPT.offset == 0 and len(all_entries):
OPT.first_eid = all_entries[0].id