Skip to content

Commit

Permalink
Merge pull request #4 from raydak-labs/fix/quality-profile-merge
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackDark authored Apr 2, 2024
2 parents c58812e + e5f80ba commit b0a8d61
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Map<string, YamlConfigQualityProfile>>((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);

Expand Down

0 comments on commit b0a8d61

Please sign in to comment.