From 5c2fb2245a97f93467b6b2b5f7e1f07f579b8939 Mon Sep 17 00:00:00 2001 From: Ben Beckford Date: Wed, 8 Jul 2026 03:05:44 -0700 Subject: [PATCH] feat(server): date workflow filter (#29040) --- packages/plugin-core/manifest.json | 92 ++++++++++++++++++++++++++++++ packages/plugin-core/src/index.ts | 23 ++++++++ 2 files changed, 115 insertions(+) diff --git a/packages/plugin-core/manifest.json b/packages/plugin-core/manifest.json index 3508a3ece9..ac0f2466e8 100644 --- a/packages/plugin-core/manifest.json +++ b/packages/plugin-core/manifest.json @@ -183,6 +183,98 @@ }, "uiHints": ["Filter"] }, + { + "name": "assetDateFilter", + "title": "Filter by date", + "description": "Filter assets by date taken", + "types": ["AssetV1"], + "schema": { + "type": "object", + "properties": { + "startDate": { + "type": "object", + "title": "Start date", + "description": "Earliest date of assets to include", + "properties": { + "day": { + "type": "number", + "title": "Day", + "description": "Day of the year to match", + "uiHint": { + "order": 1 + } + }, + "month": { + "type": "number", + "title": "Month", + "description": "Month of the year to match", + "uiHint": { + "order": 2 + } + }, + "year": { + "type": "number", + "title": "Year", + "description": "Year to match", + "uiHint": { + "order": 3 + } + } + }, + "uiHint": { + "order": 1 + }, + "required": ["day", "month", "year"] + }, + "endDate": { + "type": "object", + "title": "End date", + "description": "Latest date of assets to include", + "properties": { + "day": { + "type": "number", + "title": "Day", + "description": "Day of the year to match", + "uiHint": { + "order": 1 + } + }, + "month": { + "type": "number", + "title": "Month", + "description": "Month of the year to match", + "uiHint": { + "order": 2 + } + }, + "year": { + "type": "number", + "title": "Year", + "description": "Year to match", + "uiHint": { + "order": 3 + } + } + }, + "uiHint": { + "order": 2 + }, + "required": ["day", "month", "year"] + }, + "recurring": { + "type": "boolean", + "default": false, + "title": "Match recurring dates", + "description": "Allow any assets with matching months/days regardless of the year", + "uiHint": { + "order": 3 + } + } + }, + "required": ["recurring", "startDate", "endDate"] + }, + "uiHints": ["Filter"] + }, { "name": "assetTypeFilter", "title": "Filter by asset type", diff --git a/packages/plugin-core/src/index.ts b/packages/plugin-core/src/index.ts index 59279b4de6..fc6e94a872 100644 --- a/packages/plugin-core/src/index.ts +++ b/packages/plugin-core/src/index.ts @@ -124,6 +124,27 @@ const methods = wrapper({ return { workflow: { continue: earthDiameter * delta <= (config.coordinate?.radius ?? 0) } }; }, + assetDateFilter: ({ config, data }) => { + const assetDate = new Date(data.asset.localDateTime); + let startDate = new Date(config.startDate.year, config.startDate.month - 1, config.startDate.day); + let endDate = new Date(config.endDate.year, config.endDate.month - 1, config.endDate.day); + + if (config.recurring) { + startDate.setFullYear(assetDate.getFullYear()); + endDate.setFullYear(assetDate.getFullYear()); + + if (endDate < startDate) { + if (assetDate > endDate) { + endDate.setFullYear(endDate.getFullYear() + 1); + } else { + startDate.setFullYear(startDate.getFullYear() - 1); + } + } + } + + return { workflow: { continue: assetDate >= startDate && assetDate <= endDate } }; + }, + assetLock: ({ config, data }) => { if (!config.inverse && data.asset.visibility !== AssetVisibility.Locked) { return { changes: { asset: { visibility: AssetVisibility.Locked } } }; @@ -179,6 +200,7 @@ const { assetFavorite, assetFileFilter, assetLocationFilter, + assetDateFilter, assetLock, assetMissingTimeZoneFilter, assetTypeFilter, @@ -195,6 +217,7 @@ export { assetFavorite, assetFileFilter, assetLocationFilter, + assetDateFilter, assetLock, assetMissingTimeZoneFilter, assetTypeFilter,