From 7578221f92f9a3c3cc1ac71735e7ddb170dde939 Mon Sep 17 00:00:00 2001 From: RanXom Date: Wed, 22 Jul 2026 18:04:22 +0530 Subject: feat(gallery): add extension filter to queries --- internal/gallery/query_photos_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'internal/gallery/query_photos_test.go') diff --git a/internal/gallery/query_photos_test.go b/internal/gallery/query_photos_test.go index c9bb986..05dab67 100644 --- a/internal/gallery/query_photos_test.go +++ b/internal/gallery/query_photos_test.go @@ -250,3 +250,13 @@ func TestQueryPhotosSortByDateDescending(t *testing.T) { assertIDs(t, got, "new", "mid", "old") } + +func TestQueryPhotosIgnoresExtensionFilteringForNow(t *testing.T) { + photos := makePhotos(3) + + got := QueryPhotos(photos, Query{ + Extension: "jpg", + }) + + assertIDs(t, got, "0", "1", "2") +} -- cgit v1.2.3 From 8fb30a66a81a1f7150ebe86ed091e7c1651233a1 Mon Sep 17 00:00:00 2001 From: RanXom Date: Wed, 22 Jul 2026 18:20:15 +0530 Subject: feat(gallery): filter photos by extension --- internal/gallery/query_photos_test.go | 57 +++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 3 deletions(-) (limited to 'internal/gallery/query_photos_test.go') diff --git a/internal/gallery/query_photos_test.go b/internal/gallery/query_photos_test.go index 05dab67..b72b6ec 100644 --- a/internal/gallery/query_photos_test.go +++ b/internal/gallery/query_photos_test.go @@ -251,12 +251,63 @@ func TestQueryPhotosSortByDateDescending(t *testing.T) { assertIDs(t, got, "new", "mid", "old") } -func TestQueryPhotosIgnoresExtensionFilteringForNow(t *testing.T) { - photos := makePhotos(3) +func TestQueryPhotosFilterByExtension(t *testing.T) { + photos := []Photo{ + { + ID: "jpg", + File: scanner.File{ + RelativePath: "photo.jpg", + }, + }, + { + ID: "png", + File: scanner.File{ + RelativePath: "photo.png", + }, + }, + { + ID: "jpg2", + File: scanner.File{ + RelativePath: "anotherphoto.jpg", + }, + }, + } + + got := QueryPhotos(photos, Query{ + Extension: "jpg", + }) + + assertIDs(t, got, "jpg", "jpg2") +} + +func TestQueryPhotosFilterThenSortThenPaginate(t *testing.T) { + photos := []Photo{ + { + ID: "1", + File: scanner.File{ + RelativePath: "a.png", + }, + }, + { + ID: "2", + File: scanner.File{ + RelativePath: "c.jpg", + }, + }, + { + ID: "3", + File: scanner.File{ + RelativePath: "a.jpg", + }, + }, + } got := QueryPhotos(photos, Query{ Extension: "jpg", + Sort: SortByPath, + Order: SortAsc, + Limit: 1, }) - assertIDs(t, got, "0", "1", "2") + assertIDs(t, got, "3") } -- cgit v1.2.3 From 2ca59223f20029a3a4a351b22706b2b4d47ad6e3 Mon Sep 17 00:00:00 2001 From: Saiyed Shizain Date: Tue, 25 Aug 2026 19:34:09 +0530 Subject: feat(gallery): add search query to gallery queries --- internal/gallery/query_photos_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'internal/gallery/query_photos_test.go') diff --git a/internal/gallery/query_photos_test.go b/internal/gallery/query_photos_test.go index b72b6ec..b60cfea 100644 --- a/internal/gallery/query_photos_test.go +++ b/internal/gallery/query_photos_test.go @@ -311,3 +311,13 @@ func TestQueryPhotosFilterThenSortThenPaginate(t *testing.T) { assertIDs(t, got, "3") } + +func TestQueryPhotosIgnoreSearchForNow(t *testing.T) { + photos := makePhotos(3) + + got := QueryPhotos(photos, Query{ + Search: "vacation", + }) + + assertIDs(t, got, "0", "1", "2") +} -- cgit v1.2.3 From 6792c6f697db94012adca1c56d6b032d71d00665 Mon Sep 17 00:00:00 2001 From: Saiyed Shizain Date: Wed, 26 Aug 2026 16:46:29 +0530 Subject: feat(gallery): search photos by relative path --- internal/gallery/query_photos_test.go | 48 ++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-) (limited to 'internal/gallery/query_photos_test.go') diff --git a/internal/gallery/query_photos_test.go b/internal/gallery/query_photos_test.go index b60cfea..c5d9376 100644 --- a/internal/gallery/query_photos_test.go +++ b/internal/gallery/query_photos_test.go @@ -312,12 +312,54 @@ func TestQueryPhotosFilterThenSortThenPaginate(t *testing.T) { assertIDs(t, got, "3") } -func TestQueryPhotosIgnoreSearchForNow(t *testing.T) { - photos := makePhotos(3) +func TestQueryPhotosSearchByRelativePath(t *testing.T) { + photos := []Photo{ + { + ID: "vacation", + File: scanner.File{ + RelativePath: "photos/vacation/beach.jpg", + }, + }, + { + ID: "work", + File: scanner.File{ + RelativePath: "photos/work/meeting.jpg", + }, + }, + { + ID: "vacation2", + File: scanner.File{ + RelativePath: "photos/vacation/mountains.jpg", + }, + }, + } got := QueryPhotos(photos, Query{ Search: "vacation", }) - assertIDs(t, got, "0", "1", "2") + assertIDs(t, got, "vacation", "vacation2") +} + +func TestQueryPhotosSearchIsCaseInsensitive(t *testing.T) { + photos := []Photo{ + { + ID: "1", + File: scanner.File{ + RelativePath: "Photos/Vacation/Beach.jpg", + }, + }, + { + ID: "2", + File: scanner.File{ + RelativePath: "photos/work/meeting.jpg", + }, + }, + } + + got := QueryPhotos(photos, Query{ + Search: "VACATION", + }) + + assertIDs(t, got, "1") } -- cgit v1.2.3 From bd8fab9ace7444d1b97a6df7b2d81ef981808a05 Mon Sep 17 00:00:00 2001 From: Saiyed Shizain Date: Wed, 26 Aug 2026 16:53:33 +0530 Subject: test(gallery): cover combined query pipeline --- internal/gallery/query_photos_test.go | 46 +++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'internal/gallery/query_photos_test.go') diff --git a/internal/gallery/query_photos_test.go b/internal/gallery/query_photos_test.go index c5d9376..f38c237 100644 --- a/internal/gallery/query_photos_test.go +++ b/internal/gallery/query_photos_test.go @@ -363,3 +363,49 @@ func TestQueryPhotosSearchIsCaseInsensitive(t *testing.T) { assertIDs(t, got, "1") } + +func TestQueryPhotosFilterSearchSortThenPaginate(t *testing.T) { + photos := []Photo{ + { + ID: "1", + File: scanner.File{ + RelativePath: "photos/work/report.jpg", + }, + }, + { + ID: "2", + File: scanner.File{ + RelativePath: "photos/vacation/zebra.jpg", + }, + }, + { + ID: "3", + File: scanner.File{ + RelativePath: "photos/vacation/apple.jpg", + }, + }, + { + ID: "4", + File: scanner.File{ + RelativePath: "photos/vacation/beach.png", + }, + }, + { + ID: "5", + File: scanner.File{ + RelativePath: "photos/vacation/mountains.jpg", + }, + }, + } + + got := QueryPhotos(photos, Query{ + Extension: "jpg", + Search: "vacation", + Sort: SortByPath, + Order: SortAsc, + Offset: 1, + Limit: 1, + }) + + assertIDs(t, got, "5") +} -- cgit v1.2.3