diff options
author | Sean McGivern <sean@gitlab.com> | 2016-11-25 16:41:13 +0300 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2016-12-01 15:24:55 +0300 |
commit | 79b5bfc113973e8564f7d78f5e76347693245900 (patch) | |
tree | aa61d373591b876b172e765c0ad641c7a804d208 | |
parent | 507abdb7739c2c6df49cee77c966c4db0dcaf1bb (diff) |
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.
-rw-r--r-- | app/views/shared/_issues.html.haml | 2 | ||||
-rw-r--r-- | app/views/shared/_merge_requests.html.haml | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/app/views/shared/_issues.html.haml b/app/views/shared/_issues.html.haml index baa6d5f8206..26b349e8a62 100644 --- a/app/views/shared/_issues.html.haml +++ b/app/views/shared/_issues.html.haml @@ -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] diff --git a/app/views/shared/_merge_requests.html.haml b/app/views/shared/_merge_requests.html.haml index ca3178395c1..2f3605b4d27 100644 --- a/app/views/shared/_merge_requests.html.haml +++ b/app/views/shared/_merge_requests.html.haml @@ -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] |