summaryrefslogtreecommitdiff
path: root/lib/api/projects.rb
diff options
context:
space:
mode:
authorWinnie Hellmann <winnie@gitlab.com>2017-12-14 16:14:51 +0000
committerWinnie Hellmann <winnie@gitlab.com>2017-12-14 16:14:51 +0000
commitce916f476d3a9d9119688f5879b72456322024c5 (patch)
treeef428025aa74d12a5f9eef6a3ae5aee418d40d7d /lib/api/projects.rb
parenteb98a6f6ecbd75f1f63fcfb119b2927bc2418449 (diff)
parent1f804797fa43d3adfba1ce2a6492afd93240fe59 (diff)
downloadgitlab-ce-10-2-stable-patch-5.tar.gz
Merge branch 'sh-optimize-groups-api-10-2' into '10-2-stable-patch-5'10-2-stable-patch-5
Optimize API /groups/:id/projects by preloading assocations (10.2 port) See merge request gitlab-org/gitlab-ce!15926
Diffstat (limited to 'lib/api/projects.rb')
-rw-r--r--lib/api/projects.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/api/projects.rb b/lib/api/projects.rb
index 4cd7e714aa2..14a4fc6f025 100644
--- a/lib/api/projects.rb
+++ b/lib/api/projects.rb
@@ -79,11 +79,11 @@ module API
projects = projects.with_statistics if params[:statistics]
projects = projects.with_issues_enabled if params[:with_issues_enabled]
projects = projects.with_merge_requests_enabled if params[:with_merge_requests_enabled]
+ projects = paginate(projects)
if current_user
- projects = projects.includes(:route, :taggings, namespace: :route)
- project_members = current_user.project_members
- group_members = current_user.group_members
+ project_members = current_user.project_members.preload(:source, user: [notification_settings: :source])
+ group_members = current_user.group_members.preload(:source, user: [notification_settings: :source])
end
options = options.reverse_merge(
@@ -95,7 +95,7 @@ module API
)
options[:with] = Entities::BasicProjectDetails if params[:simple]
- present paginate(projects), options
+ present options[:with].prepare_relation(projects, options), options
end
end