Skip to content

Commit b0a8d61

Browse files
authored
Merge pull request #4 from raydak-labs/fix/quality-profile-merge
2 parents c58812e + e5f80ba commit b0a8d61

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

index.ts

+24-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,30 @@ const pipeline = async (value: YamlConfigInstance, arrType: ArrType) => {
6868
recylarrMergedTemplates.quality_profiles.push(...value.quality_profiles);
6969
}
7070

71-
// TODO "real" merge missing of profiles?
71+
const recyclarrProfilesMerged = recylarrMergedTemplates.quality_profiles.reduce<Map<string, YamlConfigQualityProfile>>((p, c) => {
72+
const profile = p.get(c.name);
73+
74+
if (profile == null) {
75+
p.set(c.name, c);
76+
} else {
77+
p.set(c.name, {
78+
...profile,
79+
...c,
80+
reset_unmatched_scores: {
81+
enabled: c.reset_unmatched_scores?.enabled ?? profile.reset_unmatched_scores?.enabled ?? true,
82+
except: c.reset_unmatched_scores?.except ?? profile.reset_unmatched_scores?.except,
83+
},
84+
upgrade: {
85+
...profile.upgrade,
86+
...c.upgrade,
87+
},
88+
});
89+
}
90+
91+
return p;
92+
}, new Map());
93+
94+
recylarrMergedTemplates.quality_profiles = Array.from(recyclarrProfilesMerged.values());
7295

7396
recylarrMergedTemplates.quality_profiles = filterInvalidQualityProfiles(recylarrMergedTemplates.quality_profiles);
7497

0 commit comments

Comments
 (0)