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
path: root/lib
diff options
context:
space:
mode:
authorToon Claes <toon@gitlab.com>2017-05-24 23:12:40 +0300
committerToon Claes <toon@gitlab.com>2017-05-30 23:45:59 +0300
commit0f0b9a8466747f69e210fc27778f96ab8ef628bc (patch)
treecfe7bea389ec5f107c4e7261879235c6700baf09 /lib
parent01c6323d238706bc8d0acb0273552a094c996ca0 (diff)
Use helper to construct Finder params
The ProjectsFinder and GroupFinder both support the same set of params. And the `/api/v4/projects` and `/api/v4/group/:id/projects` also support the same set of params. But they do not match the Finder params. So use a helper method to transform them.
Diffstat (limited to 'lib')
-rw-r--r--lib/api/groups.rb2
-rw-r--r--lib/api/helpers.rb10
-rw-r--r--lib/api/projects.rb9
3 files changed, 12 insertions, 9 deletions
diff --git a/lib/api/groups.rb b/lib/api/groups.rb
index ee85b777aff..aacc3356a0e 100644
--- a/lib/api/groups.rb
+++ b/lib/api/groups.rb
@@ -151,7 +151,7 @@ module API
end
get ":id/projects" do
group = find_group!(params[:id])
- projects = GroupProjectsFinder.new(group: group, current_user: current_user).execute
+ projects = GroupProjectsFinder.new(group: group, current_user: current_user, params: project_finder_params).execute
projects = filter_projects(projects)
entity = params[:simple] ? Entities::BasicProjectDetails : Entities::Project
present paginate(projects), with: entity, current_user: current_user
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb
index 2855bd7385d..17f57cfb8d7 100644
--- a/lib/api/helpers.rb
+++ b/lib/api/helpers.rb
@@ -264,6 +264,16 @@ module API
projects.reorder(params[:order_by] => params[:sort])
end
+ def project_finder_params
+ finder_params = {}
+ finder_params[:non_public] = true if params[:membership].present?
+ finder_params[:starred] = true if params[:starred].present?
+ finder_params[:visibility_level] = Gitlab::VisibilityLevel.level_value(params[:visibility]) if params[:visibility]
+ finder_params[:archived] = params[:archived]
+ finder_params[:search] = params[:search] if params[:search]
+ finder_params
+ end
+
# file helpers
def uploaded_file(field, uploads_path)
diff --git a/lib/api/projects.rb b/lib/api/projects.rb
index 7610e3cbacc..267dd2a74d7 100644
--- a/lib/api/projects.rb
+++ b/lib/api/projects.rb
@@ -68,14 +68,7 @@ module API
end
def present_projects(options = {})
- finder_params = {}
- finder_params[:non_public] = true if params[:membership].present?
- finder_params[:starred] = true if params[:starred].present?
- finder_params[:visibility_level] = Gitlab::VisibilityLevel.level_value(params[:visibility]) if params[:visibility]
- finder_params[:archived] = params[:archived]
- finder_params[:search] = params[:search] if params[:search]
-
- projects = ProjectsFinder.new(current_user: current_user, params: finder_params).execute
+ projects = ProjectsFinder.new(current_user: current_user, params: project_finder_params).execute
projects = filter_projects(projects)
projects = projects.with_statistics if params[:statistics]
projects = projects.with_issues_enabled if params[:with_issues_enabled]