Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gemspec

gem "capybara", github: "teamcapybara/capybara"
# Use `path: "../solid_queue"` when co-developing locally
gem "solid_queue", github: "jpcamara/solid_queue", branch: "batch-review-fixes"

# minitest 6 is incompatible with railties 7.2 line filtering
gem "minitest", "~> 5.25"
140 changes: 81 additions & 59 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
GIT
remote: https://github.com/jpcamara/solid_queue.git
revision: cbfa930444fc85dad2065df10ebd4dea85fdb933
branch: batch-review-fixes
specs:
solid_queue (1.5.0)
activejob (>= 7.1)
activerecord (>= 7.1)
concurrent-ruby (>= 1.3.1)
fugit (~> 1.11)
railties (>= 7.1)
thor (>= 1.3.1)

GIT
remote: https://github.com/teamcapybara/capybara.git
revision: c0cbf4024c1abd48b0c22c2930e7b05af58ab284
Expand Down Expand Up @@ -76,103 +89,111 @@ GEM
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
ast (2.4.2)
base64 (0.2.0)
benchmark (0.3.0)
base64 (0.3.0)
benchmark (0.5.0)
better_html (2.1.1)
actionview (>= 6.0)
activesupport (>= 6.0)
ast (~> 2.0)
erubi (~> 1.4)
parser (>= 2.4)
smart_properties
bigdecimal (3.1.8)
bigdecimal (4.1.2)
builder (3.3.0)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
crass (1.0.6)
concurrent-ruby (1.3.8)
connection_pool (3.0.2)
crass (1.0.7)
debug (1.9.1)
irb (~> 1.10)
reline (>= 0.3.8)
drb (2.2.1)
erubi (1.13.0)
et-orbi (1.2.11)
drb (2.2.3)
erb (6.0.6)
erubi (1.13.1)
et-orbi (1.4.0)
tzinfo
fugit (1.11.1)
et-orbi (~> 1, >= 1.2.11)
fugit (1.13.0)
et-orbi (~> 1.4)
raabro (~> 1.4)
globalid (1.2.1)
globalid (1.4.0)
activesupport (>= 6.1)
i18n (1.14.6)
i18n (1.15.2)
concurrent-ruby (~> 1.0)
importmap-rails (2.0.1)
actionpack (>= 6.0.0)
activesupport (>= 6.0.0)
railties (>= 6.0.0)
io-console (0.7.2)
irb (1.14.1)
io-console (0.8.2)
irb (1.18.0)
pp (>= 0.6.0)
prism (>= 1.3.0)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
json (2.7.1)
logger (1.6.1)
loofah (2.23.1)
logger (1.7.0)
loofah (2.25.2)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
matrix (0.4.2)
mini_mime (1.1.5)
minitest (5.25.1)
mini_portile2 (2.8.9)
minitest (5.27.0)
mocha (2.1.0)
ruby2_keywords (>= 0.0.5)
mono_logger (1.1.2)
multi_json (1.15.0)
mustermann (3.0.3)
ruby2_keywords (~> 0.0.1)
nio4r (2.7.4)
nokogiri (1.16.7-aarch64-linux)
nokogiri (1.19.4)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
nokogiri (1.16.7-arm-linux)
nokogiri (1.19.4-aarch64-linux-gnu)
racc (~> 1.4)
nokogiri (1.16.7-arm64-darwin)
nokogiri (1.19.4-arm-linux-gnu)
racc (~> 1.4)
nokogiri (1.16.7-x86-linux)
nokogiri (1.19.4-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.7-x86_64-darwin)
nokogiri (1.19.4-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.16.7-x86_64-linux)
nokogiri (1.19.4-x86_64-linux-gnu)
racc (~> 1.4)
parallel (1.24.0)
parser (3.3.0.5)
ast (~> 2.4.1)
racc
pp (0.6.4)
prettyprint
prettyprint (0.2.0)
prism (1.9.0)
propshaft (1.1.0)
actionpack (>= 7.0.0)
activesupport (>= 7.0.0)
rack
railties (>= 7.0.0)
psych (5.1.2)
stringio
public_suffix (5.0.4)
puma (6.4.3)
nio4r (~> 2.0)
raabro (1.4.0)
raabro (1.5.0)
racc (1.8.1)
rack (3.1.8)
rack (3.1.21)
rack-protection (4.1.0)
base64 (>= 0.1.0)
logger (>= 1.6.0)
rack (>= 3.0.0, < 4)
rack-session (2.0.0)
rack-session (2.1.2)
base64 (>= 0.1.0)
rack (>= 3.0.0)
rack-test (2.1.0)
rack-test (2.2.0)
rack (>= 1.3)
rackup (2.2.0)
rackup (2.3.1)
rack (>= 3)
rails-dom-testing (2.2.0)
rails-dom-testing (2.3.0)
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
rails-html-sanitizer (1.7.1)
loofah (~> 2.25, >= 2.25.2)
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
railties (7.2.2)
actionpack (= 7.2.2)
activesupport (= 7.2.2)
Expand All @@ -182,17 +203,24 @@ GEM
thor (~> 1.0, >= 1.2.2)
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.2.1)
rdoc (6.7.0)
psych (>= 4.0.0)
rake (13.4.2)
rbs (4.1.0)
logger
prism (>= 1.6.0)
tsort
rdoc (8.0.0)
erb
prism (>= 1.6.0)
rbs (>= 4.0.0)
tsort
redis (5.1.0)
redis-client (>= 0.17.0)
redis-client (0.21.0)
connection_pool
redis-namespace (1.11.0)
redis (>= 4)
regexp_parser (2.9.0)
reline (0.5.10)
reline (0.6.3)
io-console (~> 0.5)
resque (2.6.0)
mono_logger (~> 1.0)
Expand Down Expand Up @@ -234,7 +262,7 @@ GEM
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
securerandom (0.3.1)
securerandom (0.4.1)
selenium-webdriver (4.18.1)
base64 (~> 0.2)
rexml (~> 3.2, >= 3.2.5)
Expand All @@ -248,40 +276,33 @@ GEM
rack-session (>= 2.0.0, < 3)
tilt (~> 2.0)
smart_properties (1.17.0)
solid_queue (1.0.1)
activejob (>= 7.1)
activerecord (>= 7.1)
concurrent-ruby (>= 1.3.1)
fugit (~> 1.11.0)
railties (>= 7.1)
thor (~> 1.3.1)
sqlite3 (2.2.0-aarch64-linux-gnu)
sqlite3 (2.2.0-arm-linux-gnu)
sqlite3 (2.2.0-arm64-darwin)
sqlite3 (2.2.0-x86-linux-gnu)
sqlite3 (2.2.0-x86_64-darwin)
sqlite3 (2.2.0-x86_64-linux-gnu)
sqlite3 (2.9.5-aarch64-linux-gnu)
sqlite3 (2.9.5-arm-linux-gnu)
sqlite3 (2.9.5-arm64-darwin)
sqlite3 (2.9.5-x86-linux-gnu)
sqlite3 (2.9.5-x86_64-darwin)
sqlite3 (2.9.5-x86_64-linux-gnu)
stimulus-rails (1.3.3)
railties (>= 6.0.0)
stringio (3.1.1)
thor (1.3.2)
thor (1.5.0)
tilt (2.4.0)
timeout (0.4.1)
timeout (0.6.1)
tsort (0.2.0)
turbo-rails (2.0.5)
actionpack (>= 6.0.0)
activejob (>= 6.0.0)
railties (>= 6.0.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
useragent (0.16.10)
useragent (0.16.11)
websocket (1.2.10)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.7.1)
zeitwerk (2.8.2)

PLATFORMS
aarch64-linux
Expand All @@ -295,6 +316,7 @@ DEPENDENCIES
better_html
capybara!
debug
minitest (~> 5.25)
mission_control-jobs!
mocha
propshaft
Expand All @@ -307,7 +329,7 @@ DEPENDENCIES
rubocop-performance
rubocop-rails-omakase
selenium-webdriver
solid_queue (~> 1.0.1)
solid_queue!
sqlite3

BUNDLED WITH
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module MissionControl::Jobs::AdapterFeatures
extend ActiveSupport::Concern

included do
helper_method :supported_job_statuses, :queue_pausing_supported?, :workers_exposed?, :recurring_tasks_supported?
helper_method :supported_job_statuses, :queue_pausing_supported?, :workers_exposed?, :recurring_tasks_supported?, :batches_supported?
end

private
Expand All @@ -21,4 +21,8 @@ def workers_exposed?
def recurring_tasks_supported?
MissionControl::Jobs::Current.server.queue_adapter.supports_recurring_tasks?
end

def batches_supported?
MissionControl::Jobs::Current.server.queue_adapter.supports_batches?
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def best_location_for_job_relation(job_relation)
def best_location_for_resource_not_found_error(error)
if error.message.match?(/recurring task/i)
application_recurring_tasks_path(@application)
elsif error.message.match?(/batch/i)
application_batches_path(@application)
else
root_url
end
Expand Down
59 changes: 59 additions & 0 deletions app/controllers/mission_control/jobs/batches_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
class MissionControl::Jobs::BatchesController < MissionControl::Jobs::ApplicationController
UNFINISHED_JOB_STATUSES = %i[ pending in_progress blocked scheduled ]
BATCHES_STATUSES = %w[ finished unfinished failed ]

before_action :ensure_supported_batches
before_action :set_batch, only: :show

def index
@batches_page = MissionControl::Jobs::Page.new(batches, page: params[:page].to_i)
end

def show
@jobs_page = MissionControl::Jobs::Page.new(@batch.jobs.with_status(jobs_status.to_sym), page: params[:page].to_i)
end

private
def ensure_supported_batches
unless batches_supported?
redirect_to root_url, alert: "This server doesn't support batches"
end
end

def set_batch
@batch = MissionControl::Jobs::Current.server.find_batch(params[:id])
end

def batches
MissionControl::Jobs::Current.server.batches(status: batches_status&.to_sym)
end

helper_method :batches_status, :batches_filter_param, :jobs_status

# Default to unfinished: finished/all populations can be multi-million-row,
# and only unfinished batches are actionable.
def batches_status
requested = params.fetch(:batches_status, "unfinished")
requested.presence_in(BATCHES_STATUSES) unless requested == "all"
end

def batches_filter_param
{ batches_status: batches_status }.compact
end

def jobs_status
if status = params[:jobs_status].presence&.to_sym.presence_in(supported_job_statuses)
status.to_s
elsif @batch.failed?
"failed"
elsif @batch.finished?
"finished"
else
default_unfinished_jobs_status
end
end

def default_unfinished_jobs_status
UNFINISHED_JOB_STATUSES.find { |status| @batch.public_send("#{status}_jobs") > 0 }&.to_s || "pending"
end
end
9 changes: 9 additions & 0 deletions app/helpers/mission_control/jobs/interface_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,13 @@ def modifier_for_status(status)
else "is-primary is-light"
end
end

def modifier_for_batch_status(status)
case status.to_s
when "completed" then "is-success"
when "failed" then "is-danger"
when "enqueued" then "is-info"
else "is-light"
end
end
end
1 change: 1 addition & 0 deletions app/helpers/mission_control/jobs/navigation_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def navigation_sections

sections[:workers] = [ "Workers", application_workers_path(@application) ] if workers_exposed?
sections[:recurring_tasks] = [ "Recurring tasks", application_recurring_tasks_path(@application) ] if recurring_tasks_supported?
sections[:batches] = [ "Batches", application_batches_path(@application) ] if batches_supported?
end
end

Expand Down
Loading