Class: CommandProposal::Iteration

Inherits:
ApplicationRecord
  • Object
show all
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

Instance Method Details

#bringsObject



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

Returns:

  • (Boolean)


69
70
71
# File 'app/models/command_proposal/iteration.rb', line 69

def complete?
  success? || failed? || cancelled? || terminated?
end

#durationObject



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_timeObject



87
88
89
# File 'app/models/command_proposal/iteration.rb', line 87

def end_time
  completed_at || stopped_at || Time.current
end

#force_resetObject



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_countObject



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

#paramsObject



54
55
56
# File 'app/models/command_proposal/iteration.rb', line 54

def params
  code.scan(/params\[[:\"\'](.*?)[\'\"]?\]/).flatten.uniq
end

#pending?Boolean

Returns:

  • (Boolean)


73
74
75
# File 'app/models/command_proposal/iteration.rb', line 73

def pending?
  created?
end

#primary_iteration?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'app/models/command_proposal/iteration.rb', line 65

def primary_iteration?
  task.primary_iteration == self
end

#running?Boolean

Returns:

  • (Boolean)


77
78
79
# File 'app/models/command_proposal/iteration.rb', line 77

def running?
  started? || cancelling?
end