debian-mirror-gitlab/app/graphql/resolvers/group_milestones_resolver.rb

50 lines
1.5 KiB
Ruby
Raw Normal View History

2020-10-24 23:57:45 +05:30
# frozen_string_literal: true
module Resolvers
class GroupMilestonesResolver < MilestonesResolver
2021-10-27 15:23:28 +05:30
argument :include_ancestors, GraphQL::Types::Boolean,
2021-04-29 21:17:54 +05:30
required: false,
description: 'Include milestones from all parent groups.'
2022-03-02 08:16:31 +05:30
argument :include_descendants, GraphQL::Types::Boolean,
required: false,
description: 'Include milestones from all subgroups and subprojects.'
2020-10-24 23:57:45 +05:30
2021-01-29 00:20:46 +05:30
type Types::MilestoneType.connection_type, null: true
2020-10-24 23:57:45 +05:30
private
def parent_id_parameters(args)
2021-04-29 21:17:54 +05:30
include_ancestors = args[:include_ancestors].present?
include_descendants = args[:include_descendants].present?
return { group_ids: parent.id } unless include_ancestors || include_descendants
group_ids = if include_ancestors && include_descendants
parent.self_and_hierarchy
elsif include_ancestors
parent.self_and_ancestors
else
parent.self_and_descendants
end
project_ids = if include_descendants
group_projects.with_issues_or_mrs_available_for_user(current_user)
else
nil
end
2020-10-24 23:57:45 +05:30
{
2021-04-29 21:17:54 +05:30
group_ids: group_ids.public_or_visible_to_user(current_user).select(:id),
project_ids: project_ids
2020-10-24 23:57:45 +05:30
}
end
def group_projects
GroupProjectsFinder.new(
group: parent,
current_user: current_user,
options: { include_subgroups: true }
).execute
end
end
end