From 4adba01c1c6c51a22343b102b952248afa01cbe5 Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Wed, 18 Jul 2018 21:58:49 +0300 Subject: Backport of https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/6137 --- doc/api/projects.md | 2 ++ lib/api/projects.rb | 23 ++++++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/doc/api/projects.md b/doc/api/projects.md index a35c2a56992..5d0dbbadb3c 100644 --- a/doc/api/projects.md +++ b/doc/api/projects.md @@ -55,6 +55,8 @@ GET /projects | `with_custom_attributes` | boolean | no | Include [custom attributes](custom_attributes.md) in response (admins only) | | `with_issues_enabled` | boolean | no | Limit by enabled issues feature | | `with_merge_requests_enabled` | boolean | no | Limit by enabled merge requests feature | +| `wiki_checksum_failed` | boolean | no | Limit projects where the wiki checksum calculation has failed. Only available in GitLab EE with Geo enabled | +| `repository_checksum_failed` | boolean | no | Limit projects where the repository checksum calculation has failed. Only available in GitLab EE with Geo enabled | When `simple=true` or the user is unauthenticated this returns something like: diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 0888e3befac..dd79ead5aae 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -8,6 +8,23 @@ 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 + + prepend EE::API::Projects + helpers do params :statistics_params do optional :statistics, type: Boolean, default: false, desc: 'Include project statistics' @@ -39,6 +56,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 +71,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) -- cgit v1.2.1