summaryrefslogtreecommitdiff
path: root/app/workers/environments/auto_stop_worker.rb
blob: aee6e9775509aec00c0935f224acd701b5a11787 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true

module Environments
  class AutoStopWorker
    include ApplicationWorker

    data_consistency :always
    idempotent!
    feature_category :continuous_delivery

    def perform(environment_id, params = {})
      Environment.find_by_id(environment_id).try do |environment|
        stop_actions = environment.stop_actions

        user = stop_actions.last&.user
        environment.stop_with_actions!(user)
      end
    end
  end
end