Class: RoundhouseUi::DeadController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- RoundhouseUi::DeadController
- Includes:
- JobSetBrowsing
- Defined in:
- app/controllers/roundhouse_ui/dead_controller.rb
Constant Summary
Constants included from JobSetBrowsing
JobSetBrowsing::BULK_CAP, JobSetBrowsing::FILTER_KEYS, JobSetBrowsing::MAX_QUERY_LENGTH, JobSetBrowsing::NO_FILTER, JobSetBrowsing::PER_PAGE
Constants inherited from ApplicationController
ApplicationController::AUDIT_VERBS
Instance Method Summary collapse
-
#bulk ⇒ Object
Act on many at once: retry or delete every selected job in one request.
-
#bulk_all ⇒ Object
Smart bulk: act on EVERY job matching the current filter (not just the selected/visible ones), capped for safety.
- #destroy ⇒ Object
- #index ⇒ Object
-
#preview ⇒ Object
A dry run: the count tells you how many match, this tells you which (#37).
- #requeue ⇒ Object
Methods included from JobSetBrowsing
#active_filters, #browse, #bulk_apply, #bulk_filter_present?, #bulk_matches, #bulk_refusal_reason, #class_filter, #entry_matches?, #entry_selected?, #entry_tagged?, #entry_tags, #error_filter, #filter, #load_filters, #query_refused?, #queue_filter, #tag_cache_for, #tag_filter
Methods inherited from ApplicationController
allow_in_read_only, guard_in_read_only, #redirect_to, requires_capability
Instance Method Details
#bulk ⇒ Object
Act on many at once: retry or delete every selected job in one request.
26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/roundhouse_ui/dead_controller.rb', line 26 def bulk set = backend.dead_set count = 0 Array(params[:jids]).each do |jid| entry = set.find_job(jid) or next params[:op] == "delete" ? entry.delete : entry.retry count += 1 end verb = params[:op] == "delete" ? "Deleted" : "Re-enqueued" redirect_to dead_set_path, notice: "#{verb} #{count} job(s)." end |
#bulk_all ⇒ Object
Smart bulk: act on EVERY job matching the current filter (not just the selected/visible ones), capped for safety. Only offered when a filter is active, so it can't become "retry the entire dead set" by accident.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/controllers/roundhouse_ui/dead_controller.rb', line 41 def bulk_all found = bulk_apply(backend.dead_set, @query, params[:op], BULK_CAP, tag: @tag) # An unfiltered bulk_all selected every entry and reported it as a match. # The comment above claimed this was "only offered when a filter is active" — # and it was only OFFERED that way; the route had no gate. bulk_matches now # refuses at the chokepoint, and this says so out loud rather than reporting # "Deleted 0 matching job(s)", which would read like an empty set. if found.unfiltered return redirect_to dead_set_path, alert: found.reason end verb = params[:op] == "delete" ? "Deleted" : "Re-enqueued" note = "#{verb} #{found.entries.size} matching job(s)." note += " Stopped at the #{JobSetBrowsing::BULK_CAP} cap — run again for more." if found.capped redirect_to dead_set_path, notice: note end |
#destroy ⇒ Object
19 20 21 22 23 |
# File 'app/controllers/roundhouse_ui/dead_controller.rb', line 19 def destroy entry = backend.dead_set.find_job(params[:jid]) entry&.delete redirect_to dead_set_path, notice: entry ? "Deleted #{params[:jid]}." : "Job is no longer in the dead set." end |
#index ⇒ Object
7 8 9 10 11 |
# File 'app/controllers/roundhouse_ui/dead_controller.rb', line 7 def index @page = [ params[:page].to_i, 1 ].max @total = backend.dead_set.size @jobs, @has_next = browse(backend.dead_set, @query, @page, PER_PAGE, tag: @tag) end |
#preview ⇒ Object
A dry run: the count tells you how many match, this tells you which (#37).
60 61 62 63 64 65 66 67 68 |
# File 'app/controllers/roundhouse_ui/dead_controller.rb', line 60 def preview @op = params[:op] == "delete" ? "delete" : "retry" @matched = bulk_matches(backend.dead_set, @query, JobSetBrowsing::BULK_CAP, tag: @tag) @confirm_path = bulk_all_dead_path @back_path = dead_set_path @set = "dead" @noun = "dead job" render "roundhouse_ui/shared/bulk_preview" end |
#requeue ⇒ Object
13 14 15 16 17 |
# File 'app/controllers/roundhouse_ui/dead_controller.rb', line 13 def requeue entry = backend.dead_set.find_job(params[:jid]) entry&.retry redirect_to dead_set_path, notice: entry ? "Re-enqueued #{params[:jid]}." : "Job is no longer in the dead set." end |