gitlab-org--gitlab-foss/app/views/shared/_merge_requests.html.haml
Sean McGivern 79b5bfc113 Save a query on issue and MR lists
`any?` on an AR relation performs a `SELECT COUNT`, which we don't need.

1. We are very likely to have issues or MRs, so the `SELECT COUNT` is
   often unnecessary.
2. Even where there are no items returned, the overhead of the
   `SELECT *` instead of `SELECT COUNT` is relatively small.

Calling `to_a` on the relation lets us use `Enumerable#any?`, which will
return immediately if there are objects returned.
2016-12-01 12:24:55 +00:00

17 lines
756 B
Text

- if @merge_requests.to_a.any?
- @merge_requests.group_by(&:target_project).each do |group|
.panel.panel-default.panel-small
- project = group[0]
.panel-heading
= link_to project.name_with_namespace, namespace_project_merge_requests_path(project.namespace, project)
- if can?(current_user, :create_merge_request, project)
.pull-right
= link_to 'New merge request', new_namespace_project_merge_request_path(project.namespace, project)
%ul.content-list.mr-list
- group[1].each do |merge_request|
= render 'projects/merge_requests/merge_request', merge_request: merge_request
= paginate @merge_requests, theme: "gitlab"
- else
.nothing-here-block No merge requests to show