mirror of
https://github.com/photoprism/photoprism.git
synced 2025-12-12 00:34:13 +01:00
Search: Improve inline comments and annotations
This commit is contained in:
@@ -803,7 +803,7 @@ func searchPhotos(frm form.SearchPhotos, sess *entity.Session, resultCols string
|
||||
s = s.Where("DATE(photos.taken_at) = DATE(?)", frm.Taken.UTC().Format("2006-01-02"))
|
||||
}
|
||||
|
||||
// Finds pictures taken on or before this date.
|
||||
// Finds pictures taken before this date.
|
||||
if !frm.Before.IsZero() {
|
||||
s = s.Where("photos.taken_at <= ?", frm.Before.UTC().Format("2006-01-02"))
|
||||
}
|
||||
|
||||
@@ -691,7 +691,7 @@ func UserPhotosGeo(frm form.SearchPhotosGeo, sess *entity.Session) (results GeoR
|
||||
s = s.Where("DATE(photos.taken_at) = DATE(?)", frm.Taken.UTC().Format("2006-01-02"))
|
||||
}
|
||||
|
||||
// Finds pictures taken on or before this date.
|
||||
// Finds pictures taken before this date.
|
||||
if !frm.Before.IsZero() {
|
||||
s = s.Where("photos.taken_at <= ?", frm.Before.UTC().Format("2006-01-02"))
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package search
|
||||
import (
|
||||
"strconv"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/photoprism/photoprism/internal/entity/sortby"
|
||||
|
||||
@@ -737,6 +738,55 @@ func TestPhotos(t *testing.T) {
|
||||
}
|
||||
assert.LessOrEqual(t, 2, len(photos))
|
||||
})
|
||||
t.Run("FindContentCreatedBefore", func(t *testing.T) {
|
||||
var f form.SearchPhotos
|
||||
f.Query = "Before:1990-04-18"
|
||||
f.Count = 5000
|
||||
f.Offset = 0
|
||||
f.Merged = true
|
||||
f.Order = "newest"
|
||||
|
||||
photos, _, err := Photos(f)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assert.LessOrEqual(t, 1, len(photos))
|
||||
assert.Equal(t, time.Date(1990, 3, 2, 0, 0, 0, 0, time.UTC), photos[0].TakenAt)
|
||||
})
|
||||
t.Run("FindContentCreatedBefore", func(t *testing.T) {
|
||||
var f form.SearchPhotos
|
||||
f.Query = "Before:1990-04-19"
|
||||
f.Count = 5000
|
||||
f.Offset = 0
|
||||
f.Merged = true
|
||||
f.Order = "newest"
|
||||
|
||||
photos, _, err := Photos(f)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assert.LessOrEqual(t, 2, len(photos))
|
||||
assert.Equal(t, time.Date(1990, 4, 18, 1, 0, 0, 0, time.UTC), photos[0].TakenAt)
|
||||
})
|
||||
t.Run("FindContentCreatedOnORAfter", func(t *testing.T) {
|
||||
var f form.SearchPhotos
|
||||
f.Query = "After:1990-04-18"
|
||||
f.Count = 5000
|
||||
f.Offset = 0
|
||||
f.Merged = true
|
||||
f.Order = "oldest"
|
||||
|
||||
photos, _, err := Photos(f)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assert.LessOrEqual(t, 45, len(photos))
|
||||
assert.Equal(t, time.Date(1990, 4, 18, 1, 0, 0, 0, time.UTC), photos[0].TakenAt)
|
||||
|
||||
})
|
||||
t.Run("SearchForDiff", func(t *testing.T) {
|
||||
var f form.SearchPhotos
|
||||
f.Query = "Diff:800"
|
||||
|
||||
@@ -93,7 +93,7 @@ type SearchPhotos struct {
|
||||
Updated time.Time `form:"updated" example:"updated:\"2006-01-02T15:04:05Z\"" time_format:"2006-01-02T15:04:05Z07:00" notes:"Finds content updated at or after this time"` // Pictures updated at or after this time
|
||||
Edited time.Time `form:"edited" example:"edited:\"2006-01-02T15:04:05Z\"" time_format:"2006-01-02T15:04:05Z07:00" notes:"Finds content edited at or after this time"` // Pictures edited at or after this time
|
||||
Taken time.Time `form:"taken" time_format:"2006-01-02" notes:"Finds content created on the specified date"` // Pictures taken on the specified date
|
||||
Before time.Time `form:"before" time_format:"2006-01-02" notes:"Finds content created on or before this date"` // Pictures taken on or before this date"
|
||||
Before time.Time `form:"before" time_format:"2006-01-02" notes:"Finds content created before this date"` // Pictures taken on or before this date"
|
||||
After time.Time `form:"after" time_format:"2006-01-02" notes:"Finds content created on or after this date"` // Pictures taken on or after this date
|
||||
Count int `form:"count" binding:"required" serialize:"-"` // Result FILE limit
|
||||
Offset int `form:"offset" serialize:"-"` // Result FILE offset
|
||||
|
||||
@@ -25,7 +25,7 @@ type SearchPhotosGeo struct {
|
||||
Updated time.Time `form:"updated" example:"updated:\"2006-01-02T15:04:05Z\"" time_format:"2006-01-02T15:04:05Z07:00" notes:"Finds content updated at or after this time"`
|
||||
Edited time.Time `form:"edited" example:"edited:\"2006-01-02T15:04:05Z\"" time_format:"2006-01-02T15:04:05Z07:00" notes:"Finds content edited at or after this time"`
|
||||
Taken time.Time `form:"taken" time_format:"2006-01-02" notes:"Finds content created on the specified date"`
|
||||
Before time.Time `form:"before" time_format:"2006-01-02" notes:"Finds content created on or before this date"`
|
||||
Before time.Time `form:"before" time_format:"2006-01-02" notes:"Finds content created before this date"`
|
||||
After time.Time `form:"after" time_format:"2006-01-02" notes:"Finds content created on or after this date"`
|
||||
Favorite string `form:"favorite" example:"favorite:yes" notes:"Finds favorites only"`
|
||||
Unsorted bool `form:"unsorted" notes:"Finds content that is not in an album"`
|
||||
|
||||
Reference in New Issue
Block a user