diff options
| author | Saiyed Shizain <saiyedshizain@gmail.com> | 2026-09-01 23:16:15 +0530 |
|---|---|---|
| committer | Saiyed Shizain <saiyedshizain@gmail.com> | 2026-09-01 23:16:15 +0530 |
| commit | 5a51d4a74b5a656a1b11c4636956abe23c975d17 (patch) | |
| tree | e829e7dee5fedd000702674883a3431258311ee5 /internal | |
| parent | 7c346191ca616d5aef20147c46fd45ee856477aa (diff) | |
| download | galleryd-5a51d4a74b5a656a1b11c4636956abe23c975d17.tar.xz galleryd-5a51d4a74b5a656a1b11c4636956abe23c975d17.zip | |
feat(gallery): add date range to gallery queries
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/gallery/query.go | 5 | ||||
| -rw-r--r-- | internal/gallery/query_photos_test.go | 50 |
2 files changed, 55 insertions, 0 deletions
diff --git a/internal/gallery/query.go b/internal/gallery/query.go index 346c25f..355aa2e 100644 --- a/internal/gallery/query.go +++ b/internal/gallery/query.go @@ -1,5 +1,7 @@ package gallery +import "time" + type SortField string const ( @@ -27,4 +29,7 @@ type Query struct { Extension string Search string + + From time.Time + To time.Time } diff --git a/internal/gallery/query_photos_test.go b/internal/gallery/query_photos_test.go index f38c237..e5ef560 100644 --- a/internal/gallery/query_photos_test.go +++ b/internal/gallery/query_photos_test.go @@ -409,3 +409,53 @@ func TestQueryPhotosFilterSearchSortThenPaginate(t *testing.T) { assertIDs(t, got, "5") } + +func TestQueryPhotosIgnoresDateRangesForNow(t *testing.T) { + photos := []Photo{ + { + ID: "old", + Metadata: metadata.Metadata{ + DateTaken: time.Date( + 2024, + 1, + 1, + 0, + 0, + 0, + 0, + time.UTC, + ), + }, + }, + { + ID: "new", + Metadata: metadata.Metadata{ + DateTaken: time.Date( + 2025, + 1, + 1, + 0, + 0, + 0, + 0, + time.UTC, + ), + }, + }, + } + + got := QueryPhotos(photos, Query{ + From: time.Date( + 2025, + 1, + 1, + 0, + 0, + 0, + 0, + time.UTC, + ), + }) + + assertIDs(t, got, "old", "new") +} |