Skip to content

Commit 75c02ee

Browse files
authored
fix: clear scheduled_at for non-Scheduled statuses (#123)
Co-authored-by: Flegma <Flegma@users.noreply.github.com>
1 parent 7d47452 commit 75c02ee

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

hasura/triggers/matches.sql

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,13 +314,17 @@ BEGIN
314314
END IF;
315315

316316
scheduled_at := COALESCE(NEW.scheduled_at);
317-
317+
318318
-- We need to correctly handle the cancels_at field, since matches open 15 minutes before the scheduled time.
319319
-- Therefore, cancels_at should be set relative to the scheduled time, not the current time.
320-
IF (scheduled_at IS NOT NULL AND scheduled_at < NOW()) THEN
320+
IF (scheduled_at IS NOT NULL AND scheduled_at < NOW() AND NEW.status = 'Scheduled') THEN
321321
NEW.scheduled_at = NOW();
322322
END IF;
323323

324+
IF NEW.status != 'Scheduled' THEN
325+
NEW.scheduled_at = null;
326+
END IF;
327+
324328
IF (NEW.status = 'WaitingForCheckIn' AND OLD.status != 'WaitingForCheckIn') THEN
325329
IF _auto_cancellation THEN
326330
NEW.cancels_at = COALESCE(scheduled_at, NOW()) + (_auto_cancel_duration)::interval;

0 commit comments

Comments
 (0)