summaryrefslogtreecommitdiff
path: root/app/views
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2016-11-25 13:41:13 +0000
committerSean McGivern <sean@gitlab.com>2016-12-01 12:24:55 +0000
commit79b5bfc113973e8564f7d78f5e76347693245900 (patch)
treeaa61d373591b876b172e765c0ad641c7a804d208 /app/views
parent507abdb7739c2c6df49cee77c966c4db0dcaf1bb (diff)
downloadgitlab-ce-79b5bfc113973e8564f7d78f5e76347693245900.tar.gz
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.
Diffstat (limited to 'app/views')
-rw-r--r--app/views/shared/_issues.html.haml2
-rw-r--r--app/views/shared/_merge_requests.html.haml2
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]