Class: UserProjectAccessChangedService
- Inherits:
-
Object
- Object
- UserProjectAccessChangedService
- Defined in:
- app/services/user_project_access_changed_service.rb
Constant Summary collapse
- DELAY =
1.hour
- MEDIUM_DELAY =
10.minutes
- HIGH_PRIORITY =
:high
- MEDIUM_PRIORITY =
:medium
- LOW_PRIORITY =
:low
Instance Method Summary collapse
- #execute(priority: HIGH_PRIORITY) ⇒ Object
-
#initialize(user_ids) ⇒ UserProjectAccessChangedService
constructor
A new instance of UserProjectAccessChangedService.
Constructor Details
#initialize(user_ids) ⇒ UserProjectAccessChangedService
Returns a new instance of UserProjectAccessChangedService.
11 12 13 |
# File 'app/services/user_project_access_changed_service.rb', line 11 def initialize(user_ids) @user_ids = Array.wrap(user_ids) end |
Instance Method Details
#execute(priority: HIGH_PRIORITY) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/services/user_project_access_changed_service.rb', line 15 def execute(priority: HIGH_PRIORITY) return if @user_ids.empty? bulk_args = @user_ids.map { |id| [id] } result = case priority when HIGH_PRIORITY AuthorizedProjectsWorker.bulk_perform_async(bulk_args) # rubocop:disable Scalability/BulkPerformWithContext when MEDIUM_PRIORITY AuthorizedProjectUpdate::UserRefreshWithLowUrgencyWorker.bulk_perform_in(MEDIUM_DELAY, bulk_args, batch_size: 100, batch_delay: 30.seconds) # rubocop:disable Scalability/BulkPerformWithContext when LOW_PRIORITY if Feature.disabled?(:do_not_run_safety_net_auth_refresh_jobs) do # We wrap the execution in `with_related_class_context`so as to obtain # the location of the original caller # in jobs enqueued from within `AuthorizedProjectUpdate::UserRefreshFromReplicaWorker` AuthorizedProjectUpdate::UserRefreshFromReplicaWorker.bulk_perform_in( # rubocop:disable Scalability/BulkPerformWithContext DELAY, bulk_args, batch_size: 100, batch_delay: 30.seconds) end end end ::User.sticking.bulk_stick(:user, @user_ids) result end |