gitlab-org--gitlab-foss/app/controllers/projects/deployments_controller.rb

52 lines
1.2 KiB
Ruby
Raw Normal View History

class Projects::DeploymentsController < Projects::ApplicationController
before_action :authorize_read_environment!
before_action :authorize_read_deployment!
def index
2017-03-28 08:56:30 -04:00
deployments = environment.deployments.reorder(created_at: :desc)
deployments = deployments.where('created_at > ?', params[:after].to_time) if params[:after]&.to_time
render json: { deployments: DeploymentSerializer.new(project: project)
.represent_concise(deployments) }
end
2017-05-09 00:15:34 -04:00
def metrics
return render_404 unless deployment.has_metrics?
@metrics = deployment.metrics
2017-05-09 00:15:34 -04:00
if @metrics&.any?
render json: @metrics, status: :ok
else
head :no_content
end
rescue NotImplementedError
render_404
2017-05-09 00:15:34 -04:00
end
2017-05-25 11:39:43 -04:00
def additional_metrics
return render_404 unless deployment.has_additional_metrics?
respond_to do |format|
format.json do
metrics = deployment.additional_metrics
if metrics.any?
render json: metrics
else
head :no_content
end
end
2017-05-25 11:39:43 -04:00
end
end
private
2017-05-09 00:15:34 -04:00
def deployment
@deployment ||= environment.deployments.find_by(iid: params[:id])
end
def environment
@environment ||= project.environments.find(params[:environment_id])
end
end