🚑 Prevent duplicate substitutions
- Prevent duplication if two substitution plan files are the same
This commit is contained in:
@ -40,7 +40,17 @@ export class Parser {
|
||||
for (const plan of plans) {
|
||||
const foundPlan = dayPlans.find((e) => e.date == plan.date);
|
||||
if (!foundPlan) dayPlans.push(plan);
|
||||
else foundPlan.changes.push(...plan.changes);
|
||||
else {
|
||||
for (const change of plan.changes) {
|
||||
// Make sure to not insert the exact same substitution twice
|
||||
const changeExists = foundPlan.changes.find(
|
||||
(e) => JSON.stringify(e) == JSON.stringify(change),
|
||||
);
|
||||
if (!changeExists) {
|
||||
foundPlan.changes.push(change);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Insert substitutions of all substitution plans
|
||||
for (const plan of dayPlans) {
|
||||
|
Reference in New Issue
Block a user