blob: d3528b0674bc89dfbd392a43e591a13d0fb1d119 (
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
|
# frozen_string_literal: true
class DisallowTwoFactorForSubgroupsWorker
include ApplicationWorker
data_consistency :always
sidekiq_options retry: 3
include ExceptionBacktrace
INTERVAL = 2.seconds.to_i
feature_category :subgroups
tags :exclude_from_kubernetes
idempotent!
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
end
|