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.
This commit is contained in:
Sean McGivern 2016-11-25 13:41:13 +00:00
parent 507abdb773
commit 79b5bfc113
2 changed files with 2 additions and 2 deletions

View file

@ -1,4 +1,4 @@
- if @issues.reorder(nil).any?
- if @issues.to_a.any?
- @issues.group_by(&:project).each do |group|
.panel.panel-default.panel-small
- project = group[0]

View file

@ -1,4 +1,4 @@
- if @merge_requests.reorder(nil).any?
- if @merge_requests.to_a.any?
- @merge_requests.group_by(&:target_project).each do |group|
.panel.panel-default.panel-small
- project = group[0]