Welcome to mirror list, hosted at ThFree Co, Russian Federation.

group_private_service.rb « destroy « todos « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 60599ca9ca4e432cb94f9188aee73e08ae09b96f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# frozen_string_literal: true

module Todos
  module Destroy
    class GroupPrivateService < ::Todos::Destroy::BaseService
      extend ::Gitlab::Utils::Override

      attr_reader :group

      # rubocop: disable CodeReuse/ActiveRecord
      def initialize(group_id)
        @group = Group.find_by(id: group_id)
      end
      # rubocop: enable CodeReuse/ActiveRecord

      private

      override :todos
      # rubocop: disable CodeReuse/ActiveRecord
      def todos
        Todo.where(group_id: group.id)
      end
      # rubocop: enable CodeReuse/ActiveRecord

      override :authorized_users
      def authorized_users
        User.from_union([
          group.project_users_with_descendants.select(:id),
          group.members_with_parents.select(:user_id)
        ], remove_duplicates: false)
      end

      override :todos_to_remove?
      def todos_to_remove?
        group&.private?
      end
    end
  end
end