Sha256: 686901d0bc4c7182fa7de0cdc09339ab62070c3af3339ea1a844f92946d1edfc
Contents?: true
Size: 862 Bytes
Versions: 206
Compression:
Stored size: 862 Bytes
Contents
# frozen_string_literal: true module Motor module Alerts module Scheduler SCHEDULER_INTERVAL = 1.minute 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 Rails.logger.error(e) end end end end end
Version data entries
206 entries across 206 versions & 6 rubygems