good_job 3.26.0 → 3.26.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: a51ff44544ae7fb381fce50f13d3196d6a561bcdc6a5af7f37ad1e8fb0d6b258
4
- data.tar.gz: 3703fe631d3f549bb152999203e5d67ac6d305c4ac77bba5b47621f3419cef21
3
+ metadata.gz: cd8ee28330829da54e9a3aa54e26b346c5a36749cadbe957871e800d7cd896fd
4
+ data.tar.gz: 42fd6406fafafff7a8635908db73c8a4159db1e86178551e1245d81c6485e943
5
5
  SHA512:
6
- metadata.gz: ba6647af970ee04455977ccdfb835ac03648bc544ae3606e69e2007d04bf13634f0767c1263738d04101a6839949affd3227a19b1b573d27a6cb8bb4ea56a5b6
7
- data.tar.gz: 3c8e79ae13f69d050f35aea95ebaf4c035a97138a89d24c57430776909d44c9fbbd9a5ab4460ca30efd65c2c16ec231780957c555f43a77dc100388dbfffb341
6
+ metadata.gz: 1b63f85473716cc66d12ff3886c3968606c0e6eff11d43b9ea49524419ba6f55841d3662660169712a5aca1b7715c9c50a9927626bc3416d495634864082effd
7
+ data.tar.gz: 83d2f99ca7aa3357af7625adbf05ab970b64fa9d6145d865ae045c737e7c8637e31b2da878e710db29feb2cf04a9dc63388663067bb096a6e2495e3d16b03367
data/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # Changelog
2
2
 
3
+ ## [v3.26.2](https://github.com/bensheldon/good_job/tree/v3.26.2) (2024-03-15)
4
+
5
+ [Full Changelog](https://github.com/bensheldon/good_job/compare/v3.26.1...v3.26.2)
6
+
7
+ **Closed issues:**
8
+
9
+ - Async mode blocks ActionDispatch::Reloader [\#1274](https://github.com/bensheldon/good_job/issues/1274)
10
+
11
+ **Merged pull requests:**
12
+
13
+ - Update dependencies and their Sorbet / Tapioca files [\#1284](https://github.com/bensheldon/good_job/pull/1284) ([bensheldon](https://github.com/bensheldon))
14
+ - Use require\_relative and do not modify $LOAD\_PATH in gemspec [\#1283](https://github.com/bensheldon/good_job/pull/1283) ([bensheldon](https://github.com/bensheldon))
15
+ - Tweak rbtrace script [\#1279](https://github.com/bensheldon/good_job/pull/1279) ([bensheldon](https://github.com/bensheldon))
16
+ - Fix for Rails head: Don't try to override connection on connection checkin in tests [\#1277](https://github.com/bensheldon/good_job/pull/1277) ([bensheldon](https://github.com/bensheldon))
17
+ - Tiny improvements to french translation [\#1273](https://github.com/bensheldon/good_job/pull/1273) ([francois-ferrandis](https://github.com/francois-ferrandis))
18
+ - Load metrics for top nav asynchronously [\#1231](https://github.com/bensheldon/good_job/pull/1231) ([binarygit](https://github.com/binarygit))
19
+
20
+ ## [v3.26.1](https://github.com/bensheldon/good_job/tree/v3.26.1) (2024-03-01)
21
+
22
+ [Full Changelog](https://github.com/bensheldon/good_job/compare/v3.26.0...v3.26.1)
23
+
24
+ **Fixed bugs:**
25
+
26
+ - Ignore job deserialization errors when mass-retrying through the dashboard [\#1269](https://github.com/bensheldon/good_job/pull/1269) ([bensheldon](https://github.com/bensheldon))
27
+
28
+ **Closed issues:**
29
+
30
+ - Plain HTTP 500 Error when retrying a job for deleted record [\#1263](https://github.com/bensheldon/good_job/issues/1263)
31
+
3
32
  ## [v3.26.0](https://github.com/bensheldon/good_job/tree/v3.26.0) (2024-03-01)
4
33
 
5
34
  [Full Changelog](https://github.com/bensheldon/good_job/compare/v3.25.0...v3.26.0)
@@ -44,10 +44,13 @@ module GoodJob
44
44
  end
45
45
 
46
46
  job
47
- rescue GoodJob::Job::ActionForStateMismatchError, GoodJob::AdvisoryLockable::RecordAlreadyAdvisoryLockedError
47
+ rescue GoodJob::Job::ActiveJobDeserializationError,
48
+ GoodJob::Job::ActionForStateMismatchError,
49
+ GoodJob::AdvisoryLockable::RecordAlreadyAdvisoryLockedError
48
50
  nil
49
51
  end.compact
50
52
 
53
+ # TODO: Put these messages through I18n
51
54
  notice = if processed_jobs.any?
52
55
  "Successfully #{ACTIONS[mass_action]} #{processed_jobs.count} #{'job'.pluralize(processed_jobs.count)}"
53
56
  else
@@ -94,11 +97,14 @@ module GoodJob
94
97
  private
95
98
 
96
99
  def redirect_on_error(exception)
100
+ # TODO: Put these messages through I18n
97
101
  alert = case exception
98
102
  when GoodJob::Job::AdapterNotGoodJobError
99
103
  "Active Job Queue Adapter must be GoodJob."
100
104
  when GoodJob::Job::ActionForStateMismatchError
101
105
  "Job is not in an appropriate state for this action."
106
+ when GoodJob::Job::ActiveJobDeserializationError
107
+ "Active Job data could not be deserialized."
102
108
  else
103
109
  exception.to_s
104
110
  end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GoodJob
4
+ class MetricsController < ApplicationController
5
+ def primary_nav
6
+ jobs_count = GoodJob::Job.count
7
+ batches_count = GoodJob::BatchRecord.migrated? ? GoodJob::BatchRecord.all.size : 0
8
+ cron_entries_count = GoodJob::CronEntry.all.size
9
+ processes_count = GoodJob::Process.active.count
10
+
11
+ render json: {
12
+ jobs_count: number_to_human(jobs_count),
13
+ batches_count: number_to_human(batches_count),
14
+ cron_entries_count: number_to_human(cron_entries_count),
15
+ processes_count: number_to_human(processes_count),
16
+ }
17
+ end
18
+
19
+ private
20
+
21
+ def number_to_human(count)
22
+ helpers.number_to_human(count, **helpers.translate_hash("good_job.number.human.decimal_units"))
23
+ end
24
+ end
25
+ end
@@ -9,8 +9,10 @@ import LivePoll from "live_poll";
9
9
 
10
10
  import { Application } from "stimulus";
11
11
  import ThemeController from "theme_controller";
12
+ import AsyncValuesController from "async_values_controller";
12
13
  window.Stimulus = Application.start();
13
14
  Stimulus.register("theme", ThemeController)
15
+ Stimulus.register("async-values", AsyncValuesController)
14
16
 
15
17
  documentReady(function() {
16
18
  renderCharts();
@@ -0,0 +1,31 @@
1
+ import {Controller} from "stimulus"
2
+
3
+ // Fetches JSON values from the server and updates the targets with the response.
4
+ export default class extends Controller {
5
+ static values = {
6
+ url: String,
7
+ }
8
+ static targets = ["value"]
9
+
10
+ connect() {
11
+ this.#fetch();
12
+ }
13
+
14
+ async #fetch() {
15
+ const data = await fetch(this.urlValue).then(response => response.json())
16
+ this.valueTargets.forEach((target) => {
17
+ target.textContent = data[target.dataset['asyncValuesKey']];
18
+ target.classList.remove('d-none');
19
+
20
+ // When `data-async-values-zero-class="css-class"` is set, add `css-class` to the target if the value is "0"
21
+ if (target.dataset['asyncValuesZeroClass']) {
22
+ const className = target.dataset['asyncValuesZeroClass'];
23
+ if (data[target.dataset['asyncValuesKey']] === "0") {
24
+ target.classList.add(className);
25
+ } else {
26
+ target.classList.remove(className);
27
+ }
28
+ }
29
+ });
30
+ }
31
+ }
@@ -104,8 +104,10 @@ module GoodJob
104
104
  def active_job(ignore_deserialization_errors: false)
105
105
  ActiveJob::Base.deserialize(active_job_data).tap do |aj|
106
106
  aj.send(:deserialize_arguments_if_needed)
107
+ rescue ActiveJob::DeserializationError
108
+ raise unless ignore_deserialization_errors
107
109
  end
108
- rescue ActiveJob::DeserializationError, NameError
110
+ rescue NameError
109
111
  raise unless ignore_deserialization_errors
110
112
  end
111
113
 
@@ -13,6 +13,8 @@ module GoodJob
13
13
  AdapterNotGoodJobError = Class.new(StandardError)
14
14
  # Attached to a Job's Execution when the Job is discarded.
15
15
  DiscardJobError = Class.new(StandardError)
16
+ # Raised when Active Job data cannot be deserialized
17
+ ActiveJobDeserializationError = Class.new(StandardError)
16
18
 
17
19
  class << self
18
20
  delegate :table_name, to: GoodJob::Execution
@@ -186,8 +188,9 @@ module GoodJob
186
188
  def retry_job
187
189
  with_advisory_lock do
188
190
  execution = head_execution(reload: true)
189
- active_job = execution.active_job
191
+ active_job = execution.active_job(ignore_deserialization_errors: true)
190
192
 
193
+ raise ActiveJobDeserializationError if active_job.nil?
191
194
  raise AdapterNotGoodJobError unless active_job.class.queue_adapter.is_a? GoodJob::Adapter
192
195
  raise ActionForStateMismatchError if execution.finished_at.blank? || execution.error.blank?
193
196
 
@@ -14,33 +14,29 @@
14
14
  </button>
15
15
 
16
16
  <div class="collapse navbar-collapse" id="navbarSupportedContent">
17
- <ul class="navbar-nav me-auto">
17
+ <ul class="navbar-nav me-auto" data-controller="async-values" data-async-values-url-value="<%= metrics_primary_nav_path %>">
18
18
  <li class="nav-item">
19
19
  <%= link_to jobs_path, class: ["nav-link", ("active" if controller_name == 'jobs')] do %>
20
20
  <%= t(".jobs") %>
21
- <% jobs_count = GoodJob::Job.count %>
22
- <span class="badge bg-secondary rounded-pill"><%= number_to_human(jobs_count, **translate_hash("good_job.number.human.decimal_units")) %></span>
21
+ <span data-async-values-target="value" data-async-values-key="jobs_count" class="badge bg-secondary rounded-pill d-none"></span>
23
22
  <% end %>
24
23
  </li>
25
24
  <li class="nav-item">
26
25
  <%= link_to batches_path, class: ["nav-link", ("active" if controller_name == 'batches')] do %>
27
26
  <%=t ".batches" %>
28
- <% batches_count = GoodJob::BatchRecord.migrated? ? GoodJob::BatchRecord.all.size : 0 %>
29
- <span class="badge bg-secondary rounded-pill"><%= number_to_human(batches_count, **translate_hash("good_job.number.human.decimal_units")) %></span>
27
+ <span data-async-values-target="value" data-async-values-key="batches_count" class="badge bg-secondary rounded-pill d-none"></span>
30
28
  <% end %>
31
29
  </li>
32
30
  <li class="nav-item">
33
31
  <%= link_to cron_entries_path, class: ["nav-link", ("active" if controller_name == 'cron_entries')] do %>
34
32
  <%= t(".cron_schedules") %>
35
- <% cron_entries_count = GoodJob::CronEntry.all.size %>
36
- <span class="badge bg-secondary rounded-pill"><%= cron_entries_count %></span>
33
+ <span data-async-values-target="value" data-async-values-key="cron_entries_count" class="badge bg-secondary rounded-pill d-none"></span>
37
34
  <% end %>
38
35
  </li>
39
36
  <li class="nav-item">
40
37
  <%= link_to processes_path, class: ["nav-link", ("active" if controller_name == 'processes')] do %>
41
38
  <%= t(".processes") %>
42
- <% processes_count = GoodJob::Process.active.count %>
43
- <span class="badge bg-secondary rounded-pill <%= "bg-danger" if processes_count == 0 %>"><%= processes_count %></span>
39
+ <span data-async-values-target="value" data-async-values-key="processes_count" data-async-values-zero-class="bg-danger" class="badge bg-secondary rounded-pill d-none"></span>
44
40
  <% end %>
45
41
  </li>
46
42
  </ul>
@@ -214,11 +214,11 @@ fr:
214
214
  all: Tous
215
215
  all_jobs: Tous les jobs
216
216
  all_queues: Toutes les files d'attente
217
- clear: Clair
217
+ clear: Réinitialiser
218
218
  job_name: Nom du job
219
219
  placeholder: Recherche par classe, ID de job, paramètres de job et texte d'erreur.
220
220
  queue_name: Nom de la file d'attente
221
- search: Recherche
221
+ search: Rechercher
222
222
  navbar:
223
223
  batches: Lots
224
224
  cron_schedules: Cron
@@ -232,12 +232,12 @@ fr:
232
232
  light: Lumière
233
233
  theme: Thème
234
234
  secondary_navbar:
235
- inspiration: N'oublie pas, toi aussi tu fais du bon boulot !
235
+ inspiration: N'oublie pas, toi aussi tu fais du bon boulot !
236
236
  last_updated: Dernière mise à jour
237
237
  status:
238
238
  discarded: Mis au rebut
239
239
  queued: À la file
240
240
  retried: Réessayés
241
241
  running: En cours
242
- scheduled: Replanifiés
242
+ scheduled: Planifiés
243
243
  succeeded: Réussis
data/config/routes.rb CHANGED
@@ -16,6 +16,7 @@ GoodJob::Engine.routes.draw do
16
16
  put :retry
17
17
  end
18
18
  end
19
+ get 'jobs/metrics/primary_nav', to: 'metrics#primary_nav', as: :metrics_primary_nav
19
20
 
20
21
  resources :batches, only: %i[index show]
21
22
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module GoodJob
4
4
  # GoodJob gem version.
5
- VERSION = '3.26.0'
5
+ VERSION = '3.26.2'
6
6
 
7
7
  # GoodJob version as Gem::Version object
8
8
  GEM_VERSION = Gem::Version.new(VERSION)
data/lib/good_job.rb CHANGED
@@ -3,44 +3,44 @@
3
3
  require "active_job"
4
4
  require "active_job/queue_adapters"
5
5
 
6
- require "good_job/version"
7
- require "good_job/engine"
8
-
9
- require "good_job/adapter"
10
- require "active_job/queue_adapters/good_job_adapter"
11
- require "good_job/active_job_extensions/batches"
12
- require "good_job/active_job_extensions/concurrency"
13
- require "good_job/interrupt_error"
14
- require "good_job/active_job_extensions/interrupt_errors"
15
- require "good_job/active_job_extensions/labels"
16
- require "good_job/active_job_extensions/notify_options"
17
-
18
- require "good_job/overridable_connection"
19
- require "good_job/bulk"
20
- require "good_job/callable"
21
- require "good_job/capsule"
22
- require "good_job/cleanup_tracker"
23
- require "good_job/cli"
24
- require "good_job/configuration"
25
- require "good_job/cron_manager"
26
- require "good_job/current_thread"
27
- require "good_job/daemon"
28
- require "good_job/dependencies"
29
- require "good_job/job_performer"
30
- require "good_job/job_performer/metrics"
31
- require "good_job/log_subscriber"
32
- require "good_job/multi_scheduler"
33
- require "good_job/notifier"
34
- require "good_job/poller"
35
- require "good_job/probe_server"
36
- require "good_job/probe_server/healthcheck_middleware"
37
- require "good_job/probe_server/not_found_app"
38
- require "good_job/probe_server/simple_handler"
39
- require "good_job/probe_server/webrick_handler"
40
- require "good_job/scheduler"
41
- require "good_job/shared_executor"
42
- require "good_job/systemd_service"
43
- require "good_job/thread_status"
6
+ require_relative "good_job/version"
7
+ require_relative "good_job/engine"
8
+
9
+ require_relative "good_job/adapter"
10
+ require_relative "active_job/queue_adapters/good_job_adapter"
11
+ require_relative "good_job/active_job_extensions/batches"
12
+ require_relative "good_job/active_job_extensions/concurrency"
13
+ require_relative "good_job/interrupt_error"
14
+ require_relative "good_job/active_job_extensions/interrupt_errors"
15
+ require_relative "good_job/active_job_extensions/labels"
16
+ require_relative "good_job/active_job_extensions/notify_options"
17
+
18
+ require_relative "good_job/overridable_connection"
19
+ require_relative "good_job/bulk"
20
+ require_relative "good_job/callable"
21
+ require_relative "good_job/capsule"
22
+ require_relative "good_job/cleanup_tracker"
23
+ require_relative "good_job/cli"
24
+ require_relative "good_job/configuration"
25
+ require_relative "good_job/cron_manager"
26
+ require_relative "good_job/current_thread"
27
+ require_relative "good_job/daemon"
28
+ require_relative "good_job/dependencies"
29
+ require_relative "good_job/job_performer"
30
+ require_relative "good_job/job_performer/metrics"
31
+ require_relative "good_job/log_subscriber"
32
+ require_relative "good_job/multi_scheduler"
33
+ require_relative "good_job/notifier"
34
+ require_relative "good_job/poller"
35
+ require_relative "good_job/probe_server"
36
+ require_relative "good_job/probe_server/healthcheck_middleware"
37
+ require_relative "good_job/probe_server/not_found_app"
38
+ require_relative "good_job/probe_server/simple_handler"
39
+ require_relative "good_job/probe_server/webrick_handler"
40
+ require_relative "good_job/scheduler"
41
+ require_relative "good_job/shared_executor"
42
+ require_relative "good_job/systemd_service"
43
+ require_relative "good_job/thread_status"
44
44
 
45
45
  # GoodJob is a multithreaded, Postgres-based, ActiveJob backend for Ruby on Rails.
46
46
  #
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.26.0
4
+ version: 3.26.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Sheldon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-01 00:00:00.000000000 Z
11
+ date: 2024-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activejob
@@ -168,16 +168,16 @@ dependencies:
168
168
  name: puma
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
- - - "~>"
171
+ - - ">="
172
172
  - !ruby/object:Gem::Version
173
- version: '5.6'
173
+ version: '0'
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
- - - "~>"
178
+ - - ">="
179
179
  - !ruby/object:Gem::Version
180
- version: '5.6'
180
+ version: '0'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: rspec-rails
183
183
  requirement: !ruby/object:Gem::Requirement
@@ -268,11 +268,13 @@ files:
268
268
  - app/controllers/good_job/cron_entries_controller.rb
269
269
  - app/controllers/good_job/frontends_controller.rb
270
270
  - app/controllers/good_job/jobs_controller.rb
271
+ - app/controllers/good_job/metrics_controller.rb
271
272
  - app/controllers/good_job/processes_controller.rb
272
273
  - app/filters/good_job/base_filter.rb
273
274
  - app/filters/good_job/batches_filter.rb
274
275
  - app/filters/good_job/jobs_filter.rb
275
276
  - app/frontend/good_job/application.js
277
+ - app/frontend/good_job/modules/async_values_controller.js
276
278
  - app/frontend/good_job/modules/charts.js
277
279
  - app/frontend/good_job/modules/checkbox_toggle.js
278
280
  - app/frontend/good_job/modules/document_ready.js