diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-13 06:07:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-13 06:07:50 +0300 |
commit | 38bab6e1581d30c0e9d312474fd796404cc7b484 (patch) | |
tree | e4e6b11e2788cae577ecb1efa5195f9bc77b83f2 /lib/api/projects.rb | |
parent | 47b8f79a0896f406008d5a7eda2781f8da301e91 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/api/projects.rb')
-rw-r--r-- | lib/api/projects.rb | 34 |
1 files changed, 9 insertions, 25 deletions
diff --git a/lib/api/projects.rb b/lib/api/projects.rb index ea7087d2f46..a1fce9e8b20 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -75,17 +75,15 @@ module API mutually_exclusive :import_url, :template_name, :template_project_id end - def find_projects + def load_projects ProjectsFinder.new(current_user: current_user, params: project_finder_params).execute end - # Prepare the full projects query - # None of this is supposed to actually execute any database query - def prepare_query(projects) + def present_projects(projects, options = {}) projects = reorder_projects(projects) projects = apply_filters(projects) - - projects, options = with_custom_attributes(projects) + projects = paginate(projects) + projects, options = with_custom_attributes(projects, options) options = options.reverse_merge( with: current_user ? Entities::ProjectWithAccess : Entities::BasicProjectDetails, @@ -93,23 +91,9 @@ module API current_user: current_user, license: false ) - options[:with] = Entities::BasicProjectDetails if params[:simple] - projects = options[:with].preload_relation(projects, options) - - [projects, options] - end - - def prepare_and_present(project_relation) - projects, options = prepare_query(project_relation) - - projects = paginate_and_retrieve!(projects) - - # Refresh count caches - options[:with].execute_batch_counting(projects) - - present projects, options + present options[:with].prepare_relation(projects, options), options end def translate_params_for_compatibility(params) @@ -134,7 +118,7 @@ module API params[:user] = user - prepare_and_present find_projects + present_projects load_projects end desc 'Get projects starred by a user' do @@ -150,7 +134,7 @@ module API not_found!('User') unless user starred_projects = StarredProjectsFinder.new(user, params: project_finder_params, current_user: current_user).execute - prepare_and_present starred_projects + present_projects starred_projects end end @@ -166,7 +150,7 @@ module API use :with_custom_attributes end get do - prepare_and_present find_projects + present_projects load_projects end desc 'Create new project' do @@ -303,7 +287,7 @@ module API get ':id/forks' do forks = ForkProjectsFinder.new(user_project, params: project_finder_params, current_user: current_user).execute - prepare_and_present forks + present_projects forks end desc 'Check pages access of this project' |