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:
authorFrancisco Lopez <fjlopez@gitlab.com>2017-11-24 15:20:52 +0300
committerFrancisco Lopez <fjlopez@gitlab.com>2017-12-01 20:32:12 +0300
commita2babf32fe2b57850bd678919947d53e5127f6fe (patch)
tree1fb69dfe55a17b894a72878fc351946c78692629 /lib/api/groups.rb
parentdd562ae749db805c7c2c764f4e8b6082009df17f (diff)
More preloading improvement and added batch count services
Diffstat (limited to 'lib/api/groups.rb')
-rw-r--r--lib/api/groups.rb25
1 files changed, 20 insertions, 5 deletions
diff --git a/lib/api/groups.rb b/lib/api/groups.rb
index df2d97bceda..746dcc9fc91 100644
--- a/lib/api/groups.rb
+++ b/lib/api/groups.rb
@@ -52,6 +52,24 @@ module API
groups
end
+ def find_group_projects(params)
+ group = find_group!(params[:id])
+ projects = GroupProjectsFinder.new(group: group, current_user: current_user, params: project_finder_params).execute
+ projects = projects.preload(:project_feature, :route, :group)
+ .preload(namespace: [:route, :owner],
+ tags: :taggings,
+ project_group_links: :group,
+ fork_network: :root_project,
+ forked_project_link: :forked_from_project,
+ forked_from_project: [:route, :forks, namespace: :route, tags: :taggings])
+ projects = reorder_projects(projects)
+ paginated_projects = paginate(projects)
+ projects_with_fork = paginated_projects + paginated_projects.map(&:forked_from_project).compact
+ ::Projects::BatchForksCountService.new(projects_with_fork).refresh_cache
+ ::Projects::BatchOpenIssuesCountService.new(paginated_projects).refresh_cache
+ paginated_projects
+ end
+
def present_groups(params, groups)
options = {
with: Entities::Group,
@@ -170,12 +188,9 @@ module API
use :pagination
end
get ":id/projects" do
- group = find_group!(params[:id])
- projects = GroupProjectsFinder.new(group: group, current_user: current_user, params: project_finder_params).execute
- projects = projects.preload(:fork_network, :forked_project_link, :project_feature, :project_group_links, :tags, :taggings, :group, :namespace, :route)
- projects = reorder_projects(projects)
+ projects = find_group_projects(params)
entity = params[:simple] ? Entities::BasicProjectDetails : Entities::Project
- present paginate(projects), with: entity, current_user: current_user
+ present projects, with: entity, current_user: current_user
end
desc 'Get a list of subgroups in this group.' do