Class: ActionsController
Instance Method Summary
collapse
#after_sign_in_path_for, #api_authenticate!, #authenticated_via_token?, #current_project, #expire_revision!, #followed_projects, #no_cache, #oauth_authorize!, #read_revision, #require_login, #return_or_cache_revision!, #revision, #token_authenticate!, #unfurling?, #with_current_project
Methods included from UrlHelper
#feature_path, #link_to_project_feature
Instance Method Details
#index ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'app/controllers/actions_controller.rb', line 3
def index
authorize! :read, Action
actions_by_name = Houston.actions.to_a.each_with_object({}) { |action, map|
map[action.name] = { name: action.name, required_params: action.required_params } }
actions = Action.where(name: actions_by_name.keys)
most_recent_actions = actions.joins(<<-SQL)
inner join (select name, max(started_at) "started_at" from actions group by name) "most_recent"
on actions.name=most_recent.name and actions.started_at=most_recent.started_at
SQL
most_recent_actions.each do |action|
actions_by_name[action.name][:last] = action
end
actions.group(:name).unscope(:order).pluck(:name, "COUNT(id)", "COUNT(CASE WHEN succeeded THEN 1 ELSE NULL END)", "AVG(EXTRACT(epoch from finished_at - started_at))").each do |name, runs, successful_runs, avg_duration|
actions_by_name[name].merge!(
runs: runs,
successful_runs: successful_runs,
avg_duration: avg_duration )
end
@actions = actions_by_name.values
end
|
#retry ⇒ Object
52
53
54
55
56
57
|
# File 'app/controllers/actions_controller.rb', line 52
def retry
authorize! :run, Action
action = Action.find(params[:id])
action.retry!
redirect_to :back
end
|
#run ⇒ Object
46
47
48
49
50
|
# File 'app/controllers/actions_controller.rb', line 46
def run
authorize! :run, Action
Houston.actions.run params[:slug]
redirect_to "/actions", notice: "#{params[:slug]} is running"
end
|
#running ⇒ Object
36
37
38
39
|
# File 'app/controllers/actions_controller.rb', line 36
def running
authorize! :read, Action
@actions = Action.running
end
|
#show ⇒ Object
28
29
30
31
32
33
34
|
# File 'app/controllers/actions_controller.rb', line 28
def show
authorize! :read, Action
@action_name = params[:slug]
@actions = Action.where(name: @action_name).preload(:error).limit(50)
@actions = @actions.where(Action.arel_table[:created_at].lt(params[:before])) if params[:before]
render partial: "actions/actions" if request.xhr?
end
|
#unqueued ⇒ Object
41
42
43
44
|
# File 'app/controllers/actions_controller.rb', line 41
def unqueued
authorize! :read, Action
@actions = Action.unqueued
end
|