rcarvalho-workless 1.0.2.12 → 1.0.2.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/workless/scalers/base.rb +13 -14
  2. metadata +2 -2
@@ -6,7 +6,7 @@ module Delayed
6
6
 
7
7
  class Base
8
8
  def self.jobs
9
- Delayed::Job.all(:conditions => { :failed_at => nil })
9
+ Delayed::Job.where(:failed_at => nil)
10
10
  end
11
11
 
12
12
  def self.scale_info= info
@@ -22,19 +22,18 @@ module Delayed
22
22
  end
23
23
 
24
24
  def self.calculate_num_workers
25
- if num_workers.class == Fixnum
26
- @@scale_info ||= {
27
- 0 => 1,
28
- 100 => 2,
29
- 500 => 3,
30
- 1000 => 4
31
- }
32
- scale_key = @@scale_info.keys.reverse.select{|v| v < num_workers }.first
33
- if scale_key.nil?
34
- return 0
35
- else
36
- return @@scale_info[scale_key]
37
- end
25
+ num_jobs = self.jobs.count
26
+ @@scale_info ||= {
27
+ 0 => 0,
28
+ 100 => 1,
29
+ 500 => 2,
30
+ 1000 => 3
31
+ }
32
+ scale_key = @@scale_info.keys.reverse.select{|v| v <= num_jobs }.first
33
+ if scale_key.nil?
34
+ return 0
35
+ else
36
+ return @@scale_info[scale_key]
38
37
  end
39
38
  end
40
39
  end
metadata CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 1
7
7
  - 0
8
8
  - 2
9
- - 12
10
- version: 1.0.2.12
9
+ - 13
10
+ version: 1.0.2.13
11
11
  platform: ruby
12
12
  authors:
13
13
  - lostboy