From 564ebae16261f305f580f80ddf11046ecbc0f0db Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Mon, 31 Oct 2022 09:58:39 +0100 Subject: [PATCH] Albums: Ignore labels with zero probability when adding all labels #2821 Signed-off-by: Michael Mayer --- internal/query/file_selection.go | 4 ++-- internal/query/photo_selection.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/query/file_selection.go b/internal/query/file_selection.go index 962d395dd..1c894e0a2 100644 --- a/internal/query/file_selection.go +++ b/internal/query/file_selection.go @@ -115,8 +115,8 @@ func SelectedFiles(f form.Selection, o FileSelection) (results entity.Files, err SELECT b.path FROM folders a JOIN folders b ON b.path LIKE %s WHERE a.folder_uid IN (?)) OR photos.photo_uid IN (SELECT photo_uid FROM photos_albums WHERE hidden = 0 AND album_uid IN (?)) OR files.file_uid IN (SELECT file_uid FROM %s m WHERE m.subj_uid IN (?)) - OR photos.id IN (SELECT pl.photo_id FROM photos_labels pl JOIN labels l ON pl.label_id = l.id AND l.deleted_at IS NULL WHERE l.label_uid IN (?)) - OR photos.id IN (SELECT pl.photo_id FROM photos_labels pl JOIN categories c ON c.label_id = pl.label_id JOIN labels lc ON lc.id = c.category_id AND lc.deleted_at IS NULL WHERE lc.label_uid IN (?))`, + OR photos.id IN (SELECT pl.photo_id FROM photos_labels pl JOIN labels l ON pl.label_id = l.id AND pl.uncertainty < 100 AND l.deleted_at IS NULL WHERE l.label_uid IN (?)) + OR photos.id IN (SELECT pl.photo_id FROM photos_labels pl JOIN categories c ON c.label_id = pl.label_id AND pl.uncertainty < 100 JOIN labels lc ON lc.id = c.category_id AND lc.deleted_at IS NULL WHERE lc.label_uid IN (?))`, concat, entity.Marker{}.TableName()) // Build search query. diff --git a/internal/query/photo_selection.go b/internal/query/photo_selection.go index bb4c3ec46..6a7c34e31 100644 --- a/internal/query/photo_selection.go +++ b/internal/query/photo_selection.go @@ -40,8 +40,8 @@ func SelectedPhotos(f form.Selection) (results entity.Photos, err error) { SELECT b.path FROM folders a JOIN folders b ON b.path LIKE %s WHERE a.folder_uid IN (?)) OR photos.photo_uid IN (SELECT photo_uid FROM photos_albums WHERE hidden = 0 AND album_uid IN (?)) OR photos.id IN (SELECT f.photo_id FROM files f JOIN %s m ON f.file_uid = m.file_uid WHERE f.deleted_at IS NULL AND m.subj_uid IN (?)) - OR photos.id IN (SELECT pl.photo_id FROM photos_labels pl JOIN labels l ON pl.label_id = l.id AND l.deleted_at IS NULL WHERE l.label_uid IN (?)) - OR photos.id IN (SELECT pl.photo_id FROM photos_labels pl JOIN categories c ON c.label_id = pl.label_id JOIN labels lc ON lc.id = c.category_id AND lc.deleted_at IS NULL WHERE lc.label_uid IN (?))`, + OR photos.id IN (SELECT pl.photo_id FROM photos_labels pl JOIN labels l ON pl.label_id = l.id AND pl.uncertainty < 100 AND l.deleted_at IS NULL WHERE l.label_uid IN (?)) + OR photos.id IN (SELECT pl.photo_id FROM photos_labels pl JOIN categories c ON c.label_id = pl.label_id AND pl.uncertainty < 100 JOIN labels lc ON lc.id = c.category_id AND lc.deleted_at IS NULL WHERE lc.label_uid IN (?))`, concat, entity.Marker{}.TableName()) s := UnscopedDb().Table("photos").