From 18f7a999fd89b6247421d3de8976d1359013cd56 Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Wed, 3 Jun 2020 10:33:09 +0200 Subject: [PATCH] Backend: Add search filter for "original" file name #260 Signed-off-by: Michael Mayer --- internal/form/photo_search.go | 1 + internal/query/photo_search.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/internal/form/photo_search.go b/internal/form/photo_search.go index 87ad93b42..df4956149 100644 --- a/internal/form/photo_search.go +++ b/internal/form/photo_search.go @@ -13,6 +13,7 @@ type PhotoSearch struct { Path string `form:"path"` Folder string `form:"folder"` // Alias for Path Name string `form:"name"` + Original string `form:"original"` Title string `form:"title"` Hash string `form:"hash"` Video bool `form:"video"` diff --git a/internal/query/photo_search.go b/internal/query/photo_search.go index d2738683d..bcb089734 100644 --- a/internal/query/photo_search.go +++ b/internal/query/photo_search.go @@ -219,6 +219,10 @@ func PhotoSearch(f form.PhotoSearch) (results PhotoResults, count int, err error s = s.Where("photos.photo_name LIKE ?", strings.ReplaceAll(f.Name, "*", "%")) } + if f.Original != "" { + s = s.Where("photos.original_name LIKE ?", strings.ReplaceAll(f.Original, "*", "%")) + } + if f.Title != "" { s = s.Where("LOWER(photos.photo_title) LIKE ?", strings.ReplaceAll(strings.ToLower(f.Title), "*", "%")) }