Commit 44fdf0a1 authored by Toon Claes's avatar Toon Claes

Move ProjectsFinder to `present_projects` for simplification

To avoid passing parameters double, move all filtering to the `present_projects`
helper.
parent 98043aee
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment