debian-mirror-gitlab/app/services/user_project_access_changed_service.rb

30 lines
874 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
class UserProjectAccessChangedService
2020-05-24 23:13:21 +05:30
DELAY = 1.hour
HIGH_PRIORITY = :high
LOW_PRIORITY = :low
2017-08-17 22:00:37 +05:30
def initialize(user_ids)
@user_ids = Array.wrap(user_ids)
end
2020-05-24 23:13:21 +05:30
def execute(blocking: true, priority: HIGH_PRIORITY)
2018-03-17 18:26:18 +05:30
bulk_args = @user_ids.map { |id| [id] }
if blocking
AuthorizedProjectsWorker.bulk_perform_and_wait(bulk_args)
else
2020-05-24 23:13:21 +05:30
if priority == HIGH_PRIORITY
AuthorizedProjectsWorker.bulk_perform_async(bulk_args) # rubocop:disable Scalability/BulkPerformWithContext
else
2020-06-23 00:09:42 +05:30
AuthorizedProjectUpdate::UserRefreshWithLowUrgencyWorker.bulk_perform_in( # rubocop:disable Scalability/BulkPerformWithContext
DELAY, bulk_args, batch_size: 100, batch_delay: 30.seconds)
2020-05-24 23:13:21 +05:30
end
2018-03-17 18:26:18 +05:30
end
2017-08-17 22:00:37 +05:30
end
end
2019-12-04 20:38:33 +05:30
2021-06-08 01:23:25 +05:30
UserProjectAccessChangedService.prepend_mod_with('UserProjectAccessChangedService')