good_job 4.8.0 → 4.8.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 69c9c36ff0026c4a82ac6db945370e397d218e7976d4fc540aa4144225f75a25
4
- data.tar.gz: 4db17623ab0fc1e1747a6c1de6ea596efde905c774a4c8193beb9f7a380c5e31
3
+ metadata.gz: dad9150afd9c10b0e0bd9850f5252000456a22f6e7cd9ccfd399ccf5f8e797aa
4
+ data.tar.gz: a2d3897d12bbd2b4b5860e4306038f71bc0c5f63ed3d03f97b0e06bfc21cfa5b
5
5
  SHA512:
6
- metadata.gz: 4c9972c721472ca50148161ffc9611f59799e501b7c8fb0af5feac5b1a3f0dcdbf906295125bf4376b2e7fda0e72f9a8d27230fdb491fc6ea0c6c78bca8e4655
7
- data.tar.gz: 3b5f9fc708ae37ebb1e6a27f6d5f453312193caf78334f210b09dfd0a5d53ba591db1017516cb7c681b1afe01dd1dd66115f4b6728a6fa7cb28a4c1383005d04
6
+ metadata.gz: 2375178420c7a749563bb93c4be342dd594dd170095297e38d71dae31f657be30d75a3220e2e072e731ae91aad7cb51f3ad550e89a7c210da1464ef148e3552f
7
+ data.tar.gz: 51956eb4fcc4c12a0a4aa832720be3cf1c462f0c55cab637a550ff104a55c7f28edad7e079772b324667bc67bc0003ffe69d12c0446ea289f369ef506a4e6286
data/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
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
+
16
+ ## [v4.8.1](https://github.com/bensheldon/good_job/tree/v4.8.1) (2025-01-24)
17
+
18
+ [Full Changelog](https://github.com/bensheldon/good_job/compare/v4.8.0...v4.8.1)
19
+
20
+ **Fixed bugs:**
21
+
22
+ - Fix notifier/scheduler handling of integer/epoch serialized scheduled\_at values [\#1583](https://github.com/bensheldon/good_job/pull/1583) ([bensheldon](https://github.com/bensheldon))
23
+
24
+ **Closed issues:**
25
+
26
+ - Losing "Processes" on the dashboard [\#1582](https://github.com/bensheldon/good_job/issues/1582)
27
+ - Ability to pause queues [\#1574](https://github.com/bensheldon/good_job/issues/1574)
28
+
3
29
  ## [v4.8.0](https://github.com/bensheldon/good_job/tree/v4.8.0) (2025-01-22)
4
30
 
5
31
  [Full Changelog](https://github.com/bensheldon/good_job/compare/v4.7.0...v4.8.0)
@@ -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 %>
@@ -162,6 +162,8 @@ module GoodJob # :nodoc:
162
162
  if state[:scheduled_at]
163
163
  scheduled_at = if state[:scheduled_at].is_a? String
164
164
  Time.zone.parse state[:scheduled_at]
165
+ elsif state[:scheduled_at].is_a? Numeric
166
+ Time.zone.at state[:scheduled_at]
165
167
  else
166
168
  state[:scheduled_at]
167
169
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module GoodJob
4
4
  # GoodJob gem version.
5
- VERSION = '4.8.0'
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.0
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-22 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