remove duplicates from search results 0fixes BUG-70

This commit is contained in:
2021-10-10 21:46:13 +11:00
parent 8f4eb870bb
commit 91f0f10767
2 changed files with 18 additions and 2 deletions

1
BUGs
View File

@@ -5,4 +5,3 @@ BUG-61: in Fullscreen mode and next/prev dropped out of FS when calling /viewlis
-- only way to fix this, is for when we POST to viewlist, it returns json, and we never leave /view/X
-- then we can stay on-page, and stay in FS and then just call ViewImageOrVide()
BUG-69: when moving a directory (maybe files???) it creates new destination directory even if one exists... not sure what the os.replace, etc. does at that point???
BUG-70: when a dir is a match and a file is a match (common with our date-based matching), then we get 2 answers in the search

View File

@@ -246,7 +246,24 @@ def GetEntries( OPT ):
file_data=Entry.query.join(File).filter(Entry.name.ilike(f"%{search_term}%")).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(OPT.offset).limit(OPT.how_many).all()
dir_data=Entry.query.join(File).join(EntryDirLink).join(Dir).filter(Dir.rel_path.ilike(f"%{search_term}%")).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(OPT.offset).limit(OPT.how_many).all()
ai_data=Entry.query.join(File).join(FaceFileLink).join(Face).join(FaceRefimgLink).join(Refimg).join(PersonRefimgLink).join(Person).filter(Person.tag.ilike(f"%{search_term}%")).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(OPT.offset).limit(OPT.how_many).all()
all_entries = file_data + dir_data + ai_data
# remove any duplicates from combined data
all_entries = file_data
for d in dir_data:
add_it=1
for f in file_data:
if d.name == f.name:
add_it=0
break
if add_it:
all_entries = all_entries + d
for a in ai_data:
add_it=1
for f in file_data:
if a.name == f.name:
add_it=0
break
if add_it:
all_entries = all_entries + a
return all_entries
for path in OPT.paths: