mission_control-jobs 0.3.0 → 0.3.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: ced6558306cb1d5dce82b59a848a16904e39600a0b65982b124a9788d4d47989
4
- data.tar.gz: 2a973ec0f123903d0ecd42f47d19e2f213d2659fed58f9521ed7f080ca6c9807
3
+ metadata.gz: d7d0d51d0662e0351ff33ed1b2a480a7f1d11c593eefbe89a630a980de5a1b24
4
+ data.tar.gz: a9c05be3a1b2b0975c3d7095ac3d3433c502b5afd87a942996ced2aa01485b6c
5
5
  SHA512:
6
- metadata.gz: 8a374110adc1bf32f56c680ce5024dce8f2b4d9812380dbbc0af0a3006b56c25614c92b653d4c9738d92601c610e78a2f566f929456b184cf2f08a9f3920ce62
7
- data.tar.gz: 2a7be00afe61ee9f6441e955f85cb4eee5361945c0f6208140cfd0d98883c7d6ec702a4785590c9822c20db9961e7ea089614ec869e37c7571156f0850f2040b
6
+ metadata.gz: de6116de1a5b4fd7b87d4aba9e245953147edaa3cf8dd9e5e464be815dec79d74977dbe60b638246a6fe3625f9cb050aaceb9cd09c73eda857b1756006700328
7
+ data.tar.gz: 4e133652b36ec90c22fc9e77170e985d6b18c1a68ae73ce43361a1ea5be9c14820f8db594ce713bbcf7a8a6540766f9f6d4a5974dd51a9510fb94040f57fde76
data/README.md CHANGED
@@ -65,6 +65,7 @@ This library extends Active Job with a querying interface and the following sett
65
65
  ## Adapter Specifics
66
66
 
67
67
  - **Resque**: Queue pausing is supported only if you have `resque-pause` installed in your project
68
+ - **Solid Queue**: Requires version >= 0.9.
68
69
 
69
70
  ## Advanced configuration
70
71
 
@@ -1,16 +1,2 @@
1
- /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
- * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
- * files in this directory. Styles in this file should be added after the last require_* statement.
11
- * It is generally better to create a new file per style scope.
12
- *
13
- *= require_tree .
14
- *= require_self
15
- */
16
-
1
+ @import url("./forms.css");
2
+ @import url("./jobs.css");
@@ -1,6 +1,14 @@
1
1
  class MissionControl::Jobs::ApplicationController < MissionControl::Jobs.base_controller_class.constantize
2
+ ActionController::Base::MODULES.each do |mod|
3
+ include mod unless self < mod
4
+ end
5
+
2
6
  layout "mission_control/jobs/application"
3
7
 
8
+ # Include helpers if not already included
9
+ helper MissionControl::Jobs::ApplicationHelper unless self < MissionControl::Jobs::ApplicationHelper
10
+ helper Importmap::ImportmapTagsHelper unless self < Importmap::ImportmapTagsHelper
11
+
4
12
  include MissionControl::Jobs::ApplicationScoped, MissionControl::Jobs::NotFoundRedirections
5
13
  include MissionControl::Jobs::AdapterFeatures
6
14
 
@@ -3,6 +3,6 @@ module MissionControl::Jobs
3
3
  # Explicit helper inclusion because ApplicationController inherits from the host app.
4
4
  #
5
5
  # We can't rely on +config.action_controller.include_all_helpers = true+ in the host app.
6
- include DatesHelper, JobsHelper, NavigationHelper, UiHelper
6
+ include DatesHelper, JobsHelper, NavigationHelper, InterfaceHelper
7
7
  end
8
8
  end
@@ -1,4 +1,4 @@
1
- module MissionControl::Jobs::UiHelper
1
+ module MissionControl::Jobs::InterfaceHelper
2
2
  def blank_status_notice(message)
3
3
  tag.div message, class: "mt-6 has-text-centered is-size-3 has-text-grey"
4
4
  end
@@ -1,7 +1,7 @@
1
1
  class MissionControl::Jobs::RecurringTask
2
2
  include ActiveModel::Model
3
3
 
4
- attr_accessor :id, :job_class_name, :arguments, :schedule, :last_enqueued_at
4
+ attr_accessor :id, :job_class_name, :command, :arguments, :schedule, :last_enqueued_at, :queue_name, :priority
5
5
 
6
6
  def initialize(queue_adapter: ActiveJob::Base.queue_adapter, **kwargs)
7
7
  @queue_adapter = queue_adapter
@@ -1,16 +1,37 @@
1
1
  <table class="table">
2
2
  <tbody>
3
- <tr>
4
- <th>Job class</th>
5
- <td><%= recurring_task.job_class_name %></td>
6
- </tr>
7
- <tr>
8
- <th>Arguments</th>
9
- <td><div class="is-family-monospace"><%= recurring_task.arguments.join(",") %></div></td>
10
- </tr>
3
+ <% if recurring_task.job_class_name.present? %>
4
+ <tr>
5
+ <th>Job class</th>
6
+ <td><%= recurring_task.job_class_name %></td>
7
+ </tr>
8
+
9
+ <tr>
10
+ <th>Arguments</th>
11
+ <td><div class="is-family-monospace"><%= recurring_task.arguments.join(",") %></div></td>
12
+ </tr>
13
+ <% elsif recurring_task.command.present? %>
14
+ <tr>
15
+ <th>Command</th>
16
+ <td><div class="is-family-monospace"><%= recurring_task.command %></div></td>
17
+ </tr>
18
+ <% end %>
19
+
11
20
  <tr>
12
21
  <th>Schedule</th>
13
22
  <td><%= recurring_task.schedule %></td>
14
23
  </tr>
24
+ <% if recurring_task.queue_name.present? %>
25
+ <tr>
26
+ <th>Queue</th>
27
+ <td><%= recurring_task.queue_name %></td>
28
+ </tr>
29
+ <% end %>
30
+ <% if recurring_task.priority.present? %>
31
+ <tr>
32
+ <th>Priority</th>
33
+ <td><%= recurring_task.priority %></td>
34
+ </tr>
35
+ <% end %>
15
36
  </tbody>
16
37
  </table>
@@ -3,10 +3,14 @@
3
3
  <%= link_to recurring_task.id, application_recurring_task_path(@application, recurring_task.id) %>
4
4
  </td>
5
5
  <td>
6
- <%= link_to recurring_task.job_class_name, application_recurring_task_path(@application, recurring_task.id) %>
6
+ <% if recurring_task.job_class_name.present? %>
7
+ <%= recurring_task.job_class_name %>
7
8
 
8
- <% if recurring_task.arguments.present? %>
9
- <div class="is-family-monospace"><%= recurring_task.arguments.join(",") %></div>
9
+ <% if recurring_task.arguments.present? %>
10
+ <div class="is-family-monospace"><%= recurring_task.arguments.join(",") %></div>
11
+ <% end %>
12
+ <% elsif recurring_task.command.present? %>
13
+ <div class="is-family-monospace"><%= recurring_task.command %></div>
10
14
  <% end %>
11
15
  </td>
12
16
  <td> <%= recurring_task.schedule %> </td>
@@ -4,36 +4,32 @@ module ActiveJob::QueueAdapters::SolidQueueExt::RecurringTasks
4
4
  end
5
5
 
6
6
  def recurring_tasks
7
- tasks = recurring_tasks_from_dispatchers
8
- last_enqueued_at_times = recurring_task_last_enqueued_at(tasks.keys)
7
+ tasks = SolidQueue::RecurringTask.all
8
+ last_enqueued_at_times = recurring_task_last_enqueued_at(tasks.map(&:key))
9
9
 
10
- recurring_tasks_from_dispatchers.collect do |task_id, task_attrs|
11
- recurring_task_attributes_from_solid_queue_task_attributes(task_attrs).merge \
12
- id: task_id,
13
- last_enqueued_at: last_enqueued_at_times[task_id]
10
+ tasks.collect do |task|
11
+ recurring_task_attributes_from_solid_queue_recurring_task(task).merge \
12
+ last_enqueued_at: last_enqueued_at_times[task.key]
14
13
  end
15
14
  end
16
15
 
17
16
  def find_recurring_task(task_id)
18
- if task_attrs = recurring_tasks_from_dispatchers[task_id]
19
- recurring_task_attributes_from_solid_queue_task_attributes(task_attrs).merge \
20
- id: task_id,
21
- last_enqueued_at: recurring_task_last_enqueued_at(task_id).values&.first
17
+ if task = SolidQueue::RecurringTask.find_by(key: task_id)
18
+ recurring_task_attributes_from_solid_queue_recurring_task(task).merge \
19
+ last_enqueued_at: recurring_task_last_enqueued_at(task.key).values&.first
22
20
  end
23
21
  end
24
22
 
25
23
  private
26
- def recurring_tasks_from_dispatchers
27
- SolidQueue::Process.where(kind: "Dispatcher").flat_map do |process|
28
- process.metadata["recurring_schedule"]
29
- end.compact.reduce({}, &:merge)
30
- end
31
-
32
- def recurring_task_attributes_from_solid_queue_task_attributes(task_attributes)
24
+ def recurring_task_attributes_from_solid_queue_recurring_task(task)
33
25
  {
34
- job_class_name: task_attributes["class_name"],
35
- arguments: task_attributes["arguments"],
36
- schedule: task_attributes["schedule"]
26
+ id: task.key,
27
+ job_class_name: task.class_name,
28
+ command: task.command,
29
+ arguments: task.arguments,
30
+ schedule: task.schedule,
31
+ queue_name: task.queue_name,
32
+ priority: task.priority
37
33
  }
38
34
  end
39
35
 
@@ -118,7 +118,7 @@ module ActiveJob::QueueAdapters::SolidQueueExt
118
118
  ActiveJob::ExecutionError.new \
119
119
  error_class: solid_queue_job.failed_execution.exception_class,
120
120
  message: solid_queue_job.failed_execution.message,
121
- backtrace: solid_queue_job.failed_execution.backtrace
121
+ backtrace: solid_queue_job.failed_execution.backtrace || []
122
122
  end
123
123
  end
124
124
 
@@ -4,12 +4,15 @@ require "mission_control/jobs/engine"
4
4
  require "importmap-rails"
5
5
  require "turbo-rails"
6
6
  require "stimulus-rails"
7
+ require "propshaft"
7
8
 
8
9
  module MissionControl
9
10
  module Jobs
10
11
  class Engine < ::Rails::Engine
11
12
  isolate_namespace MissionControl::Jobs
12
13
 
14
+ config.middleware.use ActionDispatch::Flash unless config.action_dispatch.flash
15
+
13
16
  config.mission_control = ActiveSupport::OrderedOptions.new unless config.try(:mission_control)
14
17
  config.mission_control.jobs = ActiveSupport::OrderedOptions.new
15
18
 
@@ -87,6 +90,7 @@ module MissionControl
87
90
  end
88
91
 
89
92
  initializer "mission_control-jobs.assets" do |app|
93
+ app.config.assets.paths << root.join("app/assets/stylesheets")
90
94
  app.config.assets.paths << root.join("app/javascript")
91
95
  app.config.assets.precompile += %w[ mission_control_jobs_manifest ]
92
96
  end
@@ -1,5 +1,5 @@
1
1
  module MissionControl
2
2
  module Jobs
3
- VERSION = "0.3.0"
3
+ VERSION = "0.3.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mission_control-jobs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jorge Manrubia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-06 00:00:00.000000000 Z
11
+ date: 2024-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '7.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: propshaft
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: importmap-rails
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +114,14 @@ dependencies:
100
114
  requirements:
101
115
  - - ">="
102
116
  - !ruby/object:Gem::Version
103
- version: '0'
117
+ version: '0.9'
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
122
  - - ">="
109
123
  - !ruby/object:Gem::Version
110
- version: '0'
124
+ version: '0.9'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: selenium-webdriver
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -286,7 +300,6 @@ files:
286
300
  - MIT-LICENSE
287
301
  - README.md
288
302
  - Rakefile
289
- - app/assets/config/mission_control_jobs_manifest.js
290
303
  - app/assets/stylesheets/mission_control/jobs/application.css
291
304
  - app/assets/stylesheets/mission_control/jobs/forms.css
292
305
  - app/assets/stylesheets/mission_control/jobs/jobs.css
@@ -310,9 +323,9 @@ files:
310
323
  - app/controllers/mission_control/jobs/workers_controller.rb
311
324
  - app/helpers/mission_control/jobs/application_helper.rb
312
325
  - app/helpers/mission_control/jobs/dates_helper.rb
326
+ - app/helpers/mission_control/jobs/interface_helper.rb
313
327
  - app/helpers/mission_control/jobs/jobs_helper.rb
314
328
  - app/helpers/mission_control/jobs/navigation_helper.rb
315
- - app/helpers/mission_control/jobs/ui_helper.rb
316
329
  - app/javascript/mission_control/jobs/application.js
317
330
  - app/javascript/mission_control/jobs/controllers/application.js
318
331
  - app/javascript/mission_control/jobs/controllers/form_controller.js
@@ -1,4 +0,0 @@
1
- //= link_directory ../stylesheets/mission_control/jobs .css
2
- //= link_directory ../../javascript/mission_control/jobs .js
3
- //= link_directory ../../javascript/mission_control/jobs/controllers .js
4
- //= link_directory ../../javascript/mission_control/jobs/helpers .js