Module: CommandProposal::Services::ShutDown

Defined in:
lib/command_proposal/services/shut_down.rb

Class Method Summary collapse

Class Method Details

.reset_allObject



6
7
8
9
10
11
# File 'lib/command_proposal/services/shut_down.rb', line 6

def reset_all
  pending = ::CommandProposal::Iteration.where(status: [:started, :cancelling])
  pending.find_each do |iteration|
    terminate(iteration)
  end
end

.terminate(iteration) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/command_proposal/services/shut_down.rb', line 13

def terminate(iteration)
  return unless iteration.running?

  terminated_result = "#{iteration&.result}\n\n~~~~~ TERMINATED ~~~~~"
  iteration.update(
    status: :terminated,
    result: terminated_result,
    completed_at: Time.current
  )
end