good_job 4.8.1 → 4.8.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: ad6949cd77548ff686d2824d654f609567f110b1e778975f72f13aec0eeda672
4
- data.tar.gz: bcfa0c1941d237dc5e4a1b8611d1987b1ddef282ac2a4417306f7664032c2c69
3
+ metadata.gz: dad9150afd9c10b0e0bd9850f5252000456a22f6e7cd9ccfd399ccf5f8e797aa
4
+ data.tar.gz: a2d3897d12bbd2b4b5860e4306038f71bc0c5f63ed3d03f97b0e06bfc21cfa5b
5
5
  SHA512:
6
- metadata.gz: 36643826c085b2192a63bc917d9271079e6517762d84f0fbf4310e56be6b10eb5d221e53cd526c88668300a3716b527dcfe94cc7f0cc5ba8163503f65770e4e1
7
- data.tar.gz: 8fe8418c883034d7e7e008a37b2617b3965582623fd87c034cdc72bd8798c760df3917a3e5b4e2d0cf9d2caa255cfe3924f0e97b4c110f361c61b00d55fa99db
6
+ metadata.gz: 2375178420c7a749563bb93c4be342dd594dd170095297e38d71dae31f657be30d75a3220e2e072e731ae91aad7cb51f3ad550e89a7c210da1464ef148e3552f
7
+ data.tar.gz: 51956eb4fcc4c12a0a4aa832720be3cf1c462f0c55cab637a550ff104a55c7f28edad7e079772b324667bc67bc0003ffe69d12c0446ea289f369ef506a4e6286
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## [v4.8.2](https://github.com/bensheldon/good_job/tree/v4.8.2) (2025-01-26)
4
+
5
+ [Full Changelog](https://github.com/bensheldon/good_job/compare/v4.8.1...v4.8.2)
6
+
7
+ **Fixed bugs:**
8
+
9
+ - Ensure that executions are properly ordered in the dashboard [\#1588](https://github.com/bensheldon/good_job/pull/1588) ([Earlopain](https://github.com/Earlopain))
10
+
11
+ **Merged pull requests:**
12
+
13
+ - Fix passing a block to `advisory_lock` in tests [\#1587](https://github.com/bensheldon/good_job/pull/1587) ([Earlopain](https://github.com/Earlopain))
14
+ - 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))
15
+
3
16
  ## [v4.8.1](https://github.com/bensheldon/good_job/tree/v4.8.1) (2025-01-24)
4
17
 
5
18
  [Full Changelog](https://github.com/bensheldon/good_job/compare/v4.8.0...v4.8.1)
@@ -11,7 +24,6 @@
11
24
  **Closed issues:**
12
25
 
13
26
  - 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
27
  - Ability to pause queues [\#1574](https://github.com/bensheldon/good_job/issues/1574)
16
28
 
17
29
  ## [v4.8.0](https://github.com/bensheldon/good_job/tree/v4.8.0) (2025-01-22)
@@ -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.8.2'
6
6
 
7
7
  # GoodJob version as Gem::Version object
8
8
  GEM_VERSION = Gem::Version.new(VERSION)
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.8.2
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-01-26 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activejob