diff options
Diffstat (limited to 'app/workers/pages/deactivate_mr_deployments_worker.rb')
-rw-r--r-- | app/workers/pages/deactivate_mr_deployments_worker.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/app/workers/pages/deactivate_mr_deployments_worker.rb b/app/workers/pages/deactivate_mr_deployments_worker.rb new file mode 100644 index 00000000000..88a38f7f89c --- /dev/null +++ b/app/workers/pages/deactivate_mr_deployments_worker.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +module Pages + class DeactivateMrDeploymentsWorker + include ApplicationWorker + + idempotent! + data_consistency :always # rubocop: disable SidekiqLoadBalancing/WorkerDataConsistency -- performing writes only + urgency :low + + feature_category :pages + + def perform(merge_request_id) + build_ids = Ci::Build.ids_in_merge_request(merge_request_id) + deactivate_deployments_with_build_ids(build_ids) + end + + private + + def deactivate_deployments_with_build_ids(build_ids) + PagesDeployment + .versioned + .ci_build_id_in(build_ids) + .each_batch do |batch| # rubocop: disable Style/SymbolProc -- deactivate does not accept the index argument + batch.deactivate + end + end + end +end |