good_job 4.9.2 → 4.10.0

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: eebb74f90c823f1b2dd3dbeeecffc6279b072d5929182c7734357ce98ebd3a1a
4
- data.tar.gz: f0df3c322938cb34d9a5686a344db8e412a2878473ff778928006855ab8339a1
3
+ metadata.gz: 464fe8415569d7b3a2e09f1ae95052ae8349969cb9086ee56e85d7d02a161de8
4
+ data.tar.gz: 9c1dd45dc3e99d9ed218a7123a38ab6f106ebf8b93871af86655d5ee9cf3a64f
5
5
  SHA512:
6
- metadata.gz: a91aae2a4768af8c89c8b0e2b04898d70dbe145b8808f2e1cc60fd18dd63faafd3679ca7444abd9e6863b7991b778ee709ba8949ac791362ff850c7aca3dcb5c
7
- data.tar.gz: e3df10dbd134f6e335938578c0050e838d2b0073a6a3d7f64a90313e70afd214e76307df146be840dc8fecfcfca32bcb4ea9671f7549573c2e0e32adb8006a7a
6
+ metadata.gz: 2270c9d1fdd9c0b953f921ac873ffed572270907ce1d99cbb92b1ddb63b9afa979603af20aacbd2b01745b4e76743966d5851ab1a742f60fcb29258aaef5cae9
7
+ data.tar.gz: 62802abd14cd93633bc7667bf42b74cbeb7bb420de6a85f3dd0fa7e93aad63eb0714f52976d80b527152bd6e7746a231a17fd46a15f8674ec7e90149df410b05
data/CHANGELOG.md CHANGED
@@ -1,5 +1,40 @@
1
1
  # Changelog
2
2
 
3
+ ## [v4.10.0](https://github.com/bensheldon/good_job/tree/v4.10.0) (2025-04-26)
4
+
5
+ [Full Changelog](https://github.com/bensheldon/good_job/compare/v4.9.3...v4.10.0)
6
+
7
+ **Implemented enhancements:**
8
+
9
+ - Improve dashboard performance when searching for job ID [\#1619](https://github.com/bensheldon/good_job/pull/1619) ([francois](https://github.com/francois))
10
+
11
+ **Fixed bugs:**
12
+
13
+ - Fix Batches dashboard deserealization error [\#1628](https://github.com/bensheldon/good_job/pull/1628) ([JulianPasquale](https://github.com/JulianPasquale))
14
+ - Fix enqueue\_after\_transaction\_commit config [\#1626](https://github.com/bensheldon/good_job/pull/1626) ([santib](https://github.com/santib))
15
+
16
+ **Closed issues:**
17
+
18
+ - Retried jobs with GoodJob::ActiveJobExtensions::Concurrency::ConcurrencyExceededError lose their arguments [\#1620](https://github.com/bensheldon/good_job/issues/1620)
19
+ - Searching for job ID fails on Heroku due to 30s request limit [\#1618](https://github.com/bensheldon/good_job/issues/1618)
20
+ - Poor performance when enqueuing many throttled jobs because of unindexed queries [\#1603](https://github.com/bensheldon/good_job/issues/1603)
21
+
22
+ **Merged pull requests:**
23
+
24
+ - Update `GoodJob.migrated?` for latest migration [\#1631](https://github.com/bensheldon/good_job/pull/1631) ([Earlopain](https://github.com/Earlopain))
25
+
26
+ ## [v4.9.3](https://github.com/bensheldon/good_job/tree/v4.9.3) (2025-03-10)
27
+
28
+ [Full Changelog](https://github.com/bensheldon/good_job/compare/v4.9.2...v4.9.3)
29
+
30
+ **Closed issues:**
31
+
32
+ - perform\_job.good\_job notification for successful jobs has error\_event: :discarded [\#1609](https://github.com/bensheldon/good_job/issues/1609)
33
+
34
+ **Merged pull requests:**
35
+
36
+ - Fix instrumentation of "perform\_job.good\_job" event [\#1616](https://github.com/bensheldon/good_job/pull/1616) ([bensheldon](https://github.com/bensheldon))
37
+
3
38
  ## [v4.9.2](https://github.com/bensheldon/good_job/tree/v4.9.2) (2025-03-09)
4
39
 
5
40
  [Full Changelog](https://github.com/bensheldon/good_job/compare/v4.9.1...v4.9.2)
@@ -2,6 +2,8 @@
2
2
 
3
3
  module GoodJob
4
4
  class JobsFilter < BaseFilter
5
+ UUID_REGEX = /\A[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}\z/i
6
+
5
7
  def state_names
6
8
  %w[scheduled retried queued running succeeded discarded]
7
9
  end
@@ -25,7 +27,16 @@ module GoodJob
25
27
 
26
28
  query = query.job_class(filter_params[:job_class]) if filter_params[:job_class].present?
27
29
  query = query.where(queue_name: filter_params[:queue_name]) if filter_params[:queue_name].present?
28
- query = query.search_text(filter_params[:query]) if filter_params[:query].present?
30
+
31
+ search_query = filter_params[:query]&.strip
32
+ if search_query.present?
33
+ query = if query_is_uuid_and_job_exists?(search_query)
34
+ query.where(active_job_id: search_query)
35
+ else
36
+ query.search_text(search_query)
37
+ end
38
+ end
39
+
29
40
  query = query.where(cron_key: filter_params[:cron_key]) if filter_params[:cron_key].present?
30
41
  query = query.where(finished_at: finished_since(filter_params[:finished_since])..) if filter_params[:finished_since].present?
31
42
 
@@ -90,5 +101,9 @@ module GoodJob
90
101
  7.days.ago
91
102
  end
92
103
  end
104
+
105
+ def query_is_uuid_and_job_exists?(search_query)
106
+ @_query_is_uuid_and_job_exists ||= search_query&.match?(UUID_REGEX) && base_query.exists?(active_job_id: search_query)
107
+ end
93
108
  end
94
109
  end
@@ -40,7 +40,19 @@ module GoodJob
40
40
  end
41
41
 
42
42
  def display_attributes
43
- attributes.except('serialized_properties').merge(properties: properties)
43
+ display_properties = begin
44
+ serialized_properties
45
+ rescue ActiveJob::DeserializationError
46
+ JSON.parse(read_attribute_before_type_cast(:serialized_properties))
47
+ end
48
+
49
+ attribute_names.to_h do |name|
50
+ if name == "serialized_properties"
51
+ ["properties", display_properties]
52
+ else
53
+ [name, self[name]]
54
+ end
55
+ end
44
56
  end
45
57
 
46
58
  def _continue_discard_or_finish(job = nil, lock: true)
@@ -9,7 +9,7 @@ module GoodJob
9
9
  attr_reader :handled_error
10
10
  # @return [Exception, nil]
11
11
  attr_reader :unhandled_error
12
- # @return [String, nil]
12
+ # @return [Symbol, nil]
13
13
  attr_reader :error_event
14
14
  # @return [Boolean, nil]
15
15
  attr_reader :unexecutable
@@ -249,6 +249,13 @@ module GoodJob
249
249
  Arel.sql('integer')
250
250
  )
251
251
  end
252
+
253
+ def concurrency_key_created_at_index_migrated?
254
+ return true if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_concurrency_key_and_created_at)
255
+
256
+ migration_pending_warning!
257
+ false
258
+ end
252
259
  end
253
260
 
254
261
  def self.build_for_enqueue(active_job, scheduled_at: nil)
@@ -642,8 +649,9 @@ module GoodJob
642
649
  value = nil
643
650
  end
644
651
  handled_error ||= current_thread.error_on_retry || current_thread.error_on_discard
645
-
646
- error_event = if handled_error == current_thread.error_on_discard
652
+ error_event = if !handled_error
653
+ nil
654
+ elsif handled_error == current_thread.error_on_discard
647
655
  :discarded
648
656
  elsif handled_error == current_thread.error_on_retry
649
657
  :retried
@@ -655,6 +663,7 @@ module GoodJob
655
663
 
656
664
  instrument_payload.merge!(
657
665
  value: value,
666
+ error: handled_error,
658
667
  handled_error: handled_error,
659
668
  retried: current_thread.retried_job.present?,
660
669
  error_event: error_event
@@ -669,7 +678,11 @@ module GoodJob
669
678
  :unhandled
670
679
  end
671
680
 
672
- instrument_payload[:unhandled_error] = e
681
+ instrument_payload.merge!(
682
+ error: e,
683
+ unhandled_error: e,
684
+ error_event: error_event
685
+ )
673
686
  ExecutionResult.new(value: nil, unhandled_error: e, error_event: error_event)
674
687
  end
675
688
  end
@@ -76,7 +76,7 @@
76
76
  </div>
77
77
  </div>
78
78
  <%= tag.div id: dom_id(batch, "properties"), class: "batch-properties list-group-item collapse small bg-dark text-light" do %>
79
- <%= tag.pre JSON.pretty_generate(batch.properties) %>
79
+ <%= tag.pre JSON.pretty_generate(batch.display_attributes["properties"]) %>
80
80
  <% end %>
81
81
  <% end %>
82
82
  <% else %>
@@ -367,6 +367,7 @@ module GoodJob
367
367
  # @return [Boolean]
368
368
  def enqueue_after_transaction_commit
369
369
  return options[:enqueue_after_transaction_commit] unless options[:enqueue_after_transaction_commit].nil?
370
+ return rails_config[:enqueue_after_transaction_commit] unless rails_config[:enqueue_after_transaction_commit].nil?
370
371
 
371
372
  DEFAULT_ENQUEUE_AFTER_TRANSACTION_COMMIT
372
373
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module GoodJob
4
4
  # GoodJob gem version.
5
- VERSION = '4.9.2'
5
+ VERSION = '4.10.0'
6
6
 
7
7
  # GoodJob version as Gem::Version object
8
8
  GEM_VERSION = Gem::Version.new(VERSION)
data/lib/good_job.rb CHANGED
@@ -290,7 +290,7 @@ module GoodJob
290
290
  # For use in tests/CI to validate GoodJob is up-to-date.
291
291
  # @return [Boolean]
292
292
  def self.migrated?
293
- GoodJob::BatchRecord.jobs_finished_at_migrated?
293
+ GoodJob::Job.concurrency_key_created_at_index_migrated?
294
294
  end
295
295
 
296
296
  # Pause job execution for a given queue or job class.
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: good_job
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.9.2
4
+ version: 4.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Sheldon
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-03-09 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activejob
@@ -240,9 +240,9 @@ executables:
240
240
  - good_job
241
241
  extensions: []
242
242
  extra_rdoc_files:
243
- - README.md
244
243
  - CHANGELOG.md
245
244
  - LICENSE.txt
245
+ - README.md
246
246
  files:
247
247
  - CHANGELOG.md
248
248
  - LICENSE.txt
@@ -421,7 +421,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
421
421
  - !ruby/object:Gem::Version
422
422
  version: '0'
423
423
  requirements: []
424
- rubygems_version: 3.6.2
424
+ rubygems_version: 3.6.8
425
425
  specification_version: 4
426
426
  summary: A multithreaded, Postgres-based ActiveJob backend for Ruby on Rails
427
427
  test_files: []