Class: RoundhouseUi::DeadController

Inherits:
ApplicationController show all
Includes:
JobSetBrowsing
Defined in:
app/controllers/roundhouse_ui/dead_controller.rb

Constant Summary

Constants included from JobSetBrowsing

JobSetBrowsing::BULK_CAP, JobSetBrowsing::PER_PAGE

Constants inherited from ApplicationController

ApplicationController::AUDIT_VERBS

Instance Method Summary collapse

Methods included from JobSetBrowsing

#browse, #bulk_apply, #entry_matches?, #entry_selected?, #entry_tagged?, #entry_tags, #queue_filter, #tag_cache_for, #tag_filter

Methods inherited from ApplicationController

#redirect_to

Instance Method Details

#bulkObject

Act on many at once: retry or delete every selected job in one request.



29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/roundhouse_ui/dead_controller.rb', line 29

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_allObject

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.



44
45
46
47
48
49
50
51
# File 'app/controllers/roundhouse_ui/dead_controller.rb', line 44

def bulk_all
  @queue_filter = queue_filter
  count, capped = bulk_apply(backend.dead_set, params[:q].to_s.strip, params[:op], BULK_CAP, tag: tag_filter)
  verb = params[:op] == "delete" ? "Deleted" : "Re-enqueued"
  note = "#{verb} #{count} matching job(s)."
  note += " Stopped at the #{JobSetBrowsing::BULK_CAP} cap — run again for more." if capped
  redirect_to dead_set_path, notice: note
end

#destroyObject



22
23
24
25
26
# File 'app/controllers/roundhouse_ui/dead_controller.rb', line 22

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

#indexObject



7
8
9
10
11
12
13
14
# File 'app/controllers/roundhouse_ui/dead_controller.rb', line 7

def index
  @query = params[:q].to_s.strip
  @page  = [ params[:page].to_i, 1 ].max
  @total = backend.dead_set.size
  @tag = tag_filter
  @queue_filter = queue_filter
  @jobs, @has_next = browse(backend.dead_set, @query, @page, PER_PAGE, tag: @tag)
end

#requeueObject



16
17
18
19
20
# File 'app/controllers/roundhouse_ui/dead_controller.rb', line 16

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