Class: ChecksController

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

Instance Method Summary collapse

Instance Method Details

#adminObject

GET /checks/admin


101
102
# File 'app/controllers/checks_controller.rb', line 101

def admin
end

#createObject

POST /checks POST /checks.json


26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/checks_controller.rb', line 26

def create
  @check = Check.new(check_params)

  respond_to do |format|
    if @check.save
      format.html { redirect_to @check, notice: 'Check was successfully created.' }
      format.json { render :show, status: :created, location: @check }
    else
      format.html { render :new }
      format.json { render json: @check.errors, status: :unprocessable_entity }
    end
  end
end

#dashboardObject

GET /dashboard


65
66
67
# File 'app/controllers/checks_controller.rb', line 65

def dashboard
  @checks = Check.all
end

#destroyObject

DELETE /checks/1 DELETE /checks/1.json


56
57
58
59
60
61
62
# File 'app/controllers/checks_controller.rb', line 56

def destroy
  @check.destroy
  respond_to do |format|
    format.html { redirect_to checks_url, notice: 'Check was successfully destroyed.' }
    format.json { head :no_content }
  end
end

#editObject

GET /checks/1/edit


21
22
# File 'app/controllers/checks_controller.rb', line 21

def edit
end

#indexObject

GET /checks GET /checks.json


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

def index
  @checks = Check.all
end

#jobObject

GET /checks/1/job GET /checks/1/job.json


71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'app/controllers/checks_controller.rb', line 71

def job
  Rails.logger.info "ciao-scheduler Database conn. pool stat: #{ActiveRecord::Base.connection_pool.stat}"
  @check = Check.find(params[:check_id])
  @job = Rufus::Scheduler.singleton.job(@check.job)
  respond_to do |format|
    if @job
      format.html
      format.json { render :job, status: :ok }
    else
      format.html { render :job, status: 404 }
      format.json { render json: "Job not found", status: 404 }
    end
  end
end

#jobs_recreateObject

GET /checks/jobs/recreate GET /checks/jobs/recreate.json


88
89
90
91
92
93
94
95
96
97
98
# File 'app/controllers/checks_controller.rb', line 88

def jobs_recreate
  Check.active.each do |check|
    check.unschedule_job if check.job
    check.create_job
  end
  Rails.logger.info "ciao-scheduler Database conn. pool stat: #{ActiveRecord::Base.connection_pool.stat}"
  respond_to do |format|
    format.html { redirect_to checks_url, notice: 'Check jobs were successfully recreated.' }
    format.json { render json: "Check jobs were successfully recreated.", status: 200 }
  end
end

#newObject

GET /checks/new


16
17
18
# File 'app/controllers/checks_controller.rb', line 16

def new
  @check = Check.new
end

#showObject

GET /checks/1 GET /checks/1.json


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

def show
end

#updateObject

PATCH/PUT /checks/1 PATCH/PUT /checks/1.json


42
43
44
45
46
47
48
49
50
51
52
# File 'app/controllers/checks_controller.rb', line 42

def update
  respond_to do |format|
    if @check.update(check_params)
      format.html { redirect_to @check, notice: 'Check was successfully updated.' }
      format.json { render :show, status: :ok, location: @check }
    else
      format.html { render :edit }
      format.json { render json: @check.errors, status: :unprocessable_entity }
    end
  end
end