Skip to content
Snippets Groups Projects
Commit b8bfe50a authored by Ahmad Sherif's avatar Ahmad Sherif
Browse files

Reduce number of queries when calling GlobalMilestone#{labels,participants}

parent ac347028
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -180,6 +180,7 @@ v 8.12.0 (unreleased)
- Clean environment variables when running git hooks
- Fix Import/Export issues importing protected branches and some specific models
- Fix non-master branch readme display in tree view
- Speed-up group milestones show page
- Add UX improvements for merge request version diffs
 
v 8.11.7
Loading
Loading
Loading
Loading
@@ -61,11 +61,11 @@ class GlobalMilestone
end
 
def participants
@participants ||= milestones.map(&:participants).flatten.compact.uniq
@participants ||= milestones_relation.includes(:participants).map(&:participants).flatten.compact.uniq
end
 
def labels
@labels ||= GlobalLabel.build_collection(milestones.map(&:labels).flatten)
@labels ||= GlobalLabel.build_collection(milestones_relation.includes(:labels).map(&:labels).flatten)
.sort_by!(&:title)
end
 
Loading
Loading
@@ -89,4 +89,14 @@ 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment