From 95789e7a3dc6f49ae396c53a34874f3d1642433c Mon Sep 17 00:00:00 2001
From: Teal <git@teal.is>
Date: Mon, 27 May 2024 15:47:54 +0200
Subject: [PATCH] fix schedule for upcoming

---
 app/jobs/telegram_notify_upcoming_job.rb | 2 +-
 config/cronotab.rb                       | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/app/jobs/telegram_notify_upcoming_job.rb b/app/jobs/telegram_notify_upcoming_job.rb
index acd2c67..3c77039 100644
--- a/app/jobs/telegram_notify_upcoming_job.rb
+++ b/app/jobs/telegram_notify_upcoming_job.rb
@@ -2,7 +2,7 @@ class TelegramNotifyUpcomingJob < ApplicationJob
   queue_as :default
 
   def perform(**args)
-    Session.scheduled.includes(:stage, :assignments).where(stage: { name: ["Stage 1", "Stage 2", "Standby"] }).where(starts_at: Time.now..(Time.now + args[:interval])).order(:starts_at).each do |session|
+    Session.scheduled.includes(:stage, :assignments).where(stage: { name: ["Stage 1", "Stage 2", "Standby"] }).where(starts_at: (Time.now + args[:offset])..(Time.now + args[:offset] + args[:interval])).order(:starts_at).each do |session|
       assignees = session.assignments.map(&:user)
       if assignees.length.positive?
         notify_names = assignees.map { |a| a.telegram_username ? "@#{a.telegram_username}" : a.name }
diff --git a/config/cronotab.rb b/config/cronotab.rb
index 04bbfe1..a534585 100644
--- a/config/cronotab.rb
+++ b/config/cronotab.rb
@@ -15,4 +15,4 @@
 #
 
 Crono.perform(FetchConferenceDataJob, 'rp2024').every 5.minutes
-Crono.perform(TelegramNotifyUpcomingJob, interval: 15.minutes).every 15.minutes
+Crono.perform(TelegramNotifyUpcomingJob, offset: 15.minutes, interval: 1.minute).every 1.minute
-- 
GitLab