Class: RoundhouseUi::RetriesController

Inherits:
ApplicationController show all
Includes:
JobSetBrowsing
Defined in:
app/controllers/roundhouse_ui/retries_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

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_allObject

Smart bulk: retry/delete EVERY job matching the current filter, capped for safety. Offered only when a filter is active.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/controllers/roundhouse_ui/retries_controller.rb', line 28

def bulk_all
  found = bulk_apply(backend.retry_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 retries_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 retries_path, notice: note
end

#destroyObject



20
21
22
23
24
# File 'app/controllers/roundhouse_ui/retries_controller.rb', line 20

def destroy
  entry = backend.retry_set.find_job(params[:jid])
  entry&.delete
  redirect_to retries_path, notice: entry ? "Deleted #{params[:jid]}." : "Job is no longer in the retry set."
end

#indexObject



7
8
9
10
11
# File 'app/controllers/roundhouse_ui/retries_controller.rb', line 7

def index
  @page  = [ params[:page].to_i, 1 ].max
  @total = backend.retry_set.size
  @jobs, @has_next = browse(backend.retry_set, @query, @page, PER_PAGE, tag: @tag)
end

#previewObject

A dry run: the count tells you how many match, this tells you which (#37).



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'app/controllers/roundhouse_ui/retries_controller.rb', line 47

def preview
  @op = params[:op] == "delete" ? "delete" : "retry"
  @matched = bulk_matches(backend.retry_set, @query, JobSetBrowsing::BULK_CAP, tag: @tag)
  @confirm_path = bulk_all_retries_path
  @back_path = retries_path
  # "retry", not "retries". bulk_preview renders job_path(set: @set) per row, and
  # routes constrain set to /dead|retry|scheduled/ — so this 500'd the dry run
  # before every bulk delete on this page, but ONLY when at least one job
  # matched, because the template touches job_path inside the row loop. An empty
  # preview rendered fine, which is why nothing noticed. Copied from
  # dead_controller with the noun substituted; see also the concern this pair
  # should share.
  @set = "retry"
  @noun = "retry"
  render "roundhouse_ui/shared/bulk_preview"
end

#requeueObject

Retry now — moves the job back to its queue immediately.



14
15
16
17
18
# File 'app/controllers/roundhouse_ui/retries_controller.rb', line 14

def requeue
  entry = backend.retry_set.find_job(params[:jid])
  entry&.retry
  redirect_to retries_path, notice: entry ? "Re-enqueued #{params[:jid]}." : "Job is no longer in the retry set."
end