Class: CommandProposal::Iteration
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- CommandProposal::Iteration
- Includes:
- Service::ExternalBelong
- Defined in:
- app/models/command_proposal/iteration.rb
Constant Summary collapse
- TRUNCATE_COUNT =
2000- PAGINATION_PER =
Also hardcoded in JS: app/assets/javascripts/command_proposal/console.js
2
Instance Method Summary collapse
- #brings ⇒ Object
- #complete? ⇒ Boolean
- #duration ⇒ Object
- #end_time ⇒ Object
- #force_reset ⇒ Object
- #line_count ⇒ Object
- #params ⇒ Object
- #pending? ⇒ Boolean
- #primary_iteration? ⇒ Boolean
- #running? ⇒ Boolean
Instance Method Details
#brings ⇒ Object
58 59 60 61 62 63 |
# File 'app/models/command_proposal/iteration.rb', line 58 def brings bring_str = code.scan(/bring.*?\n/).flatten.first return [] unless bring_str.present? ::CommandProposal::Task.module.where(friendly_id: bring_str.scan(/\s+\:(\w+),?/).flatten) end |
#complete? ⇒ Boolean
69 70 71 |
# File 'app/models/command_proposal/iteration.rb', line 69 def complete? success? || failed? || cancelled? || terminated? end |
#duration ⇒ Object
81 82 83 84 85 |
# File 'app/models/command_proposal/iteration.rb', line 81 def duration return unless started_at? (completed_at || stopped_at || Time.current) - started_at end |
#end_time ⇒ Object
87 88 89 |
# File 'app/models/command_proposal/iteration.rb', line 87 def end_time completed_at || stopped_at || Time.current end |
#force_reset ⇒ Object
91 92 93 94 |
# File 'app/models/command_proposal/iteration.rb', line 91 def force_reset # Debugging method. Should never actually be called. update(status: :approved, result: nil, completed_at: nil, stopped_at: nil, started_at: nil) end |
#line_count ⇒ Object
96 97 98 99 100 |
# File 'app/models/command_proposal/iteration.rb', line 96 def line_count return 0 if code.blank? code.count("\n") end |
#params ⇒ Object
54 55 56 |
# File 'app/models/command_proposal/iteration.rb', line 54 def params code.scan(/params\[[:\"\'](.*?)[\'\"]?\]/).flatten.uniq end |
#pending? ⇒ Boolean
73 74 75 |
# File 'app/models/command_proposal/iteration.rb', line 73 def pending? created? end |
#primary_iteration? ⇒ Boolean
65 66 67 |
# File 'app/models/command_proposal/iteration.rb', line 65 def primary_iteration? task.primary_iteration == self end |
#running? ⇒ Boolean
77 78 79 |
# File 'app/models/command_proposal/iteration.rb', line 77 def running? started? || cancelling? end |