diff options
author | Felipe Artur <felipefac@gmail.com> | 2017-01-23 18:40:25 -0200 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2017-02-09 17:33:19 -0200 |
commit | f23c1befcfec7dbdad6c527da4bf17d616da5b5e (patch) | |
tree | fe7d309c2013207bb2f0f51fbf19128de3383237 /app/models/note.rb | |
parent | c4fd6ff407cff8f2f742997a7400ba940a1fce5f (diff) | |
download | gitlab-ce-issue_25900.tar.gz |
Gather issuable metadata to avoid n+ queries on index viewissue_25900
Diffstat (limited to 'app/models/note.rb')
-rw-r--r-- | app/models/note.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/app/models/note.rb b/app/models/note.rb index bf090a0438c..b4bdc42a788 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -108,6 +108,12 @@ class Note < ActiveRecord::Base Discussion.for_diff_notes(active_notes). map { |d| [d.line_code, d] }.to_h end + + def count_for_collection(ids, type) + user.select('noteable_id', 'COUNT(*)'). + group(:noteable_id). + where(noteable_type: type, noteable_id: ids) + end end def cross_reference? |