diff options
author | James Edwards-Jones <jedwardsjones@gitlab.com> | 2016-12-16 18:52:27 +0300 |
---|---|---|
committer | James Edwards-Jones <jedwardsjones@gitlab.com> | 2016-12-20 15:45:29 +0300 |
commit | 27c936adf9728cd21114aa3f2f9b44deb0296eb4 (patch) | |
tree | eee3a69f32c44c3f74d113ef03867b4387d22ba3 /app/models/global_milestone.rb | |
parent | 01adeb17acccab09eb0074725050356d9d431c8a (diff) |
Milestoneish SQL performance partially improved and memoized
Memoize Milestoneish#issues_visible_to_user and counts to reduce lookups
Milstoneish SQL optimised with project, but still slow on GlobalMilestone
Diffstat (limited to 'app/models/global_milestone.rb')
-rw-r--r-- | app/models/global_milestone.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/app/models/global_milestone.rb b/app/models/global_milestone.rb index b01607dcda9..a54e478f5f8 100644 --- a/app/models/global_milestone.rb +++ b/app/models/global_milestone.rb @@ -24,12 +24,16 @@ class GlobalMilestone @first_milestone = milestones.find {|m| m.description.present? } || milestones.first end + def milestoneish_ids + milestones.select(:id) + end + def safe_title @title.to_slug.normalize.to_s end def projects - @projects ||= Project.for_milestones(milestones.select(:id)) + @projects ||= Project.for_milestones(milestoneish_ids) end def state @@ -49,11 +53,11 @@ class GlobalMilestone end def issues - @issues ||= Issue.of_milestones(milestones.select(:id)).includes(:project, :assignee, :labels) + @issues ||= Issue.of_milestones(milestoneish_ids).includes(:project, :assignee, :labels) end def merge_requests - @merge_requests ||= MergeRequest.of_milestones(milestones.select(:id)).includes(:target_project, :assignee, :labels) + @merge_requests ||= MergeRequest.of_milestones(milestoneish_ids).includes(:target_project, :assignee, :labels) end def participants |