finalized reminder notification system migrations
This commit is contained in:
@@ -45,7 +45,7 @@ BEGIN
|
||||
SELECT id AS schedule_id, user_id AS user_id, start_time AS start_at
|
||||
FROM public.duty_schedules
|
||||
WHERE start_time BETWEEN now() + interval '15 minutes' - interval '30 seconds' AND now() + interval '15 minutes' + interval '30 seconds'
|
||||
AND status = 'active'
|
||||
AND status IN ('arrival', 'late')
|
||||
LOOP
|
||||
-- Skip if user already checked in for this duty (attendance_logs references duty_schedule_id)
|
||||
IF EXISTS (SELECT 1 FROM public.attendance_logs al WHERE al.duty_schedule_id = rec.schedule_id AND al.check_in_at IS NOT NULL) THEN
|
||||
@@ -62,7 +62,7 @@ BEGIN
|
||||
SELECT id AS schedule_id, user_id AS user_id, end_time AS end_at
|
||||
FROM public.duty_schedules
|
||||
WHERE end_time BETWEEN now() - interval '30 seconds' AND now() + interval '30 seconds'
|
||||
AND status = 'active'
|
||||
AND status IN ('arrival', 'late')
|
||||
LOOP
|
||||
INSERT INTO public.scheduled_notifications (schedule_id, user_id, notify_type, scheduled_for)
|
||||
VALUES (rec.schedule_id, rec.user_id, 'end', rec.end_at)
|
||||
|
||||
Reference in New Issue
Block a user