Sha256: a4614c5c9facd779a54de9324b96b93152aa864a812f72c42c1126c9507fd41e
Contents?: true
Size: 863 Bytes
Versions: 9
Compression:
Stored size: 863 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.find_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
9 entries across 9 versions & 1 rubygems