good_job 3.4.8 → 3.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +1 -1
- data/app/filters/good_job/jobs_filter.rb +3 -3
- data/app/helpers/good_job/application_helper.rb +2 -2
- data/app/models/concerns/good_job/reportable.rb +3 -3
- data/app/models/good_job/execution.rb +8 -8
- data/app/models/good_job/job.rb +23 -5
- data/app/views/good_job/jobs/_table.erb +2 -2
- data/app/views/good_job/jobs/show.html.erb +1 -1
- data/config/locales/en.yml +1 -1
- data/config/locales/es.yml +1 -1
- data/config/locales/nl.yml +1 -1
- data/config/locales/ru.yml +1 -1
- data/lib/good_job/version.rb +1 -1
- data/lib/good_job.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7cc0961bf8aed9531b101c7d9a2be80693bd16dadf7239aa76b25adfea24f27c
|
4
|
+
data.tar.gz: 0740f33be940345ef16ebea8a8f188ebac56fe27af260f5510e7ed3d2ce98a96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bdb4e1dab74099990750ea9239fe741432969d4aa412a8fdead0cbd4b43f5a7ae07732c78ff7ce82aedd534d5c6a27122be1c4b390f75982531ec0ed37ad9e8
|
7
|
+
data.tar.gz: 04b50734aab939660d38b28076c1ca7fe13f19894fe419cd09f9d099c1cdb2253c9ec0d8c90fdb54fe2bdeeff58646e3f366f3bcaf86638bb9dbd579194bb4c1
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v3.5.0](https://github.com/bensheldon/good_job/tree/v3.5.0) (2022-10-18)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/bensheldon/good_job/compare/v3.4.8...v3.5.0)
|
6
|
+
|
7
|
+
**Merged pull requests:**
|
8
|
+
|
9
|
+
- Fix flaky test for `Scheduler#cleanup_interval_jobs` [\#723](https://github.com/bensheldon/good_job/pull/723) ([bensheldon](https://github.com/bensheldon))
|
10
|
+
- Pin development Puma version until Capybara is compatible [\#722](https://github.com/bensheldon/good_job/pull/722) ([bensheldon](https://github.com/bensheldon))
|
11
|
+
- Rename Job status of `finished` to `succeeded`; `finished` now means either `succeeded` or `discarded` [\#721](https://github.com/bensheldon/good_job/pull/721) ([bensheldon](https://github.com/bensheldon))
|
12
|
+
|
3
13
|
## [v3.4.8](https://github.com/bensheldon/good_job/tree/v3.4.8) (2022-10-11)
|
4
14
|
|
5
15
|
[Full Changelog](https://github.com/bensheldon/good_job/compare/v3.4.7...v3.4.8)
|
data/README.md
CHANGED
@@ -363,7 +363,7 @@ GoodJob includes a Dashboard as a mountable `Rails::Engine`.
|
|
363
363
|
end
|
364
364
|
```
|
365
365
|
|
366
|
-
_To view finished (
|
366
|
+
_To view finished jobs (succeeded and discarded) on the Dashboard, GoodJob must be configured to preserve job records. Preservation is enabled by default._
|
367
367
|
|
368
368
|
**Troubleshooting the Dashboard:** Some applications are unable to autoload the Goodjob Engine. To work around this, explicitly require the Engine at the top of your `config/application.rb` file, immediately after Rails is required and before Bundler requires the Rails' groups.
|
369
369
|
|
@@ -8,7 +8,7 @@ module GoodJob
|
|
8
8
|
'retried' => query.retried.count,
|
9
9
|
'queued' => query.queued.count,
|
10
10
|
'running' => query.running.count,
|
11
|
-
'
|
11
|
+
'succeeded' => query.succeeded.count,
|
12
12
|
'discarded' => query.discarded.count,
|
13
13
|
}
|
14
14
|
end
|
@@ -25,8 +25,8 @@ module GoodJob
|
|
25
25
|
case filter_params[:state]
|
26
26
|
when 'discarded'
|
27
27
|
query = query.discarded
|
28
|
-
when '
|
29
|
-
query = query.
|
28
|
+
when 'succeeded'
|
29
|
+
query = query.succeeded
|
30
30
|
when 'retried'
|
31
31
|
query = query.retried
|
32
32
|
when 'scheduled'
|
@@ -24,7 +24,7 @@ module GoodJob
|
|
24
24
|
|
25
25
|
STATUS_ICONS = {
|
26
26
|
discarded: "exclamation",
|
27
|
-
|
27
|
+
succeeded: "check",
|
28
28
|
queued: "dash_circle",
|
29
29
|
retried: "arrow_clockwise",
|
30
30
|
running: "play",
|
@@ -33,7 +33,7 @@ module GoodJob
|
|
33
33
|
|
34
34
|
STATUS_COLOR = {
|
35
35
|
discarded: "danger",
|
36
|
-
|
36
|
+
succeeded: "success",
|
37
37
|
queued: "secondary",
|
38
38
|
retried: "warning",
|
39
39
|
running: "primary",
|
@@ -8,8 +8,8 @@ module GoodJob
|
|
8
8
|
# - retried: The job previously errored on execution and will be re-executed in the future.
|
9
9
|
# 2. The job is being executed
|
10
10
|
# - running: the job is actively being executed by an execution thread
|
11
|
-
# 3. The job
|
12
|
-
# -
|
11
|
+
# 3. The job has finished
|
12
|
+
# - succeeded: The job executed successfully
|
13
13
|
# - discarded: The job previously errored on execution and will not be re-executed in the future.
|
14
14
|
#
|
15
15
|
# @return [Symbol]
|
@@ -20,7 +20,7 @@ module GoodJob
|
|
20
20
|
elsif error.present? && retried_good_job_id.nil?
|
21
21
|
:discarded
|
22
22
|
else
|
23
|
-
:
|
23
|
+
:succeeded
|
24
24
|
end
|
25
25
|
elsif (scheduled_at || created_at) > DateTime.current
|
26
26
|
if serialized_params.fetch('executions', 0) > 1
|
@@ -68,7 +68,7 @@ module GoodJob
|
|
68
68
|
belongs_to :job, class_name: 'GoodJob::Job', foreign_key: 'active_job_id', primary_key: 'active_job_id', optional: true, inverse_of: :executions
|
69
69
|
after_destroy -> { self.class.active_job_id(active_job_id).delete_all }, if: -> { @_destroy_job }
|
70
70
|
|
71
|
-
# Get
|
71
|
+
# Get executions with given ActiveJob ID
|
72
72
|
# @!method active_job_id
|
73
73
|
# @!scope class
|
74
74
|
# @param active_job_id [String]
|
@@ -76,7 +76,7 @@ module GoodJob
|
|
76
76
|
# @return [ActiveRecord::Relation]
|
77
77
|
scope :active_job_id, ->(active_job_id) { where(active_job_id: active_job_id) }
|
78
78
|
|
79
|
-
# Get
|
79
|
+
# Get executions with given class name
|
80
80
|
# @!method job_class
|
81
81
|
# @!scope class
|
82
82
|
# @param string [String]
|
@@ -84,32 +84,32 @@ module GoodJob
|
|
84
84
|
# @return [ActiveRecord::Relation]
|
85
85
|
scope :job_class, ->(job_class) { where("serialized_params->>'job_class' = ?", job_class) }
|
86
86
|
|
87
|
-
# Get
|
87
|
+
# Get executions that have not yet finished (succeeded or discarded).
|
88
88
|
# @!method unfinished
|
89
89
|
# @!scope class
|
90
90
|
# @return [ActiveRecord::Relation]
|
91
91
|
scope :unfinished, -> { where(finished_at: nil) }
|
92
92
|
|
93
|
-
# Get
|
93
|
+
# Get executions that are not scheduled for a later time than now (i.e. jobs that
|
94
94
|
# are not scheduled or scheduled for earlier than the current time).
|
95
95
|
# @!method only_scheduled
|
96
96
|
# @!scope class
|
97
97
|
# @return [ActiveRecord::Relation]
|
98
98
|
scope :only_scheduled, -> { where(arel_table['scheduled_at'].lteq(Time.current)).or(where(scheduled_at: nil)) }
|
99
99
|
|
100
|
-
# Order
|
100
|
+
# Order executions by priority (highest priority first).
|
101
101
|
# @!method priority_ordered
|
102
102
|
# @!scope class
|
103
103
|
# @return [ActiveRecord::Relation]
|
104
104
|
scope :priority_ordered, -> { order('priority DESC NULLS LAST') }
|
105
105
|
|
106
|
-
# Order
|
106
|
+
# Order executions by created_at, for first-in first-out
|
107
107
|
# @!method creation_ordered
|
108
108
|
# @!scope class
|
109
109
|
# @return [ActiveRecord:Relation]
|
110
110
|
scope :creation_ordered, -> { order('created_at ASC') }
|
111
111
|
|
112
|
-
# Order
|
112
|
+
# Order executions for de-queueing
|
113
113
|
# @!method dequeueing_ordered
|
114
114
|
# @!scope class
|
115
115
|
# @param parsed_queues [Hash]
|
@@ -124,7 +124,7 @@ module GoodJob
|
|
124
124
|
relation
|
125
125
|
end)
|
126
126
|
|
127
|
-
# Order
|
127
|
+
# Order executions in order of queues in array param
|
128
128
|
# @!method queue_ordered
|
129
129
|
# @!scope class
|
130
130
|
# @param queues [Array<string] ordered names of queues
|
data/app/models/good_job/job.rb
CHANGED
@@ -55,12 +55,12 @@ module GoodJob
|
|
55
55
|
scope :queued, -> { where(finished_at: nil).where('COALESCE(scheduled_at, created_at) <= ?', DateTime.current).joins_advisory_locks.where(pg_locks: { locktype: nil }) }
|
56
56
|
# Advisory locked and executing
|
57
57
|
scope :running, -> { where(finished_at: nil).joins_advisory_locks.where.not(pg_locks: { locktype: nil }) }
|
58
|
+
# Finished executing (succeeded or discarded)
|
59
|
+
scope :finished, -> { where.not(finished_at: nil).where(retried_good_job_id: nil) }
|
58
60
|
# Completed executing successfully
|
59
|
-
scope :
|
61
|
+
scope :succeeded, -> { finished.where(error: nil) }
|
60
62
|
# Errored but will not be retried
|
61
|
-
scope :discarded, -> {
|
62
|
-
# Not errored
|
63
|
-
scope :not_discarded, -> { where(error: nil) }
|
63
|
+
scope :discarded, -> { finished.where.not(error: nil) }
|
64
64
|
|
65
65
|
# The job's ActiveJob UUID
|
66
66
|
# @return [String]
|
@@ -115,7 +115,7 @@ module GoodJob
|
|
115
115
|
aj_count = serialized_params.fetch('executions', 0)
|
116
116
|
# The execution count within serialized_params is not updated
|
117
117
|
# once the underlying execution has been executed.
|
118
|
-
if status.in? [:discarded, :
|
118
|
+
if status.in? [:discarded, :succeeded, :running]
|
119
119
|
aj_count + 1
|
120
120
|
else
|
121
121
|
aj_count
|
@@ -154,6 +154,24 @@ module GoodJob
|
|
154
154
|
end
|
155
155
|
end
|
156
156
|
|
157
|
+
# Tests whether the job has finished (succeeded or discarded).
|
158
|
+
# @return [Boolean]
|
159
|
+
def finished?
|
160
|
+
finished_at.present? && retried_good_job_id.nil?
|
161
|
+
end
|
162
|
+
|
163
|
+
# Tests whether the job has finished but with an error.
|
164
|
+
# @return [Boolean]
|
165
|
+
def discarded?
|
166
|
+
finished? && error.present?
|
167
|
+
end
|
168
|
+
|
169
|
+
# Tests whether the job has finished without error
|
170
|
+
# @return [Boolean]
|
171
|
+
def succeeded?
|
172
|
+
finished? && !discarded?
|
173
|
+
end
|
174
|
+
|
157
175
|
# Retry a job that has errored and been discarded.
|
158
176
|
# This action will create a new {Execution} record for the job.
|
159
177
|
# @return [ActiveJob::Base]
|
@@ -75,7 +75,7 @@
|
|
75
75
|
<span class="font-monospace fw-bold"><%= job.priority %></span>
|
76
76
|
</div>
|
77
77
|
<div class="col-1 text-center">
|
78
|
-
<% if job.executions_count > 0 && job.status != :
|
78
|
+
<% if job.executions_count > 0 && job.status != :succeeded %>
|
79
79
|
<%= tag.span job.executions_count, class: "badge rounded-pill bg-danger", data: {
|
80
80
|
bs_toggle: "popover",
|
81
81
|
bs_trigger: "hover focus click",
|
@@ -118,7 +118,7 @@
|
|
118
118
|
<% end %>
|
119
119
|
</li>
|
120
120
|
<li>
|
121
|
-
<%= link_to job_path(job.id), method: :delete, class: "dropdown-item #{'disabled' unless job.status.in? [:discarded, :
|
121
|
+
<%= link_to job_path(job.id), method: :delete, class: "dropdown-item #{'disabled' unless job.status.in? [:discarded, :succeeded]}", title: "Destroy job", data: { confirm: "Confirm destroy", disable: true } do %>
|
122
122
|
<%= render_icon "trash" %>
|
123
123
|
Destroy
|
124
124
|
<% end %>
|
@@ -47,7 +47,7 @@
|
|
47
47
|
<% end %>
|
48
48
|
<% end %>
|
49
49
|
|
50
|
-
<% if @job.status.in? [:discarded, :
|
50
|
+
<% if @job.status.in? [:discarded, :succeeded] %>
|
51
51
|
<%= button_to job_path(@job.id), method: :delete, class: "btn btn-sm btn-outline-primary", form_class: "d-inline-block", aria: { label: "Destroy job" }, title: "Destroy job", data: { confirm: "Confirm destroy" } do %>
|
52
52
|
<%= render_icon "trash" %>
|
53
53
|
Destroy
|
data/config/locales/en.yml
CHANGED
data/config/locales/es.yml
CHANGED
data/config/locales/nl.yml
CHANGED
@@ -58,11 +58,11 @@ nl:
|
|
58
58
|
processes: Processen
|
59
59
|
status:
|
60
60
|
discarded: weggegooid
|
61
|
-
finished: Afgewerkt
|
62
61
|
queued: In de wachtrij
|
63
62
|
retried: Opnieuw geprobeerd
|
64
63
|
running: Rennen
|
65
64
|
scheduled: Gepland
|
65
|
+
succeeded: Geslaagd
|
66
66
|
number:
|
67
67
|
format:
|
68
68
|
delimiter: "."
|
data/config/locales/ru.yml
CHANGED
data/lib/good_job/version.rb
CHANGED
data/lib/good_job.rb
CHANGED
@@ -157,7 +157,7 @@ module GoodJob
|
|
157
157
|
|
158
158
|
ActiveSupport::Notifications.instrument("cleanup_preserved_jobs.good_job", { older_than: older_than, timestamp: timestamp }) do |payload|
|
159
159
|
old_jobs = GoodJob::Job.where('finished_at <= ?', timestamp)
|
160
|
-
old_jobs = old_jobs.
|
160
|
+
old_jobs = old_jobs.succeeded unless include_discarded
|
161
161
|
old_jobs_count = old_jobs.count
|
162
162
|
|
163
163
|
GoodJob::Execution.where(job: old_jobs).delete_all
|
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: 3.
|
4
|
+
version: 3.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Sheldon
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activejob
|
@@ -252,16 +252,16 @@ dependencies:
|
|
252
252
|
name: puma
|
253
253
|
requirement: !ruby/object:Gem::Requirement
|
254
254
|
requirements:
|
255
|
-
- - "
|
255
|
+
- - "~>"
|
256
256
|
- !ruby/object:Gem::Version
|
257
|
-
version: '
|
257
|
+
version: '5.6'
|
258
258
|
type: :development
|
259
259
|
prerelease: false
|
260
260
|
version_requirements: !ruby/object:Gem::Requirement
|
261
261
|
requirements:
|
262
|
-
- - "
|
262
|
+
- - "~>"
|
263
263
|
- !ruby/object:Gem::Version
|
264
|
-
version: '
|
264
|
+
version: '5.6'
|
265
265
|
- !ruby/object:Gem::Dependency
|
266
266
|
name: rspec-rails
|
267
267
|
requirement: !ruby/object:Gem::Requirement
|