Build options hash after finding the list of projects
Because this order makes more sense and makes the code easier to read.
This commit is contained in:
parent
44fdf0a1e3
commit
4fda13b68e
|
@ -68,16 +68,17 @@ module API
|
||||||
end
|
end
|
||||||
|
|
||||||
def present_projects(options = {})
|
def present_projects(options = {})
|
||||||
options = options.reverse_merge(
|
|
||||||
with: current_user ? Entities::ProjectWithAccess : Entities::BasicProjectDetails,
|
|
||||||
current_user: current_user
|
|
||||||
)
|
|
||||||
|
|
||||||
projects = ProjectsFinder.new(current_user: current_user).execute
|
projects = ProjectsFinder.new(current_user: current_user).execute
|
||||||
projects = filter_projects(projects)
|
projects = filter_projects(projects)
|
||||||
projects = projects.with_statistics if params[:statistics]
|
projects = projects.with_statistics if params[:statistics]
|
||||||
projects = projects.with_issues_enabled if params[:with_issues_enabled]
|
projects = projects.with_issues_enabled if params[:with_issues_enabled]
|
||||||
projects = projects.with_merge_requests_enabled if params[:with_merge_requests_enabled]
|
projects = projects.with_merge_requests_enabled if params[:with_merge_requests_enabled]
|
||||||
|
|
||||||
|
options = options.reverse_merge(
|
||||||
|
with: current_user ? Entities::ProjectWithAccess : Entities::BasicProjectDetails,
|
||||||
|
statistics: params[:statistics],
|
||||||
|
current_user: current_user
|
||||||
|
)
|
||||||
options[:with] = Entities::BasicProjectDetails if params[:simple]
|
options[:with] = Entities::BasicProjectDetails if params[:simple]
|
||||||
|
|
||||||
present paginate(projects), options
|
present paginate(projects), options
|
||||||
|
|
Loading…
Reference in New Issue