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
35 36 37 38 39 40 41 42 43 44 |
# File 'app/controllers/barbeque/job_definitions_controller.rb', line 35 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
60 61 62 63 64 65 66 67 |
# File 'app/controllers/barbeque/job_definitions_controller.rb', line 60 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
25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/barbeque/job_definitions_controller.rb', line 25 def edit @job_definition = Barbeque::JobDefinition.find(params[:id]) unless @job_definition.slack_notification @job_definition.build_slack_notification end unless @job_definition.retry_config @job_definition.build_retry_config end end |
#execution_stats ⇒ Object
74 75 76 77 78 79 |
# File 'app/controllers/barbeque/job_definitions_controller.rb', line 74 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
16 17 18 19 20 21 22 23 |
# File 'app/controllers/barbeque/job_definitions_controller.rb', line 16 def new @job_definition = Barbeque::JobDefinition.new @job_definition.build_slack_notification @job_definition.build_retry_config if params[:job_definition] @job_definition.assign_attributes(new_job_definition_params) end end |
#show ⇒ Object
6 7 8 9 10 11 12 13 14 |
# 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]) @retry_config = @job_definition.retry_config @status = params[:status].presence.try(&:to_i) if @status @job_executions = @job_executions.where(status: @status) end end |
#stats ⇒ Object
69 70 71 72 |
# File 'app/controllers/barbeque/job_definitions_controller.rb', line 69 def stats @job_definition = Barbeque::JobDefinition.find(params[:job_definition_id]) @days = (params[:days] || 3).to_i end |
#update ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/controllers/barbeque/job_definitions_controller.rb', line 46 def update @job_definition = Barbeque::JobDefinition.find(params[:id]) attributes = params.require(:job_definition).permit( :description, slack_notification_attributes: slack_notification_params, retry_config_attributes: retry_config_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 |