2017-03-27 05:22:43 -04:00
|
|
|
class Projects::DeploymentsController < Projects::ApplicationController
|
2017-04-24 15:34:21 -04:00
|
|
|
before_action :authorize_read_environment!
|
2017-03-27 05:22:43 -04:00
|
|
|
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
|
2017-03-27 05:22:43 -04:00
|
|
|
|
2017-05-10 14:21:31 -04:00
|
|
|
render json: { deployments: DeploymentSerializer.new(project: project)
|
2017-04-24 16:34:36 -04:00
|
|
|
.represent_concise(deployments) }
|
2017-03-27 05:22:43 -04:00
|
|
|
end
|
|
|
|
|
2017-05-09 00:15:34 -04:00
|
|
|
def metrics
|
2017-05-12 12:16:22 -04:00
|
|
|
return render_404 unless deployment.has_metrics?
|
2017-11-14 04:02:39 -05:00
|
|
|
|
2017-04-26 16:09:03 -04:00
|
|
|
@metrics = deployment.metrics
|
2017-05-09 00:15:34 -04:00
|
|
|
if @metrics&.any?
|
|
|
|
render json: @metrics, status: :ok
|
|
|
|
else
|
|
|
|
head :no_content
|
|
|
|
end
|
2017-05-12 12:16:22 -04:00
|
|
|
rescue NotImplementedError
|
|
|
|
render_404
|
2017-05-09 00:15:34 -04:00
|
|
|
end
|
|
|
|
|
2017-05-25 11:39:43 -04:00
|
|
|
def additional_metrics
|
2017-06-16 14:48:34 -04:00
|
|
|
return render_404 unless deployment.has_additional_metrics?
|
2017-06-06 08:40:03 -04:00
|
|
|
|
2017-06-20 09:53:05 -04:00
|
|
|
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
|
|
|
|
|
2017-03-27 05:22:43 -04:00
|
|
|
private
|
|
|
|
|
2017-05-09 00:15:34 -04:00
|
|
|
def deployment
|
|
|
|
@deployment ||= environment.deployments.find_by(iid: params[:id])
|
|
|
|
end
|
|
|
|
|
2017-03-27 05:22:43 -04:00
|
|
|
def environment
|
|
|
|
@environment ||= project.environments.find(params[:environment_id])
|
|
|
|
end
|
|
|
|
end
|