Class: DisallowTwoFactorForSubgroupsWorker

Inherits:
Object
  • Object
show all
Includes:
ApplicationWorker, ExceptionBacktrace
Defined in:
app/workers/disallow_two_factor_for_subgroups_worker.rb

Constant Summary collapse

INTERVAL =
2.seconds.to_i

Constants included from ApplicationWorker

ApplicationWorker::LOGGING_EXTRA_KEY, ApplicationWorker::SAFE_PUSH_BULK_LIMIT

Constants included from WorkerAttributes

WorkerAttributes::DEFAULT_DATA_CONSISTENCY, WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_DATA_CONSISTENCIES, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES

Instance Method Summary collapse

Methods included from Gitlab::SidekiqVersioning::Worker

#job_version

Methods included from WorkerContext

#with_context

Instance Method Details

#perform(group_id) ⇒ Object


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/workers/disallow_two_factor_for_subgroups_worker.rb', line 16

def perform(group_id)
  begin
    group = Group.find(group_id)
  rescue ActiveRecord::RecordNotFound
    return
  end

  # rubocop: disable CodeReuse/ActiveRecord
  subgroups = group.descendants.where(require_two_factor_authentication: true) # rubocop: disable CodeReuse/ActiveRecord
  subgroups.find_each(batch_size: 100).with_index do |subgroup, index|
    delay = index * INTERVAL

    with_context(namespace: subgroup) do
      DisallowTwoFactorForGroupWorker.perform_in(delay, subgroup.id)
    end
  end
  # rubocop: enable CodeReuse/ActiveRecord
end