schedules bug fix

This commit is contained in:
2026-03-28 21:03:12 -04:00
parent 12c4a154e5
commit 3bf01cba1f
2 changed files with 3 additions and 3 deletions

View File

@@ -377,9 +377,9 @@ router.delete('/:id', authMiddleware, async (req, res) => {
AND title=$2 AND start_at >= $3
`, [event.created_by, event.title, event.start_at]);
} else if (recurringScope === 'all' && event.recurrence_rule) {
// Delete every occurrence
// Delete present and future occurrences only — preserve past records
await exec(req.schema, `
DELETE FROM events WHERE created_by=$1 AND recurrence_rule IS NOT NULL AND title=$2
DELETE FROM events WHERE created_by=$1 AND recurrence_rule IS NOT NULL AND title=$2 AND end_at >= NOW()
`, [event.created_by, event.title]);
} else {
await exec(req.schema, 'DELETE FROM events WHERE id=$1', [req.params.id]);