Skip to content

Commit 4cdb3f5

Browse files
committed
♻️ Refactor: remove newBase arg for createSeries
1 parent 97a7ca5 commit 4cdb3f5

File tree

5 files changed

+9
-29
lines changed

5 files changed

+9
-29
lines changed

packages/backend/src/event/services/recur/manager/recur.manager.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ export class RecurringEventManager {
4343
if (baseEvent && newBaseEvent && modifiedInstance) {
4444
return this.provider.updateSeriesWithSplit(
4545
baseEvent,
46-
newBaseEvent,
4746
modifiedInstance,
4847
);
4948
}

packages/backend/src/event/services/recur/providers/compass/compass.recur.provider.test.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -282,17 +282,9 @@ describe("Compass Recurring Event Provider", () => {
282282
eventId: originalBaseId,
283283
},
284284
};
285-
const newBase = createMockBaseEvent({
286-
user: setup.userId,
287-
title: "Team Sync - Updated",
288-
});
289285

290286
// Execute
291-
await provider.updateSeriesWithSplit(
292-
originalBase,
293-
newBase,
294-
modifiedInstance,
295-
);
287+
await provider.updateSeriesWithSplit(originalBase, modifiedInstance);
296288

297289
// Verify
298290
const storedEvents = await mongoService.event.find().toArray();

packages/backend/src/event/services/recur/providers/compass/compass.recur.provider.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,6 @@ export class CompassRecurringEventProvider implements RecurringEventProvider {
208208
);
209209
}
210210

211-
// Create a new base event starting from the modified instance with updated data
212-
const newBase: Schema_Event_Recur_Base = {
213-
...modifiedInstance,
214-
_id: new ObjectId().toString(),
215-
recurrence: {
216-
rule: originalBase.recurrence.rule,
217-
},
218-
};
219-
220211
// Update the original base event to end before the modified instance
221212
const untilDate =
222213
new Date(modifiedInstance.startDate)
@@ -235,14 +226,15 @@ export class CompassRecurringEventProvider implements RecurringEventProvider {
235226
},
236227
);
237228

238-
// Insert the new base event
239-
const newBaseWithRecurrence = {
240-
...newBase,
229+
// Create a new base event starting from the modified instance with updated data
230+
const newBase: Schema_Event_Recur_Base = {
231+
...modifiedInstance,
232+
_id: new ObjectId().toString(),
241233
recurrence: {
242234
rule: originalBase.recurrence.rule,
243235
},
244236
};
245-
await this.insertBaseEvent(newBaseWithRecurrence);
237+
await this.insertBaseEvent(newBase);
246238

247239
// Update all future instances to point to the new base event and have the modified data
248240
const { _id, recurrence, ...modifiedData } = modifiedInstance;
@@ -265,7 +257,6 @@ export class CompassRecurringEventProvider implements RecurringEventProvider {
265257

266258
async updateSeriesWithSplit(
267259
originalBase: Schema_Event_Recur_Base,
268-
newBase: Schema_Event_Recur_Base,
269260
modifiedInstance: Schema_Event_Recur_Instance,
270261
): Promise<{ modifiedCount: number }> {
271262
if (!modifiedInstance.startDate || !originalBase.recurrence?.rule) {

packages/backend/src/event/services/recur/providers/gcal/gcal.recur.provider.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,9 +384,8 @@ export class GCalRecurringEventProvider implements RecurringEventProvider {
384384

385385
async updateSeriesWithSplit(
386386
originalBase: Schema_Event,
387-
newBase: Schema_Event,
388387
modifiedInstance: Schema_Event,
389-
): Promise<{ matchedCount: number }> {
388+
): Promise<{ modifiedCount: number }> {
390389
// First update the original base event
391390
if (!originalBase.recurrence?.eventId) {
392391
throw error(
@@ -406,12 +405,12 @@ export class GCalRecurringEventProvider implements RecurringEventProvider {
406405
);
407406

408407
// Then insert the new base event
409-
await this.insertBaseEvent(newBase);
408+
// await this.insertBaseEvent(newBase);
410409

411410
// Finally update the modified instance
412411
await this.updateInstance(modifiedInstance);
413412

414-
return { matchedCount: 3 };
413+
return { modifiedCount: 3 };
415414
}
416415

417416
async updateEntireSeries(

packages/backend/src/event/services/recur/providers/recur.provider.interface.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ export interface RecurringEventProvider {
126126
*/
127127
updateSeriesWithSplit(
128128
originalBase: Schema_Event_Recur_Base,
129-
newBase: Schema_Event_Recur_Base,
130129
modifiedInstance: Schema_Event_Recur_Instance,
131130
): Promise<{ modifiedCount: number }>;
132131

0 commit comments

Comments
 (0)