summaryrefslogtreecommitdiff
path: root/lib/api
diff options
context:
space:
mode:
authorToon Claes <toon@gitlab.com>2017-05-22 16:47:16 +0200
committerToon Claes <toon@gitlab.com>2017-05-30 22:41:29 +0200
commit44fdf0a1e314da517d189e356b0e44bb63cf0f4b (patch)
treea5757aeb100b07467fb95e284f8adec3fc7e539a /lib/api
parent98043aeedf1fe3241d8362d8036f28b709e6d468 (diff)
downloadgitlab-ce-44fdf0a1e314da517d189e356b0e44bb63cf0f4b.tar.gz
Move ProjectsFinder to `present_projects` for simplification
To avoid passing parameters double, move all filtering to the `present_projects` helper.
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/projects.rb21
1 files changed, 9 insertions, 12 deletions
diff --git a/lib/api/projects.rb b/lib/api/projects.rb
index d4fe5c023bf..fce496308c3 100644
--- a/lib/api/projects.rb
+++ b/lib/api/projects.rb
@@ -67,20 +67,18 @@ module API
optional :import_url, type: String, desc: 'URL from which the project is imported'
end
- def present_projects(projects, options = {})
+ def present_projects(options = {})
options = options.reverse_merge(
- with: Entities::Project,
- current_user: current_user,
- simple: params[:simple],
- with_issues_enabled: params[:with_issues_enabled],
- with_merge_requests_enabled: params[:with_merge_requests_enabled]
+ with: current_user ? Entities::ProjectWithAccess : Entities::BasicProjectDetails,
+ current_user: current_user
)
+ projects = ProjectsFinder.new(current_user: current_user).execute
projects = filter_projects(projects)
- projects = projects.with_statistics if options[:statistics]
- projects = projects.with_issues_enabled if options[:with_issues_enabled]
- projects = projects.with_merge_requests_enabled if options[:with_merge_requests_enabled]
- options[:with] = Entities::BasicProjectDetails if options[:simple]
+ 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]
+ options[:with] = Entities::BasicProjectDetails if params[:simple]
present paginate(projects), options
end
@@ -94,8 +92,7 @@ module API
use :statistics_params
end
get do
- entity = current_user ? Entities::ProjectWithAccess : Entities::BasicProjectDetails
- present_projects ProjectsFinder.new(current_user: current_user).execute, with: entity, statistics: params[:statistics]
+ present_projects
end
desc 'Create new project' do