diff options
Diffstat (limited to 'app/services/user_project_access_changed_service.rb')
-rw-r--r-- | app/services/user_project_access_changed_service.rb | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/app/services/user_project_access_changed_service.rb b/app/services/user_project_access_changed_service.rb index 21d0861ac3f..66f1ccfab70 100644 --- a/app/services/user_project_access_changed_service.rb +++ b/app/services/user_project_access_changed_service.rb @@ -1,17 +1,26 @@ # frozen_string_literal: true class UserProjectAccessChangedService + DELAY = 1.hour + + HIGH_PRIORITY = :high + LOW_PRIORITY = :low + def initialize(user_ids) @user_ids = Array.wrap(user_ids) end - def execute(blocking: true) + def execute(blocking: true, priority: HIGH_PRIORITY) bulk_args = @user_ids.map { |id| [id] } if blocking AuthorizedProjectsWorker.bulk_perform_and_wait(bulk_args) else - AuthorizedProjectsWorker.bulk_perform_async(bulk_args) # rubocop:disable Scalability/BulkPerformWithContext + if priority == HIGH_PRIORITY + AuthorizedProjectsWorker.bulk_perform_async(bulk_args) # rubocop:disable Scalability/BulkPerformWithContext + else + AuthorizedProjectUpdate::UserRefreshWithLowUrgencyWorker.bulk_perform_in(DELAY, bulk_args) # rubocop:disable Scalability/BulkPerformWithContext + end end end end |