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

base_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: 71cd7921f328efde73cbce00027f454ad5a4e4bc (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
module Todos
  module Destroy
    class BaseService
      def execute
        return unless todos_to_remove?

        without_authorized(todos).delete_all
      end

      private

      def without_authorized(items)
        items.where('user_id NOT IN (?)', authorized_users)
      end

      def authorized_users
        ProjectAuthorization.select(:user_id).where(project_id: project_ids)
      end

      def todos
        # overridden in subclasses
      end

      def project_ids
        # overridden in subclasses
      end

      def todos_to_remove?
        # overridden in subclasses
      end
    end
  end
end