Skip to content
Snippets Groups Projects
Commit 2bb009fa authored by Teal's avatar Teal
Browse files

fucking hell

parent e540db7f
Branches
No related tags found
No related merge requests found
...@@ -70,6 +70,6 @@ gem "icalendar", "~> 2.10" ...@@ -70,6 +70,6 @@ gem "icalendar", "~> 2.10"
gem "telegram-bot-ruby", "~> 2.0" gem "telegram-bot-ruby", "~> 2.0"
gem "crono", "~> 2.0" gem "crono", git: 'https://github.com/plashchynski/crono' #"~> 2.0"
gem "daemons", "~> 1.4" gem "daemons", "~> 1.4"
GIT
remote: https://github.com/plashchynski/crono
revision: 6bf1ec9cfd383265e5578e29c2a6cd706476ab91
specs:
crono (2.0.1)
rails (>= 5.2.8)
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
...@@ -96,9 +103,6 @@ GEM ...@@ -96,9 +103,6 @@ GEM
concurrent-ruby (1.2.3) concurrent-ruby (1.2.3)
connection_pool (2.4.1) connection_pool (2.4.1)
crass (1.0.6) crass (1.0.6)
crono (2.0.1)
rails (>= 5.2.8)
sprockets-rails
daemons (1.4.1) daemons (1.4.1)
date (3.3.4) date (3.3.4)
debug (1.9.2) debug (1.9.2)
...@@ -323,7 +327,7 @@ DEPENDENCIES ...@@ -323,7 +327,7 @@ DEPENDENCIES
bcrypt (~> 3.1.7) bcrypt (~> 3.1.7)
bootsnap bootsnap
capybara capybara
crono (~> 2.0) crono!
daemons (~> 1.4) daemons (~> 1.4)
debug debug
hotwire-rails (~> 0.1.3) hotwire-rails (~> 0.1.3)
......
...@@ -5,6 +5,7 @@ class TelegramGroupChatNotificationJob < NotificationJob ...@@ -5,6 +5,7 @@ class TelegramGroupChatNotificationJob < NotificationJob
def perform(**args) def perform(**args)
channel = NotificationChannel.find_by(name: 'telegram_group_chat') channel = NotificationChannel.find_by(name: 'telegram_group_chat')
Rails.logger.debug("TelegramGroupChatNotificationJob #{args.inspect}")
return unless channel&.data return unless channel&.data
token = channel.data['token'] token = channel.data['token']
return unless token return unless token
......
class TelegramNotifyUpcomingJob < ApplicationJob class TelegramNotifyUpcomingJob < ApplicationJob
queue_as :default queue_as :default
def perform(**args) def perform(args)
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| offset = args["offset"]
interval = args["interval"]
Session.scheduled.includes(:stage, :assignments).where(stage: { name: ["Stage 1", "Stage 2", "Standby"] }).where(starts_at: (Time.now + offset)..(Time.now + offset + interval)).order(:starts_at).each do |session|
puts session.inspect
assignees = session.assignments.map(&:user) assignees = session.assignments.map(&:user)
if assignees.length.positive? if assignees.length.positive?
notify_names = assignees.map { |a| a.telegram_username ? "@#{a.telegram_username}" : a.name } notify_names = assignees.map { |a| a.telegram_username ? "@#{a.telegram_username}" : a.name }
......
...@@ -14,5 +14,5 @@ ...@@ -14,5 +14,5 @@
# Crono.perform(TestJob).every 2.days, at: '15:30' # Crono.perform(TestJob).every 2.days, at: '15:30'
# #
Crono.perform(FetchConferenceDataJob, 'rp2024').every 5.minutes # Crono.perform(FetchConferenceDataJob, 'rp2024').every 5.minutes
Crono.perform(TelegramNotifyUpcomingJob, {offset: 15.minutes, interval: 1.minute}).every 1.minute Crono.perform(TelegramNotifyUpcomingJob, { offset: 15.minutes.to_i, interval: 1.minute.to_i }).every 1.minute
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment