Class: ActionsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/actions_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#after_sign_in_path_for, #api_authenticate!, #current_project, #expire_revision!, #followed_projects, #no_cache, #read_revision, #require_login, #return_or_cache_revision!, #revision, #unfurling?, #with_current_project

Methods included from UrlHelper

#feature_path, #link_to_project_feature

Instance Method Details

#indexObject



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("  inner join (select name, max(started_at) \"started_at\" from actions group by name) \"most_recent\"\n  on actions.name=most_recent.name and actions.started_at=most_recent.started_at\n  SQL\n  most_recent_actions.each do |action|\n    actions_by_name[action.name][:last] = action\n  end\n\n  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|\n    actions_by_name[name].merge!(\n      runs: runs,\n      successful_runs: successful_runs,\n      avg_duration: avg_duration )\n  end\n\n  @actions = actions_by_name.values\nend\n")

#retryObject



47
48
49
50
51
52
# File 'app/controllers/actions_controller.rb', line 47

def retry
  authorize! :run, Action
  action = Action.find(params[:id])
  action.retry!
  redirect_to "/actions/#{action.name}", notice: "#{action.name} is running"
end

#runObject



41
42
43
44
45
# File 'app/controllers/actions_controller.rb', line 41

def run
  authorize! :run, Action
  Houston.actions.run params[:slug]
  redirect_to "/actions", notice: "#{params[:slug]} is running"
end

#runningObject



36
37
38
39
# File 'app/controllers/actions_controller.rb', line 36

def running
  authorize! :read, Action
  @actions = Action.where(finished_at: nil)
end

#showObject



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[:started_at].lt(params[:before])) if params[:before]
  render partial: "actions/actions" if request.xhr?
end