From e5f80bab3baae2cacbfbd7b66bf64cb63963430f Mon Sep 17 00:00:00 2001 From: Eduard Marbach Date: Tue, 2 Apr 2024 21:59:43 +0200 Subject: [PATCH] fix: merge quality profiles from template correctly --- index.ts | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/index.ts b/index.ts index 1f91efc..117db26 100644 --- a/index.ts +++ b/index.ts @@ -68,7 +68,30 @@ const pipeline = async (value: YamlConfigInstance, arrType: ArrType) => { recylarrMergedTemplates.quality_profiles.push(...value.quality_profiles); } - // TODO "real" merge missing of profiles? + const recyclarrProfilesMerged = recylarrMergedTemplates.quality_profiles.reduce>((p, c) => { + const profile = p.get(c.name); + + if (profile == null) { + p.set(c.name, c); + } else { + p.set(c.name, { + ...profile, + ...c, + reset_unmatched_scores: { + enabled: c.reset_unmatched_scores?.enabled ?? profile.reset_unmatched_scores?.enabled ?? true, + except: c.reset_unmatched_scores?.except ?? profile.reset_unmatched_scores?.except, + }, + upgrade: { + ...profile.upgrade, + ...c.upgrade, + }, + }); + } + + return p; + }, new Map()); + + recylarrMergedTemplates.quality_profiles = Array.from(recyclarrProfilesMerged.values()); recylarrMergedTemplates.quality_profiles = filterInvalidQualityProfiles(recylarrMergedTemplates.quality_profiles);