Search: Add "scan:false" filter to find photos that are not scans #3589
Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
parent
cb9d601dfa
commit
be0fdc1774
7 changed files with 16 additions and 13 deletions
|
@ -31,7 +31,7 @@ type SearchPhotos struct {
|
|||
Photo bool `form:"photo" notes:"Finds only photos, no videos"`
|
||||
Raw bool `form:"raw" notes:"Finds pictures with RAW image file"`
|
||||
Live bool `form:"live" notes:"Finds Live Photos and short videos"`
|
||||
Scan bool `form:"scan" notes:"Finds scanned images and documents"`
|
||||
Scan string `form:"scan" example:"scan:true scan:false" notes:"Finds scanned photos and documents"`
|
||||
Panorama bool `form:"panorama" notes:"Finds pictures with an aspect ratio > 1.9:1"`
|
||||
Portrait bool `form:"portrait" notes:"Finds pictures in portrait format"`
|
||||
Landscape bool `form:"landscape" notes:"Finds pictures in landscape format"`
|
||||
|
|
|
@ -29,7 +29,7 @@ type SearchPhotosGeo struct {
|
|||
Photo bool `form:"photo"`
|
||||
Raw bool `form:"raw"`
|
||||
Live bool `form:"live"`
|
||||
Scan bool `form:"scan"`
|
||||
Scan string `form:"scan" example:"scan:true scan:false" notes:"Finds scanned photos and documents"`
|
||||
Panorama bool `form:"panorama"`
|
||||
Portrait bool `form:"portrait"`
|
||||
Landscape bool `form:"landscape"`
|
||||
|
|
|
@ -311,7 +311,7 @@ func TestParseQueryString(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
assert.True(t, form.Scan)
|
||||
assert.Equal(t, ";cat", form.Scan)
|
||||
})
|
||||
t.Run("query for panorama with uncommon bool value", func(t *testing.T) {
|
||||
form := &SearchPhotos{Query: "panorama:*cat"}
|
||||
|
|
|
@ -309,7 +309,7 @@ func searchPhotos(f form.SearchPhotos, sess *entity.Session, resultCols string)
|
|||
f.Panorama = true
|
||||
case terms["scans"]:
|
||||
f.Query = strings.ReplaceAll(f.Query, "scans", "")
|
||||
f.Scan = true
|
||||
f.Scan = "true"
|
||||
case terms["monochrome"]:
|
||||
f.Query = strings.ReplaceAll(f.Query, "monochrome", "")
|
||||
f.Mono = true
|
||||
|
@ -483,8 +483,10 @@ func searchPhotos(f form.SearchPhotos, sess *entity.Session, resultCols string)
|
|||
s = s.Where("photos.photo_favorite = 1")
|
||||
}
|
||||
|
||||
// Find scans only.
|
||||
if f.Scan {
|
||||
// Filter by scan flag.
|
||||
if txt.No(f.Scan) {
|
||||
s = s.Where("photos.photo_scan = 0")
|
||||
} else if txt.NotEmpty(f.Scan) {
|
||||
s = s.Where("photos.photo_scan = 1")
|
||||
}
|
||||
|
||||
|
|
|
@ -236,7 +236,7 @@ func UserPhotosGeo(f form.SearchPhotosGeo, sess *entity.Session) (results GeoRes
|
|||
f.Panorama = true
|
||||
case terms["scans"]:
|
||||
f.Query = strings.ReplaceAll(f.Query, "scans", "")
|
||||
f.Scan = true
|
||||
f.Scan = "true"
|
||||
case terms["monochrome"]:
|
||||
f.Query = strings.ReplaceAll(f.Query, "monochrome", "")
|
||||
f.Mono = true
|
||||
|
@ -391,8 +391,10 @@ func UserPhotosGeo(f form.SearchPhotosGeo, sess *entity.Session) (results GeoRes
|
|||
s = s.Where("photos.photo_favorite = 1")
|
||||
}
|
||||
|
||||
// Find scans only.
|
||||
if f.Scan {
|
||||
// Filter by scan flag.
|
||||
if txt.No(f.Scan) {
|
||||
s = s.Where("photos.photo_scan = 0")
|
||||
} else if txt.NotEmpty(f.Scan) {
|
||||
s = s.Where("photos.photo_scan = 1")
|
||||
}
|
||||
|
||||
|
|
|
@ -777,11 +777,10 @@ func TestGeo(t *testing.T) {
|
|||
|
||||
assert.Equal(t, len(photos5), len(photos4))
|
||||
})
|
||||
|
||||
t.Run("f.Scan = true", func(t *testing.T) {
|
||||
var frm form.SearchPhotosGeo
|
||||
|
||||
frm.Scan = true
|
||||
frm.Scan = "true"
|
||||
|
||||
photos, err := PhotosGeo(frm)
|
||||
|
||||
|
|
|
@ -919,7 +919,7 @@ func TestPhotos(t *testing.T) {
|
|||
t.Run("search with multiple parameters", func(t *testing.T) {
|
||||
var f form.SearchPhotos
|
||||
f.Hidden = true
|
||||
f.Scan = true
|
||||
f.Scan = "true"
|
||||
f.Year = "2010"
|
||||
f.Day = "1"
|
||||
f.Photo = true
|
||||
|
@ -939,7 +939,7 @@ func TestPhotos(t *testing.T) {
|
|||
t.Run("search with multiple parameters", func(t *testing.T) {
|
||||
var f form.SearchPhotos
|
||||
f.Hidden = true
|
||||
f.Scan = true
|
||||
f.Scan = "true"
|
||||
f.Year = strconv.Itoa(2010)
|
||||
f.Day = strconv.Itoa(1)
|
||||
f.Video = true
|
||||
|
|
Loading…
Reference in a new issue