From 37c0125fbd1dc00807698fbd1bc40a48630f4cad Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Tue, 31 Dec 2024 15:13:17 +1100 Subject: [PATCH] Fixed BUG-136, now can search with a * or % as wildcards, and fix bug where no search results broke pa --- BUGs | 3 +-- files.py | 7 +++++++ templates/base.html | 2 +- templates/files.html | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/BUGs b/BUGs index 5f712f6..04a3c5d 100644 --- a/BUGs +++ b/BUGs @@ -1,4 +1,4 @@ -### Next: 136 +### Next: 137 BUG-100: I managed to get 2 photos matching mich in the NOT_WORKING photo (probably dif refimgs but same p.tag?) = /photos/2012/20120414-damien/IMG_8467.JPG BUG-106: cant add trudy /pat? as refimgs via FaceDBox @@ -25,4 +25,3 @@ BUG-132: right arrow to go to next photo in viewer ALSO scrolls to the right, ne BUG-133: when rebuilding pa[dev], the first run fails to have symlinks to the right paths for Import/Storage, etc. a simple restart fixes - so potentially the intial copy or some other race condition? BUG-134: when moving set of photos on page, then move another set of photos on page, the first set reappears. Could really delete them from the dom? BUG-135: failed to rotate: 2006/20061215-ITS-xmas-KP/DSC00582.JPG - not sure why -BUG-136: cant use % explicitly in search (think its special to http, not being trapped by pa, BUT, can't use a * and convert to a % - token try did not work) diff --git a/files.py b/files.py index 57bf753..b232249 100644 --- a/files.py +++ b/files.py @@ -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 diff --git a/templates/base.html b/templates/base.html index 96d98a6..ec8735c 100644 --- a/templates/base.html +++ b/templates/base.html @@ -29,7 +29,7 @@