Backend: Add search filter for "original" file name #260

Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
Michael Mayer 2020-06-03 10:33:09 +02:00
parent 3542bc5d61
commit 18f7a999fd
2 changed files with 5 additions and 0 deletions

View file

@ -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"`

View file

@ -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), "*", "%"))
}