Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-03-01 21:12:50 +0300
committerStan Hu <stanhu@gmail.com>2019-03-01 21:57:09 +0300
commita769292c672dea9fae702dd75f643a14752110ee (patch)
tree779108b3ed100cd47c2f973f49a553d275112df5 /lib/gitlab/contributions_calendar.rb
parentd86de642d16e0f7518c7f508b5282c89128e9a58 (diff)
Eliminate most N+1 queries loading UserController#calendar_activities
We can reduce a significant number of queries by preloading the associations for events. On GitLab.com, for a date that had 456 events, this brought the load time down from 8.7 to 1.2 s. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/58392
Diffstat (limited to 'lib/gitlab/contributions_calendar.rb')
-rw-r--r--lib/gitlab/contributions_calendar.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/gitlab/contributions_calendar.rb b/lib/gitlab/contributions_calendar.rb
index 5ed6427072a..f7d046600e8 100644
--- a/lib/gitlab/contributions_calendar.rb
+++ b/lib/gitlab/contributions_calendar.rb
@@ -49,6 +49,7 @@ module Gitlab
Event.contributions.where(author_id: contributor.id)
.where(created_at: date.beginning_of_day..date.end_of_day)
.where(project_id: projects)
+ .with_associations
end
# rubocop: enable CodeReuse/ActiveRecord