Class: Blazer::ChecksController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/blazer/checks_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/blazer/checks_controller.rb', line 15

def create
  @check = Blazer::Check.new(check_params)
  # use creator_id instead of creator
  # since we setup association without checking if column exists
  @check.creator = blazer_user if @check.respond_to?(:creator_id=) && blazer_user

  if @check.save
    redirect_to query_path(@check.query)
  else
    render_errors @check
  end
end

#destroyObject



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

def destroy
  @check.destroy
  redirect_to checks_path
end

#indexObject



5
6
7
8
9
# File 'app/controllers/blazer/checks_controller.rb', line 5

def index
  state_order = [nil, "disabled", "error", "timed out", "failing", "passing"]
  @checks = Blazer::Check.joins(:query).includes(:query).order("blazer_queries.name, blazer_checks.id").to_a.sort_by { |q| state_order.index(q.state) || 99 }
  @checks.select! { |c| "#{c.query.name} #{c.emails}".downcase.include?(params[:q]) } if params[:q]
end

#newObject



11
12
13
# File 'app/controllers/blazer/checks_controller.rb', line 11

def new
  @check = Blazer::Check.new(query_id: params[:query_id])
end

#runObject



41
42
43
44
# File 'app/controllers/blazer/checks_controller.rb', line 41

def run
  @query = @check.query
  redirect_to query_path(@query)
end

#updateObject



28
29
30
31
32
33
34
# File 'app/controllers/blazer/checks_controller.rb', line 28

def update
  if @check.update(check_params)
    redirect_to query_path(@check.query)
  else
    render_errors @check
  end
end