diff options
author | Ahmad Sherif <me@ahmadsherif.com> | 2016-09-23 14:34:39 +0300 |
---|---|---|
committer | Ahmad Sherif <me@ahmadsherif.com> | 2016-09-23 14:34:39 +0300 |
commit | b5132118cd43a3e005f0ed159d4a1be34b9a6ce6 (patch) | |
tree | b90d0a6fdf68c32208294dee42909177612f0d7d /app | |
parent | b8bfe50a5080909c7ba2b517d99d3c5f79d2a32f (diff) |
Ensure milestones passed to GlobalMilestone is an ActiveRecord::Relation
Diffstat (limited to 'app')
-rw-r--r-- | app/models/global_milestone.rb | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/app/models/global_milestone.rb b/app/models/global_milestone.rb index 8f38a2b6254..3e10bed19c2 100644 --- a/app/models/global_milestone.rb +++ b/app/models/global_milestone.rb @@ -8,7 +8,8 @@ class GlobalMilestone milestones = milestones.group_by(&:title) milestones.map do |title, milestones| - new(title, milestones) + milestones_relation = Milestone.where(id: milestones.map(&:id)) + new(title, milestones_relation) end end @@ -61,11 +62,11 @@ class GlobalMilestone end def participants - @participants ||= milestones_relation.includes(:participants).map(&:participants).flatten.compact.uniq + @participants ||= milestones.includes(:participants).map(&:participants).flatten.compact.uniq end def labels - @labels ||= GlobalLabel.build_collection(milestones_relation.includes(:labels).map(&:labels).flatten) + @labels ||= GlobalLabel.build_collection(milestones.includes(:labels).map(&:labels).flatten) .sort_by!(&:title) end @@ -89,14 +90,4 @@ class GlobalMilestone end end end - - private - - def milestones_relation - @milestones_relation ||= if milestones.is_a?(ActiveRecord::Relation) - milestones - else - Milestone.where(id: milestones.map(&:id)) - end - end end |