Sha256: eabda1e1cc7581cd1d4cd97c577e1f9a90570c2be0471923403e85363b3c5fad
Contents?: true
Size: 864 Bytes
Versions: 25
Compression:
Stored size: 864 Bytes
Contents
# frozen_string_literal: true module Motor module Alerts module Scheduler SCHEDULER_INTERVAL = 10.seconds CHECK_BEHIND_DURATION = 15.minutes SCHEDULER_TASK = Concurrent::TimerTask.new( execution_interval: SCHEDULER_INTERVAL ) { Motor::Alerts::Scheduler.call } ALREADY_PROCESSED_CACHE = ActiveSupport::Cache::MemoryStore.new(size: 5.megabytes) module_function def call ScheduledAlertsCache.all.each do |alert| next unless (CHECK_BEHIND_DURATION.ago..Time.current).cover?(alert.cron.previous_time.to_local_time) ALREADY_PROCESSED_CACHE.fetch("#{alert.id}-#{alert.cron.previous_time.to_i}") do Motor::AlertSendingJob.perform_later(alert).job_id end rescue StandardError => e Rials.logger.error(e) end end end end end
Version data entries
25 entries across 25 versions & 1 rubygems