From c7c08c1c32c31d4ebad763b997d5cdb397caacbc Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Tue, 19 Aug 2025 20:18:30 +1000 Subject: [PATCH] made AI: be literal, e.g. no wildcards to stop AI:kath matching AI:katherine, also removed unused fid var and commented out debugs --- files.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/files.py b/files.py index b232249..5614711 100644 --- a/files.py +++ b/files.py @@ -238,7 +238,9 @@ def GetEntriesInSearchView( OPT ): 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}%'))" + join=f"Entry.query.join(File).join(FaceFileLink).join(Face).join(FaceRefimgLink).join(Refimg).join(PersonRefimgLink).join(Person).filter(Person.tag == search_term)" + else: + join=f"Entry.query.join(File).join(FaceFileLink).join(Face).join(FaceRefimgLink).join(Refimg).join(PersonRefimgLink).join(Person).filter(Person.tag.ilike('%{search_term}%'))" if 'AI:' in OPT.orig_search_term: all_entries = eval( f"{join}.{OPT.order}.offset(OPT.offset).limit(OPT.how_many).all()") else: @@ -448,7 +450,10 @@ def files_rbp(): @app.route("/search/", methods=["GET", "POST"]) @login_required def search(search_term): + print( f"req={request}" ) OPT=States( request ) + print( f"OPT={OPT}" ) + # if we posted to get here, its a change in State, so save it to pa_user_state, and go back to the GET version or URL if request.method=="POST": redirect("/search/"+search_term) @@ -620,7 +625,6 @@ def view_list(): resp['objs'][e.id]['faces'] = [] # put face data back into array format (for js processing) - fid=0 for face in e.file_details.faces: fd= {} fd['x'] = face.face_left @@ -628,10 +632,10 @@ def view_list(): fd['w'] = face.w fd['h'] = face.h if face.refimg: + fd['pid'] = face.refimg.person.id fd['who'] = face.refimg.person.tag fd['distance'] = round(face.refimg_lnk.face_distance,2) resp['objs'][e.id]['faces'].append(fd) - fid+=1 eids=eids.rstrip(",") lst = eids.split(',') @@ -648,12 +652,12 @@ def view_list(): resp['last_eid']=OPT.last_eid resp['eids']=eids resp['offset']=OPT.offset - print( f"BUG-DEBUG: /view_list route #1 - OPT={OPT}, eids={eids} ") +# print( f"BUG-DEBUG: /view_list route #1 - OPT={OPT}, eids={eids} ") # save pref to keep the new current value, first/last pref=PA_UserState.query.filter(PA_UserState.pa_user_dn==current_user.dn,PA_UserState.orig_ptype==OPT.orig_ptype,PA_UserState.view_eid==OPT.view_eid).first() - print( f"BUG-DEBUG: /view_list route #2 - OPT={OPT}, eids={eids} ") +# print( f"BUG-DEBUG: /view_list route #2 - OPT={OPT}, eids={eids} ") UpdatePref( pref, OPT ) - print( f"BUG-DEBUG: /view_list route #3 - OPT={OPT}, eids={eids} ") +# print( f"BUG-DEBUG: /view_list route #3 - OPT={OPT}, eids={eids} ") return make_response( resp ) @@ -701,7 +705,7 @@ def view(id): imp_path = setting.import_path st_path = setting.storage_path bin_path = setting.recycle_bin_path - print( f"BUG-DEBUG: /view/id GET route - OPT={OPT}, eids={eids}, current={int(id)} ") +# print( f"BUG-DEBUG: /view/id GET route - OPT={OPT}, eids={eids}, current={int(id)} ") return render_template("viewer.html", current=int(id), eids=eids, objs=objs, OPT=OPT, NMO_data=NMO_data, imp_path=imp_path, st_path=st_path, bin_path=bin_path ) ################################################################################## @@ -712,7 +716,7 @@ def view(id): def view_img_post(id): # set pa_user_states... OPT=States( request ) - print( f"BUG-DEBUG: /view/id POST route - OPT={OPT}, id={id} ") +# print( f"BUG-DEBUG: /view/id POST route - OPT={OPT}, id={id} ") # then use back-button friendly URL (and use pa_user_states to view the right image in the right list return redirect( "/view/" + id );