diff options
author | Valery Sizov <valery@gitlab.com> | 2018-07-19 18:32:12 +0000 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2018-07-19 18:32:12 +0000 |
commit | c3c7f26a34d66ed4c2a5a2315c9b61e9a1ca27ee (patch) | |
tree | 43f38d14a122796f09b0c2f2b1e12f7a3cedfff3 /lib/api/projects.rb | |
parent | 1df0a17a1dba03d11830da2560881374c726d1fc (diff) | |
download | gitlab-ce-c3c7f26a34d66ed4c2a5a2315c9b61e9a1ca27ee.tar.gz |
Backport of gitlab-org/gitlab-ee!6137
Diffstat (limited to 'lib/api/projects.rb')
-rw-r--r-- | lib/api/projects.rb | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 0888e3befac..889e3d4f819 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -9,6 +9,21 @@ module API before { authenticate_non_get! } helpers do + params :optional_filter_params_ee do + # EE::API::Projects would override this helper + end + + # EE::API::Projects would override this method + def apply_filters(projects) + projects = projects.with_issues_available_for_user(current_user) if params[:with_issues_enabled] + projects = projects.with_merge_requests_enabled if params[:with_merge_requests_enabled] + projects = projects.with_statistics if params[:statistics] + + projects + end + end + + helpers do params :statistics_params do optional :statistics, type: Boolean, default: false, desc: 'Include project statistics' end @@ -39,6 +54,8 @@ module API optional :membership, type: Boolean, default: false, desc: 'Limit by projects that the current user is a member of' optional :with_issues_enabled, type: Boolean, default: false, desc: 'Limit by enabled issues feature' optional :with_merge_requests_enabled, type: Boolean, default: false, desc: 'Limit by enabled merge requests feature' + + use :optional_filter_params_ee end params :create_params do @@ -52,9 +69,7 @@ module API def present_projects(projects, options = {}) projects = reorder_projects(projects) - projects = projects.with_issues_available_for_user(current_user) if params[:with_issues_enabled] - projects = projects.with_merge_requests_enabled if params[:with_merge_requests_enabled] - projects = projects.with_statistics if params[:statistics] + projects = apply_filters(projects) projects = paginate(projects) projects, options = with_custom_attributes(projects, options) |