Conversation
Add support for FILTER_ALBUM_IDS, FILTER_TAKEN_AFTER, and FILTER_TAKEN_BEFORE environment variables to limit which assets are processed. Filters are displayed in startup summary logs
…iltering Add support for FILTER_ALBUM_IDS, FILTER_TAKEN_AFTER, and FILTER_TAKEN_BEFORE environment variables to limit which assets are processed. Filters are displayed in startup summary logs.
There was a problem hiding this comment.
Pull request overview
This PR implements filtering functionality to address issue #43, allowing users to filter assets by album (name or ID) and date range (before/after). This enables users to process specific subsets of their assets without needing to create separate user accounts or process all images.
Changes:
- Added three new filtering parameters: album IDs/names, taken-after date, and taken-before date
- Modified the asset fetching logic to apply filters via the Immich API's search/metadata endpoint
- Implemented album name resolution to UUIDs for user convenience
- Updated configuration and startup logging to display active filters
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/immich/client.go | Added filtering fields to Client struct, refactored FetchAssets to apply filters, implemented album name-to-UUID resolution and UUID validation |
| pkg/immich/client_test.go | Updated NewClient test calls to include new filter parameters |
| cmd/config.go | Added filter configuration variables and environment variable loading with startup logging |
| cmd/main.go | Added persistent flags for the three new filter options |
| cmd/stacker.go | Updated NewClient calls to pass filter parameters from configuration |
| cmd/fixtrash.go | Updated NewClient call with nil/empty filter parameters (filters not applicable) |
| cmd/duplicates.go | Updated NewClient call with nil/empty filter parameters (filters not applicable) |
| .gitignore | Added immich-openapi-specs.json to ignore list |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Trim whitespace from FILTER_ALBUM_IDS env var values - Trim whitespace from date filter env vars - Update flag description to mention "IDs or names" - Add date format validation with clear error messages - Improve comment explaining OR logic for multiple albums
- Add TestIsUUID with 13 test cases for UUID validation - Add TestResolveAlbumFilters with 8 test cases for album name resolution - Add TestFetchAssetsDateValidation with 10 test cases for RFC3339 validation - Add TestFetchAssetsWithAlbumFilters for album filter building (0/1/>1 cases) - Add TestFetchAssetsDeduplication for OR logic deduplication - Add TestFetchAssetsPagination for nextPage string parsing - Add TestFetchAssetsStackEnrichment for stack info enrichment - Add TestFetchAssetsAlbumResolutionError for error propagation - Add TestResolveAlbumFiltersAPIError for API error handling - Add TestNewClientWithFilterParams for filter param storage - Add TestFilterAlbumIDsParsing for env var whitespace handling - Add TestDateFilterEnvVarParsing for TrimSpace behavior - Add TestFilterFlagsBinding for CLI flag parsing - Update TestStartupConfigurationSummary with filter field tests - Add mockTransportSeq helper for multi-request test scenarios Coverage: FetchAssets 64.6% -> 100%, resolveAlbumFilters 95.8% -> 100%
- Add Asset Filtering section to environment-variables.md with FILTER_ALBUM_IDS, FILTER_TAKEN_AFTER, FILTER_TAKEN_BEFORE variables and usage examples - Add filter flags to cli-usage.md Stack Command Flags table - Add Asset Filtering examples section to cli-usage.md - Add Asset Filtering section to configuration.md with album and date examples - Update example configuration to include filter variables
Filter flags (--filter-album-ids, --filter-taken-after, --filter-taken-before) are PersistentFlags available to all subcommands but only apply to the main stacker command. Add warning when these flags are set on duplicates or fix-trash commands to prevent user confusion.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 13 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Move date format validation outside nested loops for efficiency - Add validation that takenAfter must be before takenBefore - Add album ID to debug log when fetching pages for specific albums - Add test cases for inverted and equal date validation
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Aim to fix #43 by adding filtering by:
Remaining: