diff options
Diffstat (limited to 'app/services/todos/destroy/private_features_service.rb')
-rw-r--r-- | app/services/todos/destroy/private_features_service.rb | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/app/services/todos/destroy/private_features_service.rb b/app/services/todos/destroy/private_features_service.rb deleted file mode 100644 index 44c3ff231f8..00000000000 --- a/app/services/todos/destroy/private_features_service.rb +++ /dev/null @@ -1,46 +0,0 @@ -# frozen_string_literal: true - -module Todos - module Destroy - class PrivateFeaturesService < ::Todos::Destroy::BaseService - attr_reader :project_ids, :user_id - - def initialize(project_ids, user_id = nil) - @project_ids = project_ids - @user_id = user_id - end - - # rubocop: disable CodeReuse/ActiveRecord - def execute - ProjectFeature.where(project_id: project_ids).each do |project_features| - target_types = [] - target_types << Issue.name if private?(project_features.issues_access_level) - target_types << MergeRequest.name if private?(project_features.merge_requests_access_level) - target_types << Commit.name if private?(project_features.repository_access_level) - - next if target_types.empty? - - remove_todos(project_features.project_id, target_types) - end - end - # rubocop: enable CodeReuse/ActiveRecord - - private - - def private?(feature_level) - feature_level == ProjectFeature::PRIVATE - end - - # rubocop: disable CodeReuse/ActiveRecord - def remove_todos(project_id, target_types) - items = Todo.where(project_id: project_id) - items = items.where(user_id: user_id) if user_id - - items.where.not(user_id: authorized_users) - .where(target_type: target_types) - .delete_all - end - # rubocop: enable CodeReuse/ActiveRecord - end - end -end |