summaryrefslogtreecommitdiff
path: root/app/models/concerns/participable.rb
diff options
context:
space:
mode:
authorPaco Guzman <pacoguzmanp@gmail.com>2016-06-20 17:49:15 +0200
committerPaco Guzman <pacoguzmanp@gmail.com>2016-06-21 12:54:12 +0200
commitbfce7349ea7c2efcbeb3fb34a207aad65d3129e3 (patch)
tree2e1a67f8b5a243bc7328002b4d8d924746f0db58 /app/models/concerns/participable.rb
parentf90c8c624d2bf0391a25ae07b1516d11948e1a81 (diff)
downloadgitlab-ce-bfce7349ea7c2efcbeb3fb34a207aad65d3129e3.tar.gz
Cache Participable#participants in instance variable
Diffstat (limited to 'app/models/concerns/participable.rb')
-rw-r--r--app/models/concerns/participable.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/app/models/concerns/participable.rb b/app/models/concerns/participable.rb
index 9056722f45e..9822844357d 100644
--- a/app/models/concerns/participable.rb
+++ b/app/models/concerns/participable.rb
@@ -53,6 +53,16 @@ module Participable
#
# Returns an Array of User instances.
def participants(current_user = nil)
+ @participants ||= Hash.new do |hash, user|
+ hash[user] = raw_participants(user)
+ end
+
+ @participants[current_user]
+ end
+
+ private
+
+ def raw_participants(current_user = nil)
current_user ||= author
ext = Gitlab::ReferenceExtractor.new(project, current_user)
participants = Set.new