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
Instance Method Summary collapse
- #approved? ⇒ Boolean
- #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
#approved? ⇒ Boolean
68 69 70 |
# File 'app/models/command_proposal/iteration.rb', line 68 def approved? super || (session_type == "function" && approved_at?) end |
#brings ⇒ Object
57 58 59 60 61 62 |
# File 'app/models/command_proposal/iteration.rb', line 57 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
72 73 74 |
# File 'app/models/command_proposal/iteration.rb', line 72 def complete? success? || failed? || cancelled? || terminated? end |
#duration ⇒ Object
84 85 86 87 88 |
# File 'app/models/command_proposal/iteration.rb', line 84 def duration return unless started_at? (completed_at || stopped_at || Time.current) - started_at end |
#end_time ⇒ Object
90 91 92 |
# File 'app/models/command_proposal/iteration.rb', line 90 def end_time completed_at || stopped_at || Time.current end |
#force_reset ⇒ Object
94 95 96 97 |
# File 'app/models/command_proposal/iteration.rb', line 94 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
99 100 101 102 103 |
# File 'app/models/command_proposal/iteration.rb', line 99 def line_count return 0 if code.blank? code.count("\n") end |
#params ⇒ Object
53 54 55 |
# File 'app/models/command_proposal/iteration.rb', line 53 def params code.scan(/params\[[:\"\'](.*?)[\'\"]?\]/).flatten.uniq end |
#pending? ⇒ Boolean
76 77 78 |
# File 'app/models/command_proposal/iteration.rb', line 76 def pending? created? end |
#primary_iteration? ⇒ Boolean
64 65 66 |
# File 'app/models/command_proposal/iteration.rb', line 64 def primary_iteration? task.primary_iteration == self end |
#running? ⇒ Boolean
80 81 82 |
# File 'app/models/command_proposal/iteration.rb', line 80 def running? started? || cancelling? end |