Module: HireFire::Macro::Delayed::Job
Instance Method Summary collapse
-
#queue(*queues) ⇒ Integer
Determines whether ‘ActiveRecord (3)` or `Mongoid` is being used.
Instance Method Details
#queue(*queues) ⇒ Integer
Determines whether ‘ActiveRecord (3)` or `Mongoid` is being used. Once determined, it will build the appropriate query criteria in order to count the amount of jobs in a given queue and return the result.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/hirefire/macro/delayed_job.rb', line 21 def queue(*queues) queues.flatten! if defined?(Mongoid) c = ::Delayed::Job c = c.where(:failed_at => nil) c = c.where(:run_at.lte => Time.now.utc) c = c.where(:queue.in => queues) unless queues.empty? c.count elsif defined?(ActiveRecord) c = ::Delayed::Job c = c.where(:failed_at => nil) c = c.where("run_at <= ?", Time.now.utc) c = c.where(:queue => queues) unless queues.empty? c.count else raise "HireFire could not detect ActiveRecord or Mongoid for HireFire::Macro::Delayed::Job." end end |