delayed_job_active_record 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
[![Build Status](https://travis-ci.org/collectiveidea/delayed_job_active_record.png)](https://travis-ci.org/collectiveidea/delayed_job_active_record)
|
5
5
|
[![Dependency Status](https://gemnasium.com/collectiveidea/delayed_job_active_record.png)](https://gemnasium.com/collectiveidea/delayed_job_active_record)
|
6
6
|
[![Code Climate](https://codeclimate.com/github/collectiveidea/delayed_job_active_record.png)](https://codeclimate.com/github/collectiveidea/delayed_job_active_record)
|
7
|
+
[![Coverage Status](https://coveralls.io/repos/collectiveidea/delayed_job_active_record/badge.png?branch=master)](https://coveralls.io/r/collectiveidea/delayed_job_active_record)
|
7
8
|
|
8
9
|
## Installation
|
9
10
|
|
@@ -52,22 +52,14 @@ module Delayed
|
|
52
52
|
nextScope = nextScope.scoped.by_priority.limit(1)
|
53
53
|
|
54
54
|
now = self.db_time_now
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
quotedTableName = ::ActiveRecord::Base.connection.quote_table_name(self.table_name)
|
62
|
-
subquerySql = nextScope.lock(true).select('id').to_sql
|
63
|
-
reserved = self.find_by_sql(["UPDATE #{quotedTableName} SET locked_at = ?, locked_by = ? WHERE id IN (#{subquerySql}) RETURNING *",now,worker.name])
|
64
|
-
return reserved[0]
|
65
|
-
else
|
66
|
-
# This works on MySQL and other DBs that support UPDATE...LIMIT. It uses separate queries to lock and return the job
|
67
|
-
count = nextScope.update_all(:locked_at => now, :locked_by => worker.name)
|
68
|
-
return nil if count == 0
|
69
|
-
return self.where(:locked_at => now, :locked_by => worker.name).first
|
55
|
+
job = nextScope.first
|
56
|
+
return unless job
|
57
|
+
job.with_lock do
|
58
|
+
job.locked_at = now
|
59
|
+
job.locked_by = worker.name
|
60
|
+
job.save!
|
70
61
|
end
|
62
|
+
job
|
71
63
|
end
|
72
64
|
|
73
65
|
# Lock this job for this worker.
|
@@ -1,9 +1,14 @@
|
|
1
|
-
|
1
|
+
require 'simplecov'
|
2
|
+
require 'coveralls'
|
3
|
+
|
4
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
5
|
+
SimpleCov::Formatter::HTMLFormatter,
|
6
|
+
Coveralls::SimpleCov::Formatter
|
7
|
+
]
|
8
|
+
SimpleCov.start
|
2
9
|
|
3
|
-
require 'rubygems'
|
4
|
-
require 'bundler/setup'
|
5
|
-
require 'rspec'
|
6
10
|
require 'logger'
|
11
|
+
require 'rspec'
|
7
12
|
|
8
13
|
require 'delayed_job_active_record'
|
9
14
|
require 'delayed/backend/shared_spec'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: delayed_job_active_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-02
|
14
|
+
date: 2013-03-02 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activerecord
|
@@ -75,7 +75,7 @@ files:
|
|
75
75
|
- spec/database.yml
|
76
76
|
- spec/delayed/backend/active_record_spec.rb
|
77
77
|
- spec/delayed/serialization/active_record_spec.rb
|
78
|
-
- spec/
|
78
|
+
- spec/helper.rb
|
79
79
|
homepage: http://github.com/collectiveidea/delayed_job_active_record
|
80
80
|
licenses:
|
81
81
|
- MIT
|
@@ -91,7 +91,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
91
91
|
version: '0'
|
92
92
|
segments:
|
93
93
|
- 0
|
94
|
-
hash:
|
94
|
+
hash: -4151912302057659194
|
95
95
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
96
|
none: false
|
97
97
|
requirements:
|
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
version: '0'
|
101
101
|
segments:
|
102
102
|
- 0
|
103
|
-
hash:
|
103
|
+
hash: -4151912302057659194
|
104
104
|
requirements: []
|
105
105
|
rubyforge_project:
|
106
106
|
rubygems_version: 1.8.25
|
@@ -111,4 +111,4 @@ test_files:
|
|
111
111
|
- spec/database.yml
|
112
112
|
- spec/delayed/backend/active_record_spec.rb
|
113
113
|
- spec/delayed/serialization/active_record_spec.rb
|
114
|
-
- spec/
|
114
|
+
- spec/helper.rb
|