good_job 2.4.1 → 2.4.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a0546a16ecd5760e3ca0dd5097ec950767b5993ac613489d5591d5d44eadc021
4
- data.tar.gz: 9e21d8930806b1843d4c32abef233f89f48292229386da593ba82b3a94617eae
3
+ metadata.gz: f06b525450f56cf74ff31e06e11cbf3bf2ee7f20d753973e70ddb53d67eb48d1
4
+ data.tar.gz: d25d2037ae03eaea0ff8bd4ca1dfa52ba6a57d3420e53b4be265dc7c0be580cb
5
5
  SHA512:
6
- metadata.gz: 6e3aa1deaa9973f0d435bc6eb77e4557f509a5e9dbd38e267a4268987561576323eda9bfb8bfa3af5ad7aec72c51b17f88121f7d202b1455c1ea17c8272cb6de
7
- data.tar.gz: b812a3371f589db1464f3dabe35badee94bf2a8f132e68e64c438e8ddde4415598d133f2e956d335e021a0ea82b59fbc61c3eb77cab230be760516dbca270402
6
+ metadata.gz: 2f2be221d400f0dc7a1e7c2d262b717ecd9c88a5192771df2bd343d61e878cb777af7e067814e3e7c751aa28716c2bd487b4389ef4dbbea17cc2a6a0f23d0c9a
7
+ data.tar.gz: abfd020a2203bb573c5e801e7f278214ebe996b6e63970ec60313fcb37a3b21cb901d4cf57cfd6739b7c247ea692ff7de012df3668d7c551d7ced78cc48b79e6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## [v2.4.2](https://github.com/bensheldon/good_job/tree/v2.4.2) (2021-10-19)
4
+
5
+ [Full Changelog](https://github.com/bensheldon/good_job/compare/v2.4.1...v2.4.2)
6
+
7
+ **Implemented enhancements:**
8
+
9
+ - Add migration version to install/update generator templates [\#426](https://github.com/bensheldon/good_job/pull/426) ([bensheldon](https://github.com/bensheldon))
10
+
11
+ **Fixed bugs:**
12
+
13
+ - Explicitly unscope queries within block yielded to Lockable.within\_advisory\_lock [\#429](https://github.com/bensheldon/good_job/pull/429) ([bensheldon](https://github.com/bensheldon))
14
+ - Fix Demo CleanupJob args [\#427](https://github.com/bensheldon/good_job/pull/427) ([bensheldon](https://github.com/bensheldon))
15
+
16
+ **Merged pull requests:**
17
+
18
+ - Remove v1.99/v2 transitional extra advisory lock [\#428](https://github.com/bensheldon/good_job/pull/428) ([bensheldon](https://github.com/bensheldon))
19
+
3
20
  ## [v2.4.1](https://github.com/bensheldon/good_job/tree/v2.4.1) (2021-10-11)
4
21
 
5
22
  [Full Changelog](https://github.com/bensheldon/good_job/compare/v2.4.0...v2.4.1)
@@ -19,5 +19,11 @@ module GoodJob
19
19
  def create_migration_file
20
20
  migration_template 'migrations/create_good_jobs.rb.erb', File.join(db_migrate_path, "create_good_jobs.rb")
21
21
  end
22
+
23
+ private
24
+
25
+ def migration_version
26
+ "[#{ActiveRecord::VERSION::STRING.to_f}]"
27
+ end
22
28
  end
23
29
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- class CreateGoodJobs < ActiveRecord::Migration[5.2]
2
+ class CreateGoodJobs < ActiveRecord::Migration<%= migration_version %>
3
3
  def change
4
4
  enable_extension 'pgcrypto'
5
5
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- class CreateGoodJobs < ActiveRecord::Migration[5.2]
2
+ class CreateGoodJobs < ActiveRecord::Migration<%= migration_version %>
3
3
  def change
4
4
  enable_extension 'pgcrypto'
5
5
 
@@ -24,5 +24,11 @@ module GoodJob
24
24
  migration_template "migrations/#{template_file}", File.join(db_migrate_path, destination_file), skip: true
25
25
  end
26
26
  end
27
+
28
+ private
29
+
30
+ def migration_version
31
+ "[#{ActiveRecord::VERSION::STRING.to_f}]"
32
+ end
27
33
  end
28
34
  end
@@ -32,10 +32,9 @@ module GoodJob
32
32
 
33
33
  GoodJob::Execution.new.with_advisory_lock(key: key, function: "pg_advisory_lock") do
34
34
  enqueue_concurrency = if enqueue_limit
35
- # TODO: Why is `unscoped` necessary? Nested scope is bleeding into subsequent query?
36
- GoodJob::Execution.unscoped.where(concurrency_key: key).unfinished.advisory_unlocked.count
35
+ GoodJob::Execution.where(concurrency_key: key).unfinished.advisory_unlocked.count
37
36
  else
38
- GoodJob::Execution.unscoped.where(concurrency_key: key).unfinished.count
37
+ GoodJob::Execution.where(concurrency_key: key).unfinished.count
39
38
  end
40
39
 
41
40
  # The job has not yet been enqueued, so check if adding it will go over the limit
@@ -63,7 +62,7 @@ module GoodJob
63
62
  next if key.blank?
64
63
 
65
64
  GoodJob::Execution.new.with_advisory_lock(key: key, function: "pg_advisory_lock") do
66
- allowed_active_job_ids = GoodJob::Execution.unscoped.where(concurrency_key: key).advisory_locked.order(Arel.sql("COALESCE(performed_at, scheduled_at, created_at) ASC")).limit(perform_limit).pluck(:active_job_id)
65
+ allowed_active_job_ids = GoodJob::Execution.where(concurrency_key: key).advisory_locked.order(Arel.sql("COALESCE(performed_at, scheduled_at, created_at) ASC")).limit(perform_limit).pluck(:active_job_id)
67
66
  # The current job has already been locked and will appear in the previous query
68
67
  raise GoodJob::ActiveJobExtensions::Concurrency::ConcurrencyExceededError unless allowed_active_job_ids.include? job.job_id
69
68
  end
@@ -174,13 +174,7 @@ module GoodJob
174
174
  break if execution.blank?
175
175
  break :unlocked unless execution&.executable?
176
176
 
177
- begin
178
- execution.with_advisory_lock(key: "good_jobs-#{execution.active_job_id}") do
179
- execution.perform
180
- end
181
- rescue RecordAlreadyAdvisoryLockedError => e
182
- ExecutionResult.new(value: nil, handled_error: e)
183
- end
177
+ execution.perform
184
178
  end
185
179
  end
186
180
 
@@ -149,7 +149,7 @@ module GoodJob
149
149
 
150
150
  records = advisory_lock(column: column, function: function).to_a
151
151
  begin
152
- yield(records)
152
+ unscoped { yield(records) }
153
153
  ensure
154
154
  if unlock_session
155
155
  advisory_unlock_session
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module GoodJob
3
3
  # GoodJob gem version.
4
- VERSION = '2.4.1'
4
+ VERSION = '2.4.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: good_job
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.1
4
+ version: 2.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Sheldon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-11 00:00:00.000000000 Z
11
+ date: 2021-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activejob
@@ -379,7 +379,7 @@ files:
379
379
  - lib/active_job/queue_adapters/good_job_adapter.rb
380
380
  - lib/generators/good_job/install_generator.rb
381
381
  - lib/generators/good_job/templates/install/migrations/create_good_jobs.rb.erb
382
- - lib/generators/good_job/templates/update/migrations/01_create_good_jobs.rb
382
+ - lib/generators/good_job/templates/update/migrations/01_create_good_jobs.rb.erb
383
383
  - lib/generators/good_job/update_generator.rb
384
384
  - lib/good_job.rb
385
385
  - lib/good_job/active_job_extensions.rb