2018-07-05 06:18:17 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-10-11 08:25:17 -04:00
|
|
|
class UserProjectAccessChangedService
|
2020-05-15 08:08:28 -04:00
|
|
|
DELAY = 1.hour
|
|
|
|
|
|
|
|
HIGH_PRIORITY = :high
|
|
|
|
LOW_PRIORITY = :low
|
|
|
|
|
2016-10-11 08:25:17 -04:00
|
|
|
def initialize(user_ids)
|
|
|
|
@user_ids = Array.wrap(user_ids)
|
|
|
|
end
|
|
|
|
|
2020-05-15 08:08:28 -04:00
|
|
|
def execute(blocking: true, priority: HIGH_PRIORITY)
|
2017-08-23 10:28:16 -04:00
|
|
|
bulk_args = @user_ids.map { |id| [id] }
|
|
|
|
|
|
|
|
if blocking
|
|
|
|
AuthorizedProjectsWorker.bulk_perform_and_wait(bulk_args)
|
|
|
|
else
|
2020-05-15 08:08:28 -04:00
|
|
|
if priority == HIGH_PRIORITY
|
|
|
|
AuthorizedProjectsWorker.bulk_perform_async(bulk_args) # rubocop:disable Scalability/BulkPerformWithContext
|
|
|
|
else
|
2020-06-02 14:08:32 -04:00
|
|
|
AuthorizedProjectUpdate::UserRefreshWithLowUrgencyWorker.bulk_perform_in( # rubocop:disable Scalability/BulkPerformWithContext
|
|
|
|
DELAY, bulk_args, batch_size: 100, batch_delay: 30.seconds)
|
2020-05-15 08:08:28 -04:00
|
|
|
end
|
2017-08-23 10:28:16 -04:00
|
|
|
end
|
2016-10-11 08:25:17 -04:00
|
|
|
end
|
|
|
|
end
|
2019-09-13 09:26:31 -04:00
|
|
|
|
|
|
|
UserProjectAccessChangedService.prepend_if_ee('EE::UserProjectAccessChangedService')
|