good_job 4.8.1 → 4.9.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: ad6949cd77548ff686d2824d654f609567f110b1e778975f72f13aec0eeda672
4
- data.tar.gz: bcfa0c1941d237dc5e4a1b8611d1987b1ddef282ac2a4417306f7664032c2c69
3
+ metadata.gz: e647f9e6432f6972951bdf902f2de80d9cc0001ee37c9bb355fedbfaae2c0dd6
4
+ data.tar.gz: 432488ed94165af462f1702aa08cdf26b771fa2815ba5f345d7acc48fa040a42
5
5
  SHA512:
6
- metadata.gz: 36643826c085b2192a63bc917d9271079e6517762d84f0fbf4310e56be6b10eb5d221e53cd526c88668300a3716b527dcfe94cc7f0cc5ba8163503f65770e4e1
7
- data.tar.gz: 8fe8418c883034d7e7e008a37b2617b3965582623fd87c034cdc72bd8798c760df3917a3e5b4e2d0cf9d2caa255cfe3924f0e97b4c110f361c61b00d55fa99db
6
+ metadata.gz: 68824597423a7149136168819e25d75f2ae427a574188352a793a0e8405eda879e032c4cfde00decab70e509c353dd3ea89752619099d1f4ddc80771ef3a7035
7
+ data.tar.gz: 90c3b1c09665ca5c2cbb3dcda3067949e69e02edb68dfea4ffb42c3a128a9603bde4ffb8ee9082fddab98651b9eea0c7096af71f5653c9af1588df7377e05d6b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # Changelog
2
2
 
3
+ ## [v4.9.0](https://github.com/bensheldon/good_job/tree/v4.9.0) (2025-02-07)
4
+
5
+ [Full Changelog](https://github.com/bensheldon/good_job/compare/v4.8.2...v4.9.0)
6
+
7
+ **Implemented enhancements:**
8
+
9
+ - Add `GoodJob.cli?` to check if the current process was started by the `good_job` executable [\#1592](https://github.com/bensheldon/good_job/pull/1592) ([bensheldon](https://github.com/bensheldon))
10
+
11
+ **Closed issues:**
12
+
13
+ - Option to only preserve discarded/errored jobs? [\#1594](https://github.com/bensheldon/good_job/issues/1594)
14
+ - Notifier errored: TypeError: ActiveSupport::TimeWithZone can't be coerced into Integer [\#1581](https://github.com/bensheldon/good_job/issues/1581)
15
+
16
+ ## [v4.8.2](https://github.com/bensheldon/good_job/tree/v4.8.2) (2025-01-26)
17
+
18
+ [Full Changelog](https://github.com/bensheldon/good_job/compare/v4.8.1...v4.8.2)
19
+
20
+ **Fixed bugs:**
21
+
22
+ - Ensure that executions are properly ordered in the dashboard [\#1588](https://github.com/bensheldon/good_job/pull/1588) ([Earlopain](https://github.com/Earlopain))
23
+
24
+ **Merged pull requests:**
25
+
26
+ - Fix passing a block to `advisory_lock` in tests [\#1587](https://github.com/bensheldon/good_job/pull/1587) ([Earlopain](https://github.com/Earlopain))
27
+ - Expect `Job#scheduled_at` to always be present; remove nil checks [\#1585](https://github.com/bensheldon/good_job/pull/1585) ([bensheldon](https://github.com/bensheldon))
28
+
3
29
  ## [v4.8.1](https://github.com/bensheldon/good_job/tree/v4.8.1) (2025-01-24)
4
30
 
5
31
  [Full Changelog](https://github.com/bensheldon/good_job/compare/v4.8.0...v4.8.1)
@@ -11,7 +37,6 @@
11
37
  **Closed issues:**
12
38
 
13
39
  - Losing "Processes" on the dashboard [\#1582](https://github.com/bensheldon/good_job/issues/1582)
14
- - Notifier errored: TypeError: ActiveSupport::TimeWithZone can't be coerced into Integer [\#1581](https://github.com/bensheldon/good_job/issues/1581)
15
40
  - Ability to pause queues [\#1574](https://github.com/bensheldon/good_job/issues/1574)
16
41
 
17
42
  ## [v4.8.0](https://github.com/bensheldon/good_job/tree/v4.8.0) (2025-01-22)
@@ -3042,7 +3067,7 @@
3042
3067
 
3043
3068
  **Implemented enhancements:**
3044
3069
 
3045
- - Suppress backtrace of ConcurrencyExceededError [\#348](https://github.com/bensheldon/good_job/pull/348) ([reczy](https://github.com/reczy))
3070
+ - Suppress backtrace of ConcurrencyExceededError [\#348](https://github.com/bensheldon/good_job/pull/348) ([mikereczek](https://github.com/mikereczek))
3046
3071
 
3047
3072
  **Closed issues:**
3048
3073
 
@@ -3428,7 +3453,7 @@
3428
3453
 
3429
3454
  **Merged pull requests:**
3430
3455
 
3431
- - Fix equality typo in development.rb of test\_app [\#207](https://github.com/bensheldon/good_job/pull/207) ([reczy](https://github.com/reczy))
3456
+ - Fix equality typo in development.rb of test\_app [\#207](https://github.com/bensheldon/good_job/pull/207) ([mikereczek](https://github.com/mikereczek))
3432
3457
 
3433
3458
  ## [v1.7.0](https://github.com/bensheldon/good_job/tree/v1.7.0) (2021-01-25)
3434
3459
 
@@ -15,11 +15,11 @@ module GoodJob
15
15
  # Display records after this ID for keyset pagination
16
16
  # @return [ActiveRecord::Relation]
17
17
  scope :display_all, (lambda do |after_scheduled_at: nil, after_id: nil|
18
- query = order(Arel.sql('COALESCE(scheduled_at, created_at) DESC, id DESC'))
18
+ query = order(Arel.sql('scheduled_at DESC, id DESC'))
19
19
  if after_scheduled_at.present? && after_id.present?
20
- query = query.where Arel::Nodes::Grouping.new([coalesce_scheduled_at_created_at, arel_table["id"]]).lt(Arel::Nodes::Grouping.new([bind_value('coalesce', after_scheduled_at, ActiveRecord::Type::DateTime), bind_value('id', after_id, ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Uuid)]))
20
+ query = query.where Arel::Nodes::Grouping.new([arel_table["scheduled_at"], arel_table["id"]]).lt(Arel::Nodes::Grouping.new([bind_value('scheduled_at', after_scheduled_at, ActiveRecord::Type::DateTime), bind_value('id', after_id, ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Uuid)]))
21
21
  elsif after_scheduled_at.present?
22
- query = query.where coalesce_scheduled_at_created_at.lt(bind_value('coalesce', after_scheduled_at, ActiveRecord::Type::DateTime))
22
+ query = query.where arel_table["scheduled_at"].lt(bind_value('scheduled_at', after_scheduled_at, ActiveRecord::Type::DateTime))
23
23
  end
24
24
  query
25
25
  end)
@@ -54,11 +54,11 @@ module GoodJob
54
54
  scope :finished_before, ->(timestamp) { where(arel_table['finished_at'].lteq(bind_value('finished_at', timestamp, ActiveRecord::Type::DateTime))) }
55
55
 
56
56
  # First execution will run in the future
57
- scope :scheduled, -> { where(finished_at: nil).where(coalesce_scheduled_at_created_at.gt(bind_value('coalesce', Time.current, ActiveRecord::Type::DateTime))).where(params_execution_count.lt(2)) }
57
+ scope :scheduled, -> { where(finished_at: nil).where(arel_table['scheduled_at'].gt(bind_value('scheduled_at', Time.current, ActiveRecord::Type::DateTime))).where(params_execution_count.lt(2)) }
58
58
  # Execution errored, will run in the future
59
- scope :retried, -> { where(finished_at: nil).where(coalesce_scheduled_at_created_at.gt(bind_value('coalesce', Time.current, ActiveRecord::Type::DateTime))).where(params_execution_count.gt(1)) }
59
+ scope :retried, -> { where(finished_at: nil).where(arel_table['scheduled_at'].gt(bind_value('scheduled_at', Time.current, ActiveRecord::Type::DateTime))).where(params_execution_count.gt(1)) }
60
60
  # Immediate/Scheduled time to run has passed, waiting for an available thread run
61
- scope :queued, -> { where(performed_at: nil, finished_at: nil).where(coalesce_scheduled_at_created_at.lteq(bind_value('coalesce', Time.current, ActiveRecord::Type::DateTime))) }
61
+ scope :queued, -> { where(performed_at: nil, finished_at: nil).where(arel_table['scheduled_at'].lteq(bind_value('scheduled_at', Time.current, ActiveRecord::Type::DateTime))) }
62
62
  # Advisory locked and executing
63
63
  scope :running, -> { where.not(performed_at: nil).where(finished_at: nil) }
64
64
  # Finished executing (succeeded or discarded)
@@ -94,7 +94,7 @@ module GoodJob
94
94
  # @!method only_scheduled
95
95
  # @!scope class
96
96
  # @return [ActiveRecord::Relation]
97
- scope :only_scheduled, -> { where(arel_table['scheduled_at'].lteq(bind_value('scheduled_at', DateTime.current, ActiveRecord::Type::DateTime))).or(where(scheduled_at: nil)) }
97
+ scope :only_scheduled, -> { where(arel_table['scheduled_at'].lteq(bind_value('scheduled_at', DateTime.current, ActiveRecord::Type::DateTime))) }
98
98
 
99
99
  # Exclude jobs that are paused via queue_name or job_class.
100
100
  # Only applies when enable_pauses configuration is true.
@@ -166,7 +166,7 @@ module GoodJob
166
166
  # @!method schedule_ordered
167
167
  # @!scope class
168
168
  # @return [ActiveRecord::Relation]
169
- scope :schedule_ordered, -> { order(coalesce_scheduled_at_created_at.asc) }
169
+ scope :schedule_ordered, -> { order(scheduled_at: :asc) }
170
170
 
171
171
  # Get Jobs on queues that match the given queue string.
172
172
  # @!method queue_string(string)
@@ -249,10 +249,6 @@ module GoodJob
249
249
  Arel.sql('integer')
250
250
  )
251
251
  end
252
-
253
- def coalesce_scheduled_at_created_at
254
- arel_table.coalesce(arel_table['scheduled_at'], arel_table['created_at'])
255
- end
256
252
  end
257
253
 
258
254
  def self.build_for_enqueue(active_job, scheduled_at: nil)
@@ -344,12 +340,13 @@ module GoodJob
344
340
 
345
341
  after ||= Time.current
346
342
  after_bind = bind_value('scheduled_at', after, ActiveRecord::Type::DateTime)
347
- after_query = query.where(arel_table['scheduled_at'].gt(after_bind)).or query.where(scheduled_at: nil).where(arel_table['created_at'].gt(after_bind))
348
- after_at = after_query.limit(limit).pluck(:scheduled_at, :created_at).map { |timestamps| timestamps.compact.first }
343
+ after_query = query.where(arel_table['scheduled_at'].gt(after_bind))
344
+ after_at = after_query.limit(limit).pluck(:scheduled_at)
349
345
 
350
346
  if now_limit&.positive?
351
- now_query = query.where(arel_table['scheduled_at'].lt(bind_value('scheduled_at', Time.current, ActiveRecord::Type::DateTime))).or query.where(scheduled_at: nil)
352
- now_at = now_query.limit(now_limit).pluck(:scheduled_at, :created_at).map { |timestamps| timestamps.compact.first }
347
+ now_bind = bind_value('scheduled_at', Time.current, ActiveRecord::Type::DateTime)
348
+ now_query = query.where(arel_table['scheduled_at'].lt(now_bind))
349
+ now_at = now_query.limit(now_limit).pluck(:scheduled_at)
353
350
  end
354
351
 
355
352
  Array(now_at) + after_at
@@ -84,4 +84,4 @@
84
84
  <%= tag.pre JSON.pretty_generate(@job.display_serialized_params) %>
85
85
  <% end %>
86
86
 
87
- <%= render 'executions', executions: @job.executions.reverse %>
87
+ <%= render 'executions', executions: @job.executions.sort_by(&:number).reverse %>
@@ -2,7 +2,7 @@
2
2
 
3
3
  module GoodJob
4
4
  # GoodJob gem version.
5
- VERSION = '4.8.1'
5
+ VERSION = '4.9.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
@@ -324,6 +324,12 @@ module GoodJob
324
324
  def self.paused(type = nil)
325
325
  GoodJob::Setting.paused(type)
326
326
  end
327
+
328
+ # Whether this process was initialized via the GoodJob executable (`$ good_job`)
329
+ # @return [Boolean]
330
+ def self.cli?
331
+ GoodJob::CLI.within_exe?
332
+ end
327
333
  end
328
334
 
329
335
  ActiveSupport.run_load_hooks(:good_job, GoodJob)
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.8.1
4
+ version: 4.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Sheldon
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-01-24 00:00:00.000000000 Z
10
+ date: 2025-02-07 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activejob