fix issue where search was not saving prefs
This commit is contained in:
9
TODO
9
TODO
@@ -1,9 +1,10 @@
|
|||||||
## GENERAL
|
## GENERAL
|
||||||
|
|
||||||
* search allow noo
|
* search
|
||||||
- PREFS:
|
-- allow changes to noo (done, but not in prefs yet)
|
||||||
- allow default and choosing search noo
|
- PREFS:
|
||||||
- can't force fullscreen on page load, so remove it from prefs
|
- allow default and choosing search noo
|
||||||
|
- can't force fullscreen on page load, so remove it from prefs
|
||||||
-- also, does search of matching dirname give all entries of subdirs of subdirs, etc. (think not) -- maybe a TODO?
|
-- also, does search of matching dirname give all entries of subdirs of subdirs, etc. (think not) -- maybe a TODO?
|
||||||
|
|
||||||
* [DONE] order/ find face with largest size and at least show that as unmatched
|
* [DONE] order/ find face with largest size and at least show that as unmatched
|
||||||
|
|||||||
48
files.py
48
files.py
@@ -273,11 +273,6 @@ def GetEntriesInSearchView( OPT ):
|
|||||||
join=f"Entry.query.join(File).distinct().join(FaceFileLink).join(Face).join(FaceRefimgLink).join(Refimg).join(PersonRefimgLink).join(Person).filter(Person.tag.ilike('%{search_term}%'))"
|
join=f"Entry.query.join(File).distinct().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:
|
if 'AI:' in OPT.orig_search_term:
|
||||||
all_entries = eval( f"{join}.{OPT.order}.offset(OPT.offset).limit(OPT.how_many).all()")
|
all_entries = eval( f"{join}.{OPT.order}.offset(OPT.offset).limit(OPT.how_many).all()")
|
||||||
if OPT.last_eid == 0:
|
|
||||||
OPT.num_entries = eval( f"{join}.count()" )
|
|
||||||
last_entry = eval( f"{join}.{OPT.last_order}.limit(1).first()" )
|
|
||||||
if last_entry:
|
|
||||||
OPT.last_eid = last_entry.id
|
|
||||||
else:
|
else:
|
||||||
file_data=eval( f"Entry.query.join(File).filter(Entry.name.ilike('%{search_term}%')).{OPT.order}.offset({OPT.offset}).limit({OPT.how_many}).all()" )
|
file_data=eval( f"Entry.query.join(File).filter(Entry.name.ilike('%{search_term}%')).{OPT.order}.offset({OPT.offset}).limit({OPT.how_many}).all()" )
|
||||||
dir_data =eval( f"Entry.query.join(File).join(EntryDirLink).join(Dir).filter(Dir.rel_path.ilike('%{search_term}%')).{OPT.order}.offset({OPT.offset}).limit({OPT.how_many}).all()" )
|
dir_data =eval( f"Entry.query.join(File).join(EntryDirLink).join(Dir).filter(Dir.rel_path.ilike('%{search_term}%')).{OPT.order}.offset({OPT.offset}).limit({OPT.how_many}).all()" )
|
||||||
@@ -304,30 +299,33 @@ def GetEntriesInSearchView( OPT ):
|
|||||||
if add_it:
|
if add_it:
|
||||||
all_entries.append(a)
|
all_entries.append(a)
|
||||||
|
|
||||||
# for all searches first_entry is worked out when first_eid not set yet & offset is 0 and we have some entries
|
# 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):
|
if OPT.first_eid == 0 and OPT.offset == 0 and len(all_entries):
|
||||||
OPT.first_eid = all_entries[0].id
|
OPT.first_eid = all_entries[0].id
|
||||||
if OPT.last_eid == 0:
|
if OPT.last_eid == 0:
|
||||||
by_fname= f"select e.id from entry e where e.name ilike '%%{search_term}%%'"
|
by_fname= f"select e.id from entry e where e.name ilike '%%{search_term}%%'"
|
||||||
by_dirname=f"select e.id from entry e, entry_dir_link edl where edl.entry_id = e.id and edl.dir_eid in ( select d.eid from dir d where d.rel_path ilike '%%{search_term}%%' )"
|
by_dirname=f"select e.id from entry e, entry_dir_link edl where edl.entry_id = e.id and edl.dir_eid in ( select d.eid from dir d where d.rel_path ilike '%%{search_term}%%' )"
|
||||||
by_ai =f"select e.id from entry e, face_file_link ffl, face_refimg_link frl, person_refimg_link prl, person p where e.id = ffl.file_eid and frl.face_id = ffl.face_id and frl.refimg_id = prl.refimg_id and prl.person_id = p.id and p.tag ilike '%%{search_term}%%'"
|
by_ai =f"select e.id from entry e, face_file_link ffl, face_refimg_link frl, person_refimg_link prl, person p where e.id = ffl.file_eid and frl.face_id = ffl.face_id and frl.refimg_id = prl.refimg_id and prl.person_id = p.id and p.tag ilike '%%{search_term}%%'"
|
||||||
|
|
||||||
|
if 'AI:' in OPT.orig_search_term:
|
||||||
|
sel_no_order=f"select e.*, f.* from entry e, file f where e.id=f.eid and e.id in ( {by_ai} ) "
|
||||||
|
else:
|
||||||
sel_no_order=f"select e.*, f.* from entry e, file f where e.id=f.eid and e.id in ( {by_fname} union {by_dirname} union {by_ai} ) "
|
sel_no_order=f"select e.*, f.* from entry e, file f where e.id=f.eid and e.id in ( {by_fname} union {by_dirname} union {by_ai} ) "
|
||||||
|
|
||||||
#num_entries
|
#num_entries
|
||||||
num_e_sql = f"select count(1) from ( {by_fname} union {by_dirname} union {by_ai} ) as foo"
|
num_e_sql = f"select count(1) from ( {by_fname} union {by_dirname} union {by_ai} ) as foo"
|
||||||
num_e_result = db.engine.execute( num_e_sql )
|
num_e_result = db.engine.execute( num_e_sql )
|
||||||
for res in num_e_result:
|
for res in num_e_result:
|
||||||
OPT.num_entries=res.count
|
OPT.num_entries=res.count
|
||||||
|
|
||||||
last_entry_sql= f"{sel_no_order} order by {OPT.last_order_raw} limit 1"
|
last_entry_sql= f"{sel_no_order} order by {OPT.last_order_raw} limit 1"
|
||||||
last_entry=db.engine.execute( last_entry_sql )
|
last_entry=db.engine.execute( last_entry_sql )
|
||||||
# can only be 1 due to limit above
|
# can only be 1 due to limit above
|
||||||
for l in last_entry:
|
for l in last_entry:
|
||||||
OPT.last_eid = l.id
|
OPT.last_eid = l.id
|
||||||
# store first/last eid into prefs
|
# store first/last eid into prefs
|
||||||
pref=PA_UserState.query.filter(PA_UserState.pa_user_dn==current_user.dn,PA_UserState.path_type==OPT.path_type,PA_UserState.orig_ptype==OPT.orig_ptype,PA_UserState.orig_search_term==search_term).first()
|
pref=PA_UserState.query.filter(PA_UserState.pa_user_dn==current_user.dn,PA_UserState.path_type==OPT.path_type,PA_UserState.orig_ptype==OPT.orig_ptype,PA_UserState.orig_search_term==OPT.orig_search_term).first()
|
||||||
UpdatePref( pref, OPT )
|
UpdatePref( pref, OPT )
|
||||||
return all_entries
|
return all_entries
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|||||||
Reference in New Issue
Block a user