summaryrefslogtreecommitdiff
path: root/app/services/authorized_project_update/project_access_changed_service.rb
blob: dafec1fef59a2e5c494d355d2e0724fedd65827e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true

module AuthorizedProjectUpdate
  class ProjectAccessChangedService
    def initialize(project_ids)
      @project_ids = Array.wrap(project_ids)
    end

    def execute(blocking: true)
      return if @project_ids.empty?

      bulk_args = @project_ids.map { |id| [id] }

      if blocking
        AuthorizedProjectUpdate::ProjectRecalculateWorker.bulk_perform_and_wait(bulk_args)
      else
        AuthorizedProjectUpdate::ProjectRecalculateWorker.bulk_perform_async(bulk_args) # rubocop:disable Scalability/BulkPerformWithContext
      end
    end
  end
end