blaxter-delayed_job 2.1.4 → 2.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.4
1
+ 2.1.5
data/lib/delayed/job.rb CHANGED
@@ -95,15 +95,22 @@ module Delayed
95
95
  sql << ' AND name LIKE ?'
96
96
  conditions << "%#{options[:only_for]}%"
97
97
  end
98
+
99
+ if options[:unless]
100
+ sql << " AND (#{primary_key} NOT IN (?))"
101
+ conditions << options[:unless]
102
+ end
103
+
98
104
  conditions.unshift(sql)
99
105
  end
100
106
 
101
107
  # Find a few candidate jobs to run (in case some immediately get locked by others).
102
108
  # Return in random order prevent everyone trying to do same head job at once.
103
109
  def find_available(options = {})
104
- limit = options[:limit] || 5
110
+ find_opt = {:conditions => conditions_available(options), :order => NextTaskOrder}
111
+ find_opt[:limit] = options[:limit] if options[:limit]
105
112
  ActiveRecord::Base.silence do
106
- find :all, :conditions => conditions_available(options), :order => NextTaskOrder, :limit => limit
113
+ find :all, find_opt
107
114
  end
108
115
  end
109
116
 
@@ -87,6 +87,12 @@ module Delayed
87
87
  @jobs.size
88
88
  end
89
89
 
90
+ def jobs_ids_in_execution
91
+ ret = []
92
+ each_job_in_execution {|job| ret << job.id }
93
+ ret
94
+ end
95
+
90
96
  def kill_threads!
91
97
  each_job_in_execution do |job, started_at, thread|
92
98
  puts "Killing #{job.name}"
@@ -79,7 +79,7 @@ module Delayed
79
79
  end
80
80
 
81
81
  def jobs_to_execute
82
- Job.find_available constraints
82
+ Job.find_available constraints.merge(:unless => jobs_ids_in_execution)
83
83
  end
84
84
 
85
85
  def say(text)
@@ -138,7 +138,6 @@ module Delayed
138
138
  def constraints
139
139
  {:max_run_time => Job::MAX_RUN_TIME,
140
140
  :worker_name => name,
141
- :limit => 5,
142
141
  :min_priority => min_priority,
143
142
  :max_priority => max_priority,
144
143
  :only_for => only_for,
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blaxter-delayed_job
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
8
  - 1
9
- - 4
10
- version: 2.1.4
9
+ - 5
10
+ version: 2.1.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Tobias L\xC3\xBCtke"
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-10-19 00:00:00 +02:00
19
+ date: 2010-10-25 00:00:00 +02:00
20
20
  default_executable:
21
21
  dependencies: []
22
22