Class: ForemanPatch::Round
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- ForemanPatch::Round
- Includes:
- ForemanTasks::Concerns::ActionSubject
- Defined in:
- app/models/foreman_patch/round.rb
Defined Under Namespace
Classes: Jail
Instance Method Summary collapse
Instance Method Details
#finished? ⇒ Boolean
60 61 62 |
# File 'app/models/foreman_patch/round.rb', line 60 def finished? !(task.nil? || task.pending?) end |
#progress(total = nil, done = nil) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'app/models/foreman_patch/round.rb', line 35 def progress(total = nil, done = nil) if invocations.empty? || done == 0 0 else total ||= invocations.count done ||= sub_tasks.where(result: %w(success warning error)).count ((done.to_f / total) * 100).round end end |
#progress_report ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/models/foreman_patch/round.rb', line 45 def progress_report invocations.reduce({ pending: 0, running: 0, success: 0, warning: 0, failed: 0, cancelled: 0, }) do |report, invocation| status = (invocation.status == 'planned' ? 'pending' : invocation.status) report[status.to_sym] += 1 report end end |