Search: Remove obsolete "fmin" and "fmax" filters #3818
Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
parent
09f8a58404
commit
c2b56346b6
|
@ -51,43 +51,41 @@ type SearchPhotos struct {
|
|||
Alt string `form:"alt" example:"alt:300-500" notes:"GPS Altitude (m)"`
|
||||
Dist float64 `form:"dist" example:"dist:50" notes:"Distance to Position (km)"`
|
||||
Latlng string `form:"latlng" notes:"GPS Bounding Box (Lat N, Lng E, Lat S, Lng W)"`
|
||||
Fmin float32 `form:"fmin" notes:"F-number (min)"`
|
||||
Fmax float32 `form:"fmax" notes:"F-number (max)"`
|
||||
Camera string `form:"camera" example:"camera:canon" notes:"Camera Make/Model Name"` // Camera UID or name
|
||||
Lens string `form:"lens" example:"lens:ef24" notes:"Lens Make/Model Name"` // Lens UID or name
|
||||
Iso string `form:"iso" example:"iso:200-400" notes:"ISO Number (light sensitivity)"`
|
||||
Mm string `form:"mm" example:"mm:28-35" notes:"Focal Length (35mm equivalent)"`
|
||||
F string `form:"f" example:"f:2.8-4.5" notes:"Aperture (f-number)"`
|
||||
Color string `form:"color" example:"color:\"red|blue\"" notes:"Color Name (purple, magenta, pink, red, orange, gold, yellow, lime, green, teal, cyan, blue, brown, white, grey, black) (separate with |)"` // Main color
|
||||
Chroma int16 `form:"chroma" example:"chroma:70" notes:"Chroma (0-100)"`
|
||||
Diff uint32 `form:"diff" notes:"Differential Perceptual Hash (000000-FFFFFF)"`
|
||||
Mono bool `form:"mono" notes:"Finds pictures with few or no colors"`
|
||||
Diff uint32 `form:"diff" notes:"Differential Perceptual Hash (000000-FFFFFF)"`
|
||||
Geo string `form:"geo" example:"geo:yes" notes:"Finds pictures with or without coordinates"`
|
||||
Keywords string `form:"keywords" example:"keywords:\"sand&water\"" notes:"Keywords (combinable with & and |)"`
|
||||
Label string `form:"label" example:"label:cat|dog" notes:"Label Names (separate with |)"`
|
||||
Category string `form:"category" example:"category:airport" notes:"Location Category"`
|
||||
Country string `form:"country" example:"country:\"de|us\"" notes:"Location Country Code (separate with |)"` // Moments
|
||||
State string `form:"state" example:"state:\"Baden-Württemberg\"" notes:"Location State (separate with |)"` // Moments
|
||||
City string `form:"city" example:"city:\"Berlin\"" notes:"Location City (separate with |)"` // Moments
|
||||
Year string `form:"year" example:"year:1990|2003" notes:"Year (separate with |)"` // Moments
|
||||
Month string `form:"month" example:"month:7|10" notes:"Month (1-12, separate with |)"` // Moments
|
||||
Day string `form:"day" example:"day:3|13" notes:"Day of Month (1-31, separate with |)"` // Moments
|
||||
Face string `form:"face" example:"face:PN6QO5INYTUSAATOFL43LL2ABAV5ACZG" notes:"Face ID, yes, no, new, or kind"` // UIDs
|
||||
Faces string `form:"faces" example:"faces:yes faces:3" notes:"Minimum number of Faces (yes = 1)"` // Find or exclude faces if detected.
|
||||
Subject string `form:"subject" example:"subject:\"Jane Doe & John Doe\"" notes:"Alias for person"` // UIDs
|
||||
Person string `form:"person" example:"person:\"Jane Doe & John Doe\"" notes:"Subject Names, exact matches (combinable with & and |)"` // Alias for Subject
|
||||
Subjects string `form:"subjects" example:"subjects:\"Jane & John\"" notes:"Alias for people"` // People names
|
||||
People string `form:"people" example:"people:\"Jane & John\"" notes:"Subject Names (combinable with & and |)"` // Alias for Subjects
|
||||
Album string `form:"album" example:"album:berlin" notes:"Album UID or Name, supports * wildcards"` // Album UIDs or name
|
||||
Albums string `form:"albums" example:"albums:\"South Africa & Birds\"" notes:"Album Names (combinable with & and |)"` // Multi search with and/or
|
||||
Color string `form:"color" example:"color:\"red|blue\"" notes:"Color Name (purple, magenta, pink, red, orange, gold, yellow, lime, green, teal, cyan, blue, brown, white, grey, black) (separate with |)"` // Main color
|
||||
Quality int `form:"quality" notes:"Minimum quality score (1-7)"` // Photo quality score
|
||||
Review bool `form:"review" notes:"Finds pictures in review"` // Find photos in review
|
||||
Camera string `form:"camera" example:"camera:canon" notes:"Camera Make/Model Name"` // Camera UID or name
|
||||
Lens string `form:"lens" example:"lens:ef24" notes:"Lens Make/Model Name"` // Lens UID or name
|
||||
Iso string `form:"iso" example:"iso:200-400" notes:"ISO Number (light sensitivity)"`
|
||||
Mm string `form:"mm" example:"mm:28-35" notes:"Focal Length (35mm equivalent)"`
|
||||
F string `form:"f" example:"f:2.8-4.5" notes:"Aperture (f-number)"`
|
||||
Before time.Time `form:"before" time_format:"2006-01-02" notes:"Finds pictures taken before this date"` // Finds images taken before date
|
||||
After time.Time `form:"after" time_format:"2006-01-02" notes:"Finds pictures taken after this date"` // Finds images taken after date
|
||||
Count int `form:"count" binding:"required" serialize:"-"` // Result FILE limit
|
||||
Offset int `form:"offset" serialize:"-"` // Result FILE offset
|
||||
Order string `form:"order" serialize:"-"` // Sort order
|
||||
Merged bool `form:"merged" serialize:"-"` // Merge FILES in response
|
||||
Country string `form:"country" example:"country:\"de|us\"" notes:"Location Country Code (separate with |)"` // Moments
|
||||
State string `form:"state" example:"state:\"Baden-Württemberg\"" notes:"Location State (separate with |)"` // Moments
|
||||
City string `form:"city" example:"city:\"Berlin\"" notes:"Location City (separate with |)"` // Moments
|
||||
Year string `form:"year" example:"year:1990|2003" notes:"Year (separate with |)"` // Moments
|
||||
Month string `form:"month" example:"month:7|10" notes:"Month (1-12, separate with |)"` // Moments
|
||||
Day string `form:"day" example:"day:3|13" notes:"Day of Month (1-31, separate with |)"` // Moments
|
||||
Face string `form:"face" example:"face:PN6QO5INYTUSAATOFL43LL2ABAV5ACZG" notes:"Face ID, yes, no, new, or kind"` // UIDs
|
||||
Faces string `form:"faces" example:"faces:yes faces:3" notes:"Minimum number of Faces (yes = 1)"` // Find or exclude faces if detected.
|
||||
Subject string `form:"subject" example:"subject:\"Jane Doe & John Doe\"" notes:"Alias for person"` // UIDs
|
||||
Person string `form:"person" example:"person:\"Jane Doe & John Doe\"" notes:"Subject Names, exact matches (combinable with & and |)"` // Alias for Subject
|
||||
Subjects string `form:"subjects" example:"subjects:\"Jane & John\"" notes:"Alias for people"` // People names
|
||||
People string `form:"people" example:"people:\"Jane & John\"" notes:"Subject Names (combinable with & and |)"` // Alias for Subjects
|
||||
Album string `form:"album" example:"album:berlin" notes:"Album UID or Name, supports * wildcards"` // Album UIDs or name
|
||||
Albums string `form:"albums" example:"albums:\"South Africa & Birds\"" notes:"Album Names (combinable with & and |)"` // Multi search with and/or
|
||||
Quality int `form:"quality" notes:"Minimum quality score (1-7)"` // Photo quality score
|
||||
Review bool `form:"review" notes:"Finds pictures in review"` // Find photos in review
|
||||
Before time.Time `form:"before" time_format:"2006-01-02" notes:"Finds pictures taken before this date"` // Finds images taken before date
|
||||
After time.Time `form:"after" time_format:"2006-01-02" notes:"Finds pictures taken after this date"` // Finds images taken after date
|
||||
Count int `form:"count" binding:"required" serialize:"-"` // Result FILE limit
|
||||
Offset int `form:"offset" serialize:"-"` // Result FILE offset
|
||||
Order string `form:"order" serialize:"-"` // Sort order
|
||||
Merged bool `form:"merged" serialize:"-"` // Merge FILES in response
|
||||
}
|
||||
|
||||
func (f *SearchPhotos) GetQuery() string {
|
||||
|
|
|
@ -49,11 +49,17 @@ type SearchPhotosGeo struct {
|
|||
Alt string `form:"alt" example:"alt:300-500" notes:"GPS Altitude (m)"`
|
||||
Dist float64 `form:"dist" example:"dist:50" notes:"Distance to Position (km)"`
|
||||
Latlng string `form:"latlng" notes:"GPS Bounding Box (Lat N, Lng E, Lat S, Lng W)"`
|
||||
Camera int `form:"camera"`
|
||||
Lens int `form:"lens"`
|
||||
Iso string `form:"iso" example:"iso:200-400" notes:"ISO Number (light sensitivity)"`
|
||||
Mm string `form:"mm" example:"mm:28-35" notes:"Focal Length (35mm equivalent)"`
|
||||
F string `form:"f" example:"f:2.8-4.5" notes:"Aperture (f-number)"`
|
||||
Color string `form:"color"`
|
||||
Chroma int16 `form:"chroma" example:"chroma:70" notes:"Chroma (0-100)"`
|
||||
Mono bool `form:"mono" notes:"Finds pictures with few or no colors"`
|
||||
Person string `form:"person"` // Alias for Subject
|
||||
Subjects string `form:"subjects"` // Text
|
||||
People string `form:"people"` // Alias for Subjects
|
||||
Chroma int16 `form:"chroma" example:"chroma:70" notes:"Chroma (0-100)"`
|
||||
Mono bool `form:"mono" notes:"Finds pictures with few or no colors"`
|
||||
Keywords string `form:"keywords" example:"keywords:\"sand&water\"" notes:"Keywords (combinable with & and |)"`
|
||||
Label string `form:"label" example:"label:cat|dog" notes:"Label Names (separate with |)"`
|
||||
Category string `form:"category" example:"category:airport" notes:"Location Category"`
|
||||
|
@ -65,12 +71,6 @@ type SearchPhotosGeo struct {
|
|||
Year string `form:"year"` // Moments
|
||||
Month string `form:"month"` // Moments
|
||||
Day string `form:"day"` // Moments
|
||||
Color string `form:"color"`
|
||||
Camera int `form:"camera"`
|
||||
Lens int `form:"lens"`
|
||||
Iso string `form:"iso" example:"iso:200-400" notes:"ISO Number (light sensitivity)"`
|
||||
Mm string `form:"mm" example:"mm:28-35" notes:"Focal Length (35mm equivalent)"`
|
||||
F string `form:"f" example:"f:2.8-4.5" notes:"Aperture (f-number)"`
|
||||
Count int `form:"count" serialize:"-"`
|
||||
Offset int `form:"offset" serialize:"-"`
|
||||
}
|
||||
|
|
|
@ -544,31 +544,24 @@ func TestParseQueryString(t *testing.T) {
|
|||
|
||||
assert.Contains(t, err.Error(), "invalid syntax")
|
||||
})
|
||||
t.Run("query for fmin with invalid type", func(t *testing.T) {
|
||||
form := &SearchPhotos{Query: "fmin:=}cat{"}
|
||||
t.Run("query for f with invalid type", func(t *testing.T) {
|
||||
form := &SearchPhotos{Query: "f:=}cat{"}
|
||||
|
||||
err := form.ParseQueryString()
|
||||
|
||||
if err == nil {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// log.Debugf("%+v\n", form)
|
||||
|
||||
assert.Contains(t, err.Error(), "invalid syntax")
|
||||
})
|
||||
t.Run("query for fmax with invalid type", func(t *testing.T) {
|
||||
form := &SearchPhotos{Query: "fmax:ca#$t"}
|
||||
t.Run("query for f with invalid type", func(t *testing.T) {
|
||||
form := &SearchPhotos{Query: "f:ca#$t"}
|
||||
|
||||
err := form.ParseQueryString()
|
||||
|
||||
if err == nil {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// log.Debugf("%+v\n", form)
|
||||
|
||||
assert.Contains(t, err.Error(), "invalid syntax")
|
||||
})
|
||||
t.Run("query for chroma with invalid type", func(t *testing.T) {
|
||||
form := &SearchPhotos{Query: "chroma:&|cat"}
|
||||
|
|
|
@ -23,11 +23,10 @@ type TestForm struct {
|
|||
Lat float32 `form:"lat"`
|
||||
Lng float32 `form:"lng"`
|
||||
Dist uint `form:"dist"`
|
||||
Fmin float32 `form:"fmin"`
|
||||
Fmax float32 `form:"fmax"`
|
||||
Color string `form:"color"`
|
||||
Chroma int16 `form:"chroma"`
|
||||
Diff uint32 `form:"diff"`
|
||||
Mono bool `form:"mono"`
|
||||
Diff uint32 `form:"diff"`
|
||||
Portrait bool `form:"portrait"`
|
||||
Location bool `form:"location"`
|
||||
Album string `form:"album"`
|
||||
|
@ -35,7 +34,6 @@ type TestForm struct {
|
|||
Country string `form:"country"`
|
||||
Year int `form:"year"`
|
||||
Month int `form:"month"`
|
||||
Color string `form:"color"`
|
||||
Quality int `form:"quality"`
|
||||
Review bool `form:"review"`
|
||||
Camera int `form:"camera"`
|
||||
|
|
|
@ -529,6 +529,19 @@ func searchPhotos(f form.SearchPhotos, sess *entity.Session, resultCols string)
|
|||
s = s.Where("files.file_main_color IN (?)", SplitOr(strings.ToLower(f.Color)))
|
||||
}
|
||||
|
||||
// Filter by chroma.
|
||||
if f.Mono {
|
||||
s = s.Where("files.file_chroma = 0")
|
||||
} else if f.Chroma > 9 {
|
||||
s = s.Where("files.file_chroma > ?", f.Chroma)
|
||||
} else if f.Chroma > 0 {
|
||||
s = s.Where("files.file_chroma > 0 AND files.file_chroma <= ?", f.Chroma)
|
||||
}
|
||||
|
||||
if f.Diff != 0 {
|
||||
s = s.Where("files.file_diff = ?", f.Diff)
|
||||
}
|
||||
|
||||
// Filter by favorite flag.
|
||||
if txt.No(f.Favorite) {
|
||||
s = s.Where("photos.photo_favorite = 0")
|
||||
|
@ -652,27 +665,6 @@ func searchPhotos(f form.SearchPhotos, sess *entity.Session, resultCols string)
|
|||
s = s.Where("files.file_hash IN (?)", SplitOr(strings.ToLower(f.Hash)))
|
||||
}
|
||||
|
||||
// Filter by chroma.
|
||||
if f.Mono {
|
||||
s = s.Where("files.file_chroma = 0")
|
||||
} else if f.Chroma > 9 {
|
||||
s = s.Where("files.file_chroma > ?", f.Chroma)
|
||||
} else if f.Chroma > 0 {
|
||||
s = s.Where("files.file_chroma > 0 AND files.file_chroma <= ?", f.Chroma)
|
||||
}
|
||||
|
||||
if f.Diff != 0 {
|
||||
s = s.Where("files.file_diff = ?", f.Diff)
|
||||
}
|
||||
|
||||
if f.Fmin > 0 {
|
||||
s = s.Where("photos.photo_f_number >= ?", f.Fmin)
|
||||
}
|
||||
|
||||
if f.Fmax > 0 {
|
||||
s = s.Where("photos.photo_f_number <= ?", f.Fmax)
|
||||
}
|
||||
|
||||
// Filter by location code.
|
||||
if txt.NotEmpty(f.S2) {
|
||||
// S2 Cell ID.
|
||||
|
|
|
@ -442,6 +442,15 @@ func UserPhotosGeo(f form.SearchPhotosGeo, sess *entity.Session) (results GeoRes
|
|||
s = s.Where("files.file_main_color IN (?)", SplitOr(strings.ToLower(f.Color)))
|
||||
}
|
||||
|
||||
// Filter by chroma.
|
||||
if f.Mono {
|
||||
s = s.Where("files.file_chroma = 0")
|
||||
} else if f.Chroma > 9 {
|
||||
s = s.Where("files.file_chroma > ?", f.Chroma)
|
||||
} else if f.Chroma > 0 {
|
||||
s = s.Where("files.file_chroma > 0 AND files.file_chroma <= ?", f.Chroma)
|
||||
}
|
||||
|
||||
// Filter by favorite flag.
|
||||
if txt.No(f.Favorite) {
|
||||
s = s.Where("photos.photo_favorite = 0")
|
||||
|
@ -562,15 +571,6 @@ func UserPhotosGeo(f form.SearchPhotosGeo, sess *entity.Session) (results GeoRes
|
|||
}
|
||||
}
|
||||
|
||||
// Filter by chroma.
|
||||
if f.Mono {
|
||||
s = s.Where("files.file_chroma = 0")
|
||||
} else if f.Chroma > 9 {
|
||||
s = s.Where("files.file_chroma > ?", f.Chroma)
|
||||
} else if f.Chroma > 0 {
|
||||
s = s.Where("files.file_chroma > 0 AND files.file_chroma <= ?", f.Chroma)
|
||||
}
|
||||
|
||||
// Filter by location code.
|
||||
if txt.NotEmpty(f.S2) {
|
||||
// S2 Cell ID.
|
||||
|
|
|
@ -606,9 +606,9 @@ func TestPhotos(t *testing.T) {
|
|||
assert.LessOrEqual(t, 1, len(photos))
|
||||
|
||||
})
|
||||
t.Run("form.fmin", func(t *testing.T) {
|
||||
t.Run("form.f", func(t *testing.T) {
|
||||
var f form.SearchPhotos
|
||||
f.Query = "Fmin:5"
|
||||
f.Query = "F:5-100"
|
||||
f.Count = 10
|
||||
f.Offset = 0
|
||||
f.Order = "oldest"
|
||||
|
@ -621,9 +621,9 @@ func TestPhotos(t *testing.T) {
|
|||
|
||||
assert.LessOrEqual(t, 1, len(photos))
|
||||
})
|
||||
t.Run("form.fmax", func(t *testing.T) {
|
||||
t.Run("form.f", func(t *testing.T) {
|
||||
var f form.SearchPhotos
|
||||
f.Query = "Fmax:2"
|
||||
f.Query = "F:0-2"
|
||||
f.Count = 10
|
||||
f.Offset = 0
|
||||
f.Order = "newest"
|
||||
|
|
Loading…
Reference in a new issue