From 8e9af7d6c41ab7eaa1eec4143dcef79077e7fdd7 Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Tue, 18 Mar 2025 00:42:40 +0100 Subject: [PATCH] Added date fallback configuration to summary templates, disabled by default. --- assets/summary.yaml | 1 + utils/process-summary-template.js | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/assets/summary.yaml b/assets/summary.yaml index debe0a9..b24c4fd 100644 --- a/assets/summary.yaml +++ b/assets/summary.yaml @@ -12,3 +12,4 @@ genders: fmtou - key: date format: yyyy-MM-dd + fallbackToAdded: false diff --git a/utils/process-summary-template.js b/utils/process-summary-template.js index a2f2960..d85ead6 100644 --- a/utils/process-summary-template.js +++ b/utils/process-summary-template.js @@ -40,7 +40,19 @@ const propProcessors = { }) .map((tag) => tag.name), movie: (sceneInfo) => sceneInfo.movies?.[0]?.title, - date: (sceneInfo, options) => (sceneInfo.effectiveDate ? format(sceneInfo.effectiveDate, options.format || 'yyyy-MM-dd') : ''), + date: (sceneInfo, options) => { + const dateFormat = options.format || 'yyyy-MM-dd'; + + if (sceneInfo.date) { + return format(sceneInfo.date, dateFormat); + } + + if (options.fallbackToAdded && sceneInfo.effectiveDate) { + return format(sceneInfo.effectiveDate, dateFormat); + } + + return ''; + }, }; function curateValue(value, item) {