mirror of
https://github.com/immich-app/immich.git
synced 2026-06-12 11:01:45 -07:00
feat: date workflow filter
This commit is contained in:
@@ -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",
|
||||
|
||||
Vendored
+1
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user