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
diff options
context:
space:
mode:
Diffstat (limited to 'lib/api/milestone_responses.rb')
-rw-r--r--lib/api/milestone_responses.rb35
1 files changed, 14 insertions, 21 deletions
diff --git a/lib/api/milestone_responses.rb b/lib/api/milestone_responses.rb
index fb71cb0e791..3ef30a5fcd3 100644
--- a/lib/api/milestone_responses.rb
+++ b/lib/api/milestone_responses.rb
@@ -6,6 +6,8 @@ module API
included do
helpers do
+ include ::API::Concerns::Milestones::GroupProjectParams
+
params :optional_params do
optional :description, type: String, desc: 'The description of the milestone'
optional :due_date, type: String, desc: 'The due date of the milestone. The ISO 8601 date format (%Y-%m-%d)'
@@ -18,10 +20,11 @@ module API
optional :iids, type: Array[Integer], coerce_with: ::API::Validations::Types::CommaSeparatedToIntegerArray.coerce, desc: 'The IIDs of the milestones'
optional :title, type: String, desc: 'The title of the milestones'
optional :search, type: String, desc: 'The search criteria for the title or description of the milestone'
- optional :include_parent_milestones, type: Grape::API::Boolean, default: false,
- desc: 'Include group milestones from parent and its ancestors'
+ optional :include_parent_milestones, type: Grape::API::Boolean, desc: 'Deprecated: see `include_ancestors`'
+ optional :include_ancestors, type: Grape::API::Boolean, desc: 'Include milestones from all parent groups'
optional :updated_before, type: DateTime, desc: 'Return milestones updated before the specified datetime. Format: ISO 8601 YYYY-MM-DDTHH:MM:SSZ'
optional :updated_after, type: DateTime, desc: 'Return milestones updated after the specified datetime. Format: ISO 8601 YYYY-MM-DDTHH:MM:SSZ'
+ mutually_exclusive :include_ancestors, :include_parent_milestones
use :pagination
end
@@ -35,6 +38,13 @@ module API
end
def list_milestones_for(parent)
+ if params.include?(:include_parent_milestones)
+ params[:include_ancestors] = params.delete(:include_parent_milestones)
+ else
+ # include_ancestors should default to false
+ params[:include_ancestors] ||= false
+ end
+
milestones = MilestonesFinder.new(
params.merge(parent_finder_params(parent))
).execute
@@ -82,12 +92,10 @@ module API
end
def parent_finder_params(parent)
- include_parent = params[:include_parent_milestones].present?
-
if parent.is_a?(Project)
- { project_ids: parent.id, group_ids: (include_parent ? project_group_ids(parent) : nil) }
+ project_finder_params(parent, params)
else
- { group_ids: (include_parent ? group_and_ancestor_ids(parent) : parent.id) }
+ group_finder_params(parent, params)
end
end
@@ -108,21 +116,6 @@ module API
[MergeRequestsFinder, Entities::MergeRequestBasic]
end
end
-
- def project_group_ids(parent)
- group = parent.group
- return unless group.present?
-
- group.self_and_ancestors.select(:id)
- end
-
- def group_and_ancestor_ids(group)
- return unless group.present?
-
- group.self_and_ancestors
- .public_or_visible_to_user(current_user)
- .select(:id)
- end
end
end
end