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:22:27 +0530 |
| commit | dd7183e50cfe74871b5b8a8bc0f4ebd94461f0f3 (patch) | |
| tree | e829e7dee5fedd000702674883a3431258311ee5 /internal | |
| parent | bd8fab9ace7444d1b97a6df7b2d81ef981808a05 (diff) | |
| download | galleryd-feat/api.tar.xz galleryd-feat/api.zip | |
feat(gallery): add date range to gallery queriesfeat/api
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") +} |