Skip to content
Snippets Groups Projects

Merge Requests - Assignee

Closed gitlab-qa-bot requested to merge master into 11-0-stable
9 files
+ 190
36
Compare changes
  • Side-by-side
  • Inline
Files
9
  • 4a9efc60
    GET :namespace/merge_requests/:id/ci_environments_status complexity
    already reached a limit for a direct serialization from an hash
    computed at within the controller function.
    
    Here we introduce a virtual model EnvironmentStatus and its serializer.
@@ -198,43 +198,11 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
end
def ci_environments_status
environments =
begin
@merge_request.environments_for(current_user).map do |environment|
project = environment.project
deployment = environment.first_deployment_for(@merge_request.diff_head_sha)
stop_url =
if can?(current_user, :stop_environment, environment)
stop_project_environment_path(project, environment)
end
metrics_url =
if can?(current_user, :read_environment, environment) && environment.has_metrics?
metrics_project_environment_deployment_path(project, environment, deployment)
end
metrics_monitoring_url =
if can?(current_user, :read_environment, environment)
environment_metrics_path(environment)
end
{
id: environment.id,
name: environment.name,
url: project_environment_path(project, environment),
metrics_url: metrics_url,
metrics_monitoring_url: metrics_monitoring_url,
stop_url: stop_url,
external_url: environment.external_url,
external_url_formatted: environment.formatted_external_url,
deployed_at: deployment.try(:created_at),
deployed_at_formatted: deployment.try(:formatted_deployment_time)
}
end.compact
end
environments = @merge_request.environments_for(current_user).map do |environment|
EnvironmentStatus.new(environment, @merge_request)
end
render json: environments
render json: EnvironmentStatusSerializer.new(current_user: current_user).represent(environments)
end
def rebase
Loading