Module: Resque::History::Helper

Included in:
ResqueHistory::Server
Defined in:
lib/resque-history/helpers/helper.rb

Instance Method Summary collapse

Instance Method Details

#format_execution(seconds) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/resque-history/helpers/helper.rb', line 5

def format_execution(seconds)
  if seconds.nil?
    ""
  elsif seconds < 60
    "#{seconds} secs"
  elsif seconds < 60 * 60
    "#{(seconds/60).to_i} minutes"
  elsif seconds < 60 * 60 * 24
    "#{(((seconds.to_f/60/60)*100).truncate.to_f)/100} hours"
  elsif seconds < 60 * 60 * 24 * 7
    "#{(((seconds.to_f/60/60/24)*100).truncate.to_f)/100} days"
  else
    "too long"
  end
end

#resque_history_total_jobsObject



21
22
23
# File 'lib/resque-history/helpers/helper.rb', line 21

def resque_history_total_jobs
  Resque.redis.llen(Resque::Plugins::History::HISTORY_SET_NAME)
end