Class: Rearview::JobsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Rearview::JobsController
- Defined in:
- app/controllers/rearview/jobs_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #data ⇒ Object
- #destroy ⇒ Object
- #errors ⇒ Object
- #index ⇒ Object
- #reset ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/rearview/jobs_controller.rb', line 18 def create dashboard_id = params.delete("dashboard_id") @job = Rearview::Job.new(job_create_params) @job.deep_validation = true @job.user_id = current_user.id @job.dashboard = Rearview::Dashboard.find(dashboard_id.to_i) if @job.save @job.sync_monitor_service render :show else render :show, status: 422 end end |
#data ⇒ Object
64 65 66 67 68 69 |
# File 'app/controllers/rearview/jobs_controller.rb', line 64 def data @job_data = Rearview::JobData.find_by(job_id:params[:id]) unless @job_data.present? head :status => 404 end end |
#destroy ⇒ Object
48 49 50 51 52 |
# File 'app/controllers/rearview/jobs_controller.rb', line 48 def destroy @job = Rearview::Job.find(params[:id]) @job.destroy render :show end |
#errors ⇒ Object
71 72 73 |
# File 'app/controllers/rearview/jobs_controller.rb', line 71 def errors @job_errors = Rearview::JobError.calculate_durations(Rearview::JobError.search(params).load) end |
#index ⇒ Object
10 11 12 13 14 15 16 |
# File 'app/controllers/rearview/jobs_controller.rb', line 10 def index @jobs = if params[:dashboard_id].present? Rearview::Job.where(:app_id=>params[:dashboard_id]) else Rearview::Job.all end end |
#reset ⇒ Object
54 55 56 57 58 |
# File 'app/controllers/rearview/jobs_controller.rb', line 54 def reset @job = Rearview::Job.find(params[:id]) @job.reset render :show end |
#show ⇒ Object
60 61 62 |
# File 'app/controllers/rearview/jobs_controller.rb', line 60 def show @job = Rearview::Job.find(params[:id]) end |
#update ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/rearview/jobs_controller.rb', line 32 def update @job = Rearview::Job.find(params[:id]) @job.deep_validation = true dashboard_id = params.delete("dashboard_id") if dashboard_id.present? && dashboard_id.to_i!=@job.app_id @job.dashboard = Rearview::Dashboard.find(dashboard_id.to_i) end params["alert_keys"] = [] if params["alert_keys"].blank? if @job.update_attributes(job_update_params) @job.sync_monitor_service render :show else render :show, status: 422 end end |