job_boss 0.6.5 → 0.6.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -86,10 +86,10 @@ job_boss also makes it easy to wait for the jobs to be done and to collect the r
86
86
 
87
87
  batch.result_hash # => {[0]=>false, [1]=>false, [2]=>true, [3]=>true, [4]=>false, ... }
88
88
 
89
- You can even define a block to provide updates on progress (the value which is passed into the block is a float between 0.0 and 100.0):
89
+ You can even define a block to provide updates on progress (the value which is passed into the block is a float between 0.0 and 1.0):
90
90
 
91
91
  batch.wait_for_jobs do |progress|
92
- puts "We're now at #{progress}%"
92
+ puts "We're now at #{progress * 100}%"
93
93
  end
94
94
 
95
95
  For performance, it is recommended that you keep your jobs table clean scheduling execution of the `delete_jobs_before` command on the Job model, which will clean all jobs completed before the specified time:
data/job_boss.gemspec CHANGED
@@ -4,7 +4,7 @@ $:.unshift lib unless $:.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "job_boss"
7
- s.version = '0.6.5'
7
+ s.version = '0.6.6'
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["Brian Underwood"]
10
10
  s.email = ["ml+job_boss@semi-sentient.com"]
@@ -14,6 +14,15 @@ module JobBoss
14
14
  end
15
15
  memoize :queue
16
16
 
17
+ # Used to queue jobs in a batch
18
+ # Usage:
19
+ # batch.queue_path('math#in_prime?', 42)
20
+ def queue_path(path, *args)
21
+ controller, action = path.split('#')
22
+
23
+ queue.send(controller).send(action, *args)
24
+ end
25
+
17
26
  def initialize(batch_id = nil)
18
27
  @batch_id = batch_id || Batch.generate_batch_id
19
28
  end
data/lib/job_boss/boss.rb CHANGED
@@ -94,7 +94,7 @@ module JobBoss
94
94
 
95
95
  # Go through each pending path / batch so that we don't get stuck just processing
96
96
  # long running jobs which would leave quicker jobs to suffocate
97
- Job.pending.select('DISTINCT path, batch_id').each do |distinct_job|
97
+ Job.unscoped.pending.select('DISTINCT path, batch_id').each do |distinct_job|
98
98
  job = Job.pending.order('id').find_by_path_and_batch_id(distinct_job.path, distinct_job.batch_id)
99
99
  next if job.nil?
100
100
 
@@ -146,6 +146,8 @@ class DaemonTest < ActiveSupport::TestCase
146
146
  end
147
147
  assert_equal 0.0, batch.completed_percent
148
148
 
149
+ assert_equal batch.batch_id, jobs.first.batch.batch_id
150
+
149
151
  batch.wait_for_jobs
150
152
 
151
153
  batch.result_hash.each do |args, result|
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: job_boss
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 6
9
- - 5
10
- version: 0.6.5
8
+ - 6
9
+ version: 0.6.6
11
10
  platform: ruby
12
11
  authors:
13
12
  - Brian Underwood
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2011-01-06 00:00:00 -05:00
17
+ date: 2011-01-13 00:00:00 -05:00
19
18
  default_executable: job_boss
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
@@ -26,7 +25,6 @@ dependencies:
26
25
  requirements:
27
26
  - - ">="
28
27
  - !ruby/object:Gem::Version
29
- hash: 3
30
28
  segments:
31
29
  - 0
32
30
  version: "0"
@@ -40,7 +38,6 @@ dependencies:
40
38
  requirements:
41
39
  - - ">="
42
40
  - !ruby/object:Gem::Version
43
- hash: 3
44
41
  segments:
45
42
  - 0
46
43
  version: "0"
@@ -54,7 +51,6 @@ dependencies:
54
51
  requirements:
55
52
  - - ">="
56
53
  - !ruby/object:Gem::Version
57
- hash: 3
58
54
  segments:
59
55
  - 0
60
56
  version: "0"
@@ -172,7 +168,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
172
168
  requirements:
173
169
  - - ">="
174
170
  - !ruby/object:Gem::Version
175
- hash: 3
176
171
  segments:
177
172
  - 0
178
173
  version: "0"
@@ -181,7 +176,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
176
  requirements:
182
177
  - - ">="
183
178
  - !ruby/object:Gem::Version
184
- hash: 23
185
179
  segments:
186
180
  - 1
187
181
  - 3