scheduled_job 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 086a464af16592accd6f73697f08b201e69ce287
4
- data.tar.gz: 5a0fedb421b68e80b681f8aa5ec705797a50c2c0
3
+ metadata.gz: 30677ced04a460d65fe090c92f6bf5b914d85d07
4
+ data.tar.gz: 8d5ecd3dbc01fcc33c52663d24123943192998a2
5
5
  SHA512:
6
- metadata.gz: deff4169d776644f323bfec2d8acb0b4eb48323ecae3eb251048dad15d0b01af40c188126eb0d500b26a9ebdb1f4ea0b2845eea467203ab7ac4b9b8f0d7b7200
7
- data.tar.gz: 4b8e46bcddb661417a76562c79e65e8c054f0e206bdf094d26cc7edc6dddae5cc10f8e8dba36056b26c76205e580dff99bbe3372d97e2da814b7aec16343f517
6
+ metadata.gz: 746edac4b4b6c72f2281f7fe7fcc6d86d383867e398f43c54b03f0f92712cd4f0b907237dfae32d94157c8490bc276271ead90bae7d663a07e446561817028f2
7
+ data.tar.gz: 3ab1ba959f72642680b83b7c80b4e061a9f94efe38f445596789461a2a1523083b56d7a6267b4f8b7099c13fc079238cb3d7e7a481c9fb2703e684d6b069ddac
data/CHANGELOG.md CHANGED
@@ -35,3 +35,6 @@ This is needed is some cases where scheduled_job is deployed in a container and
35
35
 
36
36
  # 0.2.3
37
37
  Updating the acitve* gem dependency versions to support the current release. Also drops travis testing for ruby 1.9.3 which is no longer an officially supported Ruby version.
38
+
39
+ # 0.2.4
40
+ Updates the way that we detect if an instance of a job has already been scheduled. This was because we were incorrectly seeing a delayed method as an instance of that job already being scheduled.
@@ -1,3 +1,3 @@
1
1
  module ScheduledJob
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
data/lib/scheduled_job.rb CHANGED
@@ -97,12 +97,17 @@ module ScheduledJob
97
97
  end
98
98
 
99
99
  def can_schedule_job?(job = nil)
100
- conditions = ['(handler like ? OR handler like ?) AND failed_at IS NULL', "%:#{self.name} %", "%:#{self.name}\n%"]
100
+ conditions = 'failed_at IS NULL'
101
101
  unless job.blank?
102
- conditions[0] << " AND id != ?"
102
+ conditions << " AND id != "
103
103
  conditions << job.id
104
104
  end
105
- job_count = Delayed::Job.where(conditions).count
105
+ jobs = Delayed::Job.where(conditions).find_all do |dj|
106
+ dj.handler.split[1][/(?<=:)[A-Z][A-z0-9:]+/] == self.name
107
+ end
108
+
109
+ job_count = jobs.count
110
+
106
111
  intended_job_count = 1
107
112
 
108
113
  if ScheduledJob.config.jobs && ScheduledJob.config.jobs[self.name]
@@ -20,7 +20,10 @@ class Test < UnderTest
20
20
  end
21
21
 
22
22
  describe ScheduledJob do
23
- before { ScheduledJob.configure { |config| config.jobs = nil } }
23
+ before do
24
+ ScheduledJob.configure { |config| config.jobs = nil }
25
+ Delayed::Job.delete_all
26
+ end
24
27
 
25
28
  let(:under_test) { UnderTest.new }
26
29
 
@@ -195,6 +198,12 @@ describe ScheduledJob do
195
198
  UnderTest.schedule_job job
196
199
  end
197
200
 
201
+ it 'doesnt find delayed methods as existing' do
202
+ UnderTest.delay.queue_name
203
+ UnderTest.schedule_job
204
+ expect(Delayed::Job.count).to eq(2)
205
+ end
206
+
198
207
  it 'doesnt find substring jobs as existing' do
199
208
  UnderTest.schedule_job
200
209
  Test.schedule_job
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scheduled_job
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - CallumD
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-05-09 00:00:00.000000000 Z
14
+ date: 2016-07-18 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: delayed_job