2019-03-26 15:32:20 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-09-16 16:44:29 +00:00
|
|
|
# Base para trabajos
|
2018-01-02 17:19:25 +00:00
|
|
|
class ApplicationJob < ActiveJob::Base
|
2023-03-28 23:21:52 +00:00
|
|
|
include Que::ActiveJob::JobExtensions
|
2020-05-30 19:43:25 +00:00
|
|
|
|
2024-03-25 16:32:08 +00:00
|
|
|
# Esperar una cantidad random de segundos primos, para que no se
|
|
|
|
# superpongan tareas
|
|
|
|
#
|
|
|
|
# @return [Array<ActiveSupport::Duration>]
|
|
|
|
RANDOM_WAIT = [3, 5, 7, 11, 13].seconds
|
|
|
|
|
|
|
|
# @return [ActiveSupport::Duration]
|
|
|
|
def self.random_wait
|
|
|
|
RANDOM_WAIT.sample
|
|
|
|
end
|
|
|
|
|
2020-05-30 19:43:25 +00:00
|
|
|
private
|
|
|
|
|
|
|
|
def site
|
|
|
|
@site ||= Site.find @params[:site_id]
|
|
|
|
end
|
2018-01-02 17:19:25 +00:00
|
|
|
end
|