Skip to content

Commit 7cc9d41

Browse files
committed
Search: Improve inline comments and annotations
1 parent d5b0b18 commit 7cc9d41

File tree

5 files changed

+54
-4
lines changed

5 files changed

+54
-4
lines changed

internal/entity/search/photos.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ func searchPhotos(frm form.SearchPhotos, sess *entity.Session, resultCols string
803803
s = s.Where("DATE(photos.taken_at) = DATE(?)", frm.Taken.UTC().Format("2006-01-02"))
804804
}
805805

806-
// Finds pictures taken on or before this date.
806+
// Finds pictures taken before this date.
807807
if !frm.Before.IsZero() {
808808
s = s.Where("photos.taken_at <= ?", frm.Before.UTC().Format("2006-01-02"))
809809
}

internal/entity/search/photos_geo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ func UserPhotosGeo(frm form.SearchPhotosGeo, sess *entity.Session) (results GeoR
691691
s = s.Where("DATE(photos.taken_at) = DATE(?)", frm.Taken.UTC().Format("2006-01-02"))
692692
}
693693

694-
// Finds pictures taken on or before this date.
694+
// Finds pictures taken before this date.
695695
if !frm.Before.IsZero() {
696696
s = s.Where("photos.taken_at <= ?", frm.Before.UTC().Format("2006-01-02"))
697697
}

internal/entity/search/photos_test.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package search
33
import (
44
"strconv"
55
"testing"
6+
"time"
67

78
"github.com/photoprism/photoprism/internal/entity/sortby"
89

@@ -737,6 +738,55 @@ func TestPhotos(t *testing.T) {
737738
}
738739
assert.LessOrEqual(t, 2, len(photos))
739740
})
741+
t.Run("FindContentCreatedBefore", func(t *testing.T) {
742+
var f form.SearchPhotos
743+
f.Query = "Before:1990-04-18"
744+
f.Count = 5000
745+
f.Offset = 0
746+
f.Merged = true
747+
f.Order = "newest"
748+
749+
photos, _, err := Photos(f)
750+
751+
if err != nil {
752+
t.Fatal(err)
753+
}
754+
assert.LessOrEqual(t, 1, len(photos))
755+
assert.Equal(t, time.Date(1990, 3, 2, 0, 0, 0, 0, time.UTC), photos[0].TakenAt)
756+
})
757+
t.Run("FindContentCreatedBefore", func(t *testing.T) {
758+
var f form.SearchPhotos
759+
f.Query = "Before:1990-04-19"
760+
f.Count = 5000
761+
f.Offset = 0
762+
f.Merged = true
763+
f.Order = "newest"
764+
765+
photos, _, err := Photos(f)
766+
767+
if err != nil {
768+
t.Fatal(err)
769+
}
770+
assert.LessOrEqual(t, 2, len(photos))
771+
assert.Equal(t, time.Date(1990, 4, 18, 1, 0, 0, 0, time.UTC), photos[0].TakenAt)
772+
})
773+
t.Run("FindContentCreatedOnORAfter", func(t *testing.T) {
774+
var f form.SearchPhotos
775+
f.Query = "After:1990-04-18"
776+
f.Count = 5000
777+
f.Offset = 0
778+
f.Merged = true
779+
f.Order = "oldest"
780+
781+
photos, _, err := Photos(f)
782+
783+
if err != nil {
784+
t.Fatal(err)
785+
}
786+
assert.LessOrEqual(t, 45, len(photos))
787+
assert.Equal(t, time.Date(1990, 4, 18, 1, 0, 0, 0, time.UTC), photos[0].TakenAt)
788+
789+
})
740790
t.Run("SearchForDiff", func(t *testing.T) {
741791
var f form.SearchPhotos
742792
f.Query = "Diff:800"

internal/form/search_photos.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ type SearchPhotos struct {
9393
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
9494
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
9595
Taken time.Time `form:"taken" time_format:"2006-01-02" notes:"Finds content created on the specified date"` // Pictures taken on the specified date
96-
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"
96+
Before time.Time `form:"before" time_format:"2006-01-02" notes:"Finds content created before this date"` // Pictures taken on or before this date"
9797
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
9898
Count int `form:"count" binding:"required" serialize:"-"` // Result FILE limit
9999
Offset int `form:"offset" serialize:"-"` // Result FILE offset

internal/form/search_photos_geo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type SearchPhotosGeo struct {
2525
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"`
2626
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"`
2727
Taken time.Time `form:"taken" time_format:"2006-01-02" notes:"Finds content created on the specified date"`
28-
Before time.Time `form:"before" time_format:"2006-01-02" notes:"Finds content created on or before this date"`
28+
Before time.Time `form:"before" time_format:"2006-01-02" notes:"Finds content created before this date"`
2929
After time.Time `form:"after" time_format:"2006-01-02" notes:"Finds content created on or after this date"`
3030
Favorite string `form:"favorite" example:"favorite:yes" notes:"Finds favorites only"`
3131
Unsorted bool `form:"unsorted" notes:"Finds content that is not in an album"`

0 commit comments

Comments
 (0)