diff --git a/server/parser/index.js b/server/parser/index.js index 0f508db..3a1e448 100644 --- a/server/parser/index.js +++ b/server/parser/index.js @@ -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) {