feat: date workflow filter

This commit is contained in:
Ben Beckford
2026-06-11 13:48:39 -07:00
parent 1ce961fbb3
commit dcd86493fc
3 changed files with 94 additions and 0 deletions
+63
View File
@@ -183,6 +183,69 @@
},
"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": {
"month": {
"type": "number",
"title": "Month",
"description": "Month of the year to match"
},
"day": {
"type": "number",
"title": "Day",
"description": "Day of the year to match"
},
"year": {
"type": "number",
"title": "Year",
"description": "Year to match"
}
}
},
"endDate": {
"type": "object",
"title": "End date",
"description": "Latest date of assets to include",
"properties": {
"month": {
"type": "number",
"title": "Month",
"description": "Month of the year to match"
},
"day": {
"type": "number",
"title": "Day",
"description": "Day of the year to match"
},
"year": {
"type": "number",
"title": "Year",
"description": "Year to match"
}
}
},
"recurring": {
"type": "boolean",
"default": false,
"title": "Match recurring dates",
"description": "Allow any assets with matching months/days regardless of the year"
}
},
"required": ["recurring", "startDate", "endDate"]
},
"uiHints": ["Filter"]
},
{
"name": "filterFileType",
"title": "Filter by file type",
+1
View File
@@ -14,6 +14,7 @@ declare module 'main' {
export function assetFileFilter(): I32;
export function assetMissingTimeZoneFilter(): I32;
export function assetLocationFilter(): I32;
export function assetDateFilter(): I32;
// updates
export function assetFavorite(): I32;
+30
View File
@@ -95,6 +95,36 @@ export const assetLocationFilter = () => {
});
};
export const assetDateFilter = () => {
return wrapper<
WorkflowType.AssetV1,
{
startDate: { month: number; day: number; year: number };
endDate: { month: number; day: number; year: number };
recurring: boolean;
}
>(({ 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 } };
});
};
export const assetFavorite = () => {
return wrapper<WorkflowType.AssetV1, { inverse?: boolean }>(({ config, data }) => {
const target = config.inverse ? false : true;