Class: StatusCat::Checkers::DelayedJob
- Includes:
- ActionView::Helpers::DateHelper
- Defined in:
- lib/status_cat/checkers/delayed_job.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize ⇒ DelayedJob
constructor
A new instance of DelayedJob.
Methods inherited from Base
Constructor Details
#initialize ⇒ DelayedJob
Returns a new instance of DelayedJob.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/status_cat/checkers/delayed_job.rb', line 7 def initialize if !defined?( ::Delayed ) @status = 'delayed_job gem not installed' else @status = fail_on_exception do sql = 'select count(*) from delayed_jobs where failed_at is null' result = ::ActiveRecord::Base.connection.execute( sql ).first @value = result.is_a?( Hash ) ? result[ 'count' ] : result[ 0 ] expires = 1.day.ago sql = "select count(*) from delayed_jobs where created_at < '#{expires.to_s( :db )}' and failed_at is null" result = ::ActiveRecord::Base.connection.execute( sql ).first value = result.is_a?( Hash ) ? result[ 'count' ] : result[ 0 ] ( value.to_i == 0 ) ? nil : "#{value} jobs more than #{time_ago_in_words( expires )} old" end end end |