Class: RigidWorkflow::RunsController
Overview
Manages workflow run CRUD operations and bulk actions. Provides views for listing, filtering, and controlling workflow runs.
Constant Summary
collapse
- ALLOWED_BULK_ACTIONS =
%i[retry cancel].freeze
Instance Method Summary
collapse
#default_url_options, stats_for_ever, unique_workflows_in_ever
Instance Method Details
#active_runs ⇒ Object
17
18
19
20
|
# File 'app/controllers/rigid_workflow/runs_controller.rb', line 17
def active_runs
@runs = filter_runs(%i[running]).page(page_params)
render :index
end
|
#bulk_action ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'app/controllers/rigid_workflow/runs_controller.rb', line 61
def bulk_action
permitted = bulk_action_params
return render_error("Invalid action") unless permitted[:action]
runs = RigidWorkflow::Run.where(id: permitted[:ids])
success_count = 0
errors = []
runs.each do |run|
begin
case permitted[:action]
when :retry
run.retry!
when :cancel
run.cancel!
end
success_count += 1
rescue => error
errors << "#{run.id}: #{error.message}"
end
end
action_label =
permitted[:action] == :retry ? "retry" : permitted[:action].to_s
notice =
"Applied #{action_label} to #{success_count} #{"run".pluralize(success_count)}."
notice +=
" #{errors.join(', ')} #{"run".pluralize(errors.size)} failed." if errors.any?
if permitted[:ids].size == 1
redirect_to runs_show_path(permitted[:ids].first), notice: notice
else
redirect_to request.referrer || admin_rigid_workflow_runs_path,
notice: notice
end
end
|
#completed_runs ⇒ Object
22
23
24
25
|
# File 'app/controllers/rigid_workflow/runs_controller.rb', line 22
def completed_runs
@runs = filter_runs(%i[completed]).page(page_params)
render :index
end
|
#failed_runs ⇒ Object
27
28
29
30
|
# File 'app/controllers/rigid_workflow/runs_controller.rb', line 27
def failed_runs
@runs = filter_runs(%i[failed]).page(page_params)
render :index
end
|
#index ⇒ Object
8
9
10
|
# File 'app/controllers/rigid_workflow/runs_controller.rb', line 8
def index
@runs = filter_runs.page(page_params)
end
|
#pending_runs ⇒ Object
12
13
14
15
|
# File 'app/controllers/rigid_workflow/runs_controller.rb', line 12
def pending_runs
@runs = filter_runs(%i[pending]).page(page_params)
render :index
end
|
#show ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'app/controllers/rigid_workflow/runs_controller.rb', line 32
def show
@run =
RigidWorkflow::Run.includes(steps: :attempts, signals: []).find(
params[:id]
)
respond_to do |format|
format.html
format.json do
render json: {
workflow: @run,
steps:
@run
.steps
.includes(:attempts)
.order(:id)
.map { |s|
s.attributes.merge(
attempts:
s.attempts.order(:attempt_number).map(&:attributes)
)
},
signals: @run.signals.order(:id)
}
end
end
end
|