Class: Barbeque::JobDefinitionsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Barbeque::JobDefinitionsController
- Defined in:
- app/controllers/barbeque/job_definitions_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #execution_stats ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #stats ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/barbeque/job_definitions_controller.rb', line 26 def create attributes = new_job_definition_params.merge(command: command_array) @job_definition = Barbeque::JobDefinition.new(attributes) if @job_definition.save redirect_to @job_definition, notice: 'Job definition was successfully created.' else render :new end end |
#destroy ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'app/controllers/barbeque/job_definitions_controller.rb', line 50 def destroy @job_definition = Barbeque::JobDefinition.find(params[:id]) @job_definition.sns_subscriptions.each do |sns_subscription| Barbeque::SNSSubscriptionService.new.unsubscribe(sns_subscription) end @job_definition.destroy redirect_to job_definitions_url, notice: 'Job definition was successfully destroyed.' end |
#edit ⇒ Object
19 20 21 22 23 24 |
# File 'app/controllers/barbeque/job_definitions_controller.rb', line 19 def edit @job_definition = Barbeque::JobDefinition.find(params[:id]) if @job_definition.slack_notification.nil? @job_definition.build_slack_notification end end |
#execution_stats ⇒ Object
64 65 66 67 68 69 |
# File 'app/controllers/barbeque/job_definitions_controller.rb', line 64 def execution_stats job_definition = Barbeque::JobDefinition.find(params[:job_definition_id]) days = (params[:days] || 3).to_i now = Time.zone.now render json: job_definition.execution_stats(days.days.ago(now), now) end |
#index ⇒ Object
2 3 4 |
# File 'app/controllers/barbeque/job_definitions_controller.rb', line 2 def index @job_definitions = Barbeque::JobDefinition.all end |
#new ⇒ Object
11 12 13 14 15 16 17 |
# File 'app/controllers/barbeque/job_definitions_controller.rb', line 11 def new @job_definition = Barbeque::JobDefinition.new @job_definition.build_slack_notification if params[:job_definition] @job_definition.assign_attributes(new_job_definition_params) end end |
#show ⇒ Object
6 7 8 9 |
# File 'app/controllers/barbeque/job_definitions_controller.rb', line 6 def show @job_definition = Barbeque::JobDefinition.find(params[:id]) @job_executions = @job_definition.job_executions.order(id: :desc).page(params[:page]) end |
#stats ⇒ Object
59 60 61 62 |
# File 'app/controllers/barbeque/job_definitions_controller.rb', line 59 def stats @job_definition = Barbeque::JobDefinition.find(params[:job_definition_id]) @days = (params[:days] || 3).to_i end |
#update ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/barbeque/job_definitions_controller.rb', line 37 def update @job_definition = Barbeque::JobDefinition.find(params[:id]) attributes = params.require(:job_definition).permit( :description, slack_notification_attributes: slack_notification_params, ).merge(command: command_array) if @job_definition.update(attributes) redirect_to @job_definition, notice: 'Job definition was successfully updated.' else render :edit end end |