diff options
author | Oswaldo Ferreira <oswaldo@gitlab.com> | 2017-10-03 18:13:13 -0300 |
---|---|---|
committer | Oswaldo Ferreira <oswaldo@gitlab.com> | 2017-10-04 00:09:48 -0300 |
commit | 1f54c9216f178e96010b28a74f04bae5848ef15d (patch) | |
tree | 7f5b63c6db133916be3cb20d94d30c0c64dc60d3 /app | |
parent | ccfe6860079c6c75ab5a1f831cd62af0e355331e (diff) | |
download | gitlab-ce-1f54c9216f178e96010b28a74f04bae5848ef15d.tar.gz |
Reduce method calls while evaluating Projects::MergeRequestsController#show.json36876-mr-show-json-controller-perf-improvements
Diffstat (limited to 'app')
-rw-r--r-- | app/models/merge_request.rb | 5 | ||||
-rw-r--r-- | app/presenters/merge_request_presenter.rb | 2 | ||||
-rw-r--r-- | app/serializers/merge_request_entity.rb | 2 | ||||
-rw-r--r-- | app/views/projects/issues/_merge_requests.html.haml | 4 |
4 files changed, 5 insertions, 8 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 8d9a30397a9..4a575dc7ba8 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -734,10 +734,9 @@ class MergeRequest < ActiveRecord::Base end def has_ci? - has_ci_integration = source_project.try(:ci_service) - uses_gitlab_ci = all_pipelines.any? + return false if has_no_commits? - (has_ci_integration || uses_gitlab_ci) && commits.any? + !!(head_pipeline_id || all_pipelines.any? || source_project&.ci_service) end def branch_missing? diff --git a/app/presenters/merge_request_presenter.rb b/app/presenters/merge_request_presenter.rb index 2df84e58575..a25882cbb62 100644 --- a/app/presenters/merge_request_presenter.rb +++ b/app/presenters/merge_request_presenter.rb @@ -31,7 +31,7 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated end def remove_wip_path - if can?(current_user, :update_merge_request, merge_request.project) + if work_in_progress? && can?(current_user, :update_merge_request, merge_request.project) remove_wip_project_merge_request_path(project, merge_request) end end diff --git a/app/serializers/merge_request_entity.rb b/app/serializers/merge_request_entity.rb index 07650ce6f20..9c5b1a7d2a7 100644 --- a/app/serializers/merge_request_entity.rb +++ b/app/serializers/merge_request_entity.rb @@ -18,7 +18,6 @@ class MergeRequestEntity < IssuableEntity expose :closed_event, using: EventEntity # User entities - expose :author, using: UserEntity expose :merge_user, using: UserEntity # Diff sha's @@ -26,7 +25,6 @@ class MergeRequestEntity < IssuableEntity merge_request.diff_head_sha if merge_request.diff_head_commit end - expose :merge_commit_sha expose :merge_commit_message expose :head_pipeline, with: PipelineDetailsEntity, as: :pipeline diff --git a/app/views/projects/issues/_merge_requests.html.haml b/app/views/projects/issues/_merge_requests.html.haml index 6a567487514..5f97d31f610 100644 --- a/app/views/projects/issues/_merge_requests.html.haml +++ b/app/views/projects/issues/_merge_requests.html.haml @@ -2,13 +2,13 @@ %h2.merge-requests-title = pluralize(@merge_requests.count, 'Related Merge Request') %ul.unstyled-list.related-merge-requests - - has_any_ci = @merge_requests.any?(&:head_pipeline) + - has_any_head_pipeline = @merge_requests.any?(&:head_pipeline_id) - @merge_requests.each do |merge_request| %li %span.merge-request-ci-status - if merge_request.head_pipeline = render_pipeline_status(merge_request.head_pipeline) - - elsif has_any_ci + - elsif has_any_head_pipeline = icon('blank fw') %span.merge-request-id = merge_request.to_reference |