Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion clients/javascript/tests/calendarEvent.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ describe('CalendarEvent API', () => {
expect(resEventTokyo.event).toBeDefined()
expect(resEventTokyo.event.calendarId).toBe(calendarTokyoId)
expect(resEventTokyo.event.recurringUntil).toEqual(
dayjs('2024-12-12T15:29:59.000Z').toDate() // 30 minutes after until
dayjs('2024-12-12T14:59:59.000Z').toDate()
)
expect(resEventTokyo.event.recurrence).toEqual(
expect.objectContaining({
Expand Down Expand Up @@ -528,11 +528,13 @@ describe('CalendarEvent API', () => {
const eventId = res.event.id

// Test updating recurrence
const until = new Date(3000).toISOString()
const res2 = await adminClient.events.update(eventId, {
recurrence: {
freq: 'weekly',
interval: 2,
count: 10,
until: until,
},
})

Expand All @@ -543,13 +545,16 @@ describe('CalendarEvent API', () => {
count: 10,
})
)
expect(dayjs(res2.event.recurrence?.until)).toEqual(dayjs(until))
expect(res2.event.recurringUntil).toEqual(dayjs(until).toDate())

// Test setting recurrence to NULL
const res3 = await adminClient.events.update(eventId, {
recurrence: null,
})

expect(res3.event.recurrence).toBeNull()
expect(res3.event.recurringUntil).toBeNull()
})

it('should handle recurring event fields', async () => {
Expand Down
2 changes: 2 additions & 0 deletions crates/api/src/event/update_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ impl UseCase for UpdateEventUseCase {
} else {
// Set to NULL
e.recurrence = None;
e.recurring_until = None;
true
}
// Otherwise, we we don't have a new recurrence, but we have an existing one
Expand All @@ -336,6 +337,7 @@ impl UseCase for UpdateEventUseCase {
})?
} else {
e.recurrence = None;
e.recurring_until = None;
true
}
} else {
Expand Down
5 changes: 1 addition & 4 deletions crates/domain/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,7 @@ impl CalendarEvent {
return Ok(false);
}

// Add duration to until if it is set
self.recurring_until = recurrence
.until
.map(|until| until + TimeDelta::milliseconds(self.duration));
self.recurring_until = recurrence.until;

// Set the recurrence
self.recurrence = Some(recurrence);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions crates/infra/src/repos/event/calendar_event/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ impl IEventRepo for PostgresEventRepo {
AND (
(e.start_time <= $2 AND e.end_time >= $3)
OR
(e.start_time < $2 AND e.recurrence_jsonb IS NOT NULL AND (e.recurring_until IS NULL OR e.recurring_until > $3))
(e.start_time < $2 AND e.recurrence_jsonb IS NOT NULL AND (e.recurring_until IS NULL OR e.recurring_until >= $3))
)
"#,
calendar_id.as_ref(),
Expand Down Expand Up @@ -680,7 +680,7 @@ impl IEventRepo for PostgresEventRepo {
AND (
(e.start_time <= $2 AND e.end_time >= $3)
OR
(e.start_time < $2 AND e.recurrence_jsonb IS NOT NULL AND (e.recurring_until IS NULL OR e.recurring_until > $3))
(e.start_time < $2 AND e.recurrence_jsonb IS NOT NULL AND (e.recurring_until IS NULL OR e.recurring_until >= $3))
)
"#,
&calendar_ids as &[Uuid],
Expand Down Expand Up @@ -852,7 +852,7 @@ impl IEventRepo for PostgresEventRepo {
AND (
(e.start_time < $2 AND e.end_time > $3)
OR
(e.start_time < $2 AND e.recurrence_jsonb IS NOT NULL AND (e.recurring_until IS NULL OR e.recurring_until > $3))
(e.start_time < $2 AND e.recurrence_jsonb IS NOT NULL AND (e.recurring_until IS NULL OR e.recurring_until >= $3))
)
AND busy = true
AND status = any($4::text[])
Expand Down