Class: Run
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Run
- Defined in:
- app/models/run.rb
Constant Summary collapse
- STATUSES =
%w[queued running needs_input succeeded failed cancelled].freeze
- EXHAUSTION =
A budget/timeout outcome, whether the segment parked (needs_input) or was recorded as a failure. The parked message ("…turn budget mid-work…") lives on the last question event; the failure message (failure_reason) lives on result_summary. Either signals "try again with a fresh budget," not a bug.
/turn budget|max-turns budget|timed out|timeout/i
Instance Method Summary collapse
- #exhausted? ⇒ Boolean
- #finished? ⇒ Boolean
-
#restartable? ⇒ Boolean
A run the user can relaunch from the work panel: an execution-column run that parked or failed on its budget/timeout.
Instance Method Details
#exhausted? ⇒ Boolean
20 21 22 23 |
# File 'app/models/run.rb', line 20 def exhausted? text = needs_input? ? events.where(kind: "question").order(:id).last&.text : result_summary text.to_s.match?(EXHAUSTION) end |
#finished? ⇒ Boolean
18 |
# File 'app/models/run.rb', line 18 def finished? = %w[succeeded failed cancelled].include?(status) |
#restartable? ⇒ Boolean
A run the user can relaunch from the work panel: an execution-column run that parked or failed on its budget/timeout. Restart resumes the surviving session (fresh budget) or starts a clean run when no session remains.
28 |
# File 'app/models/run.rb', line 28 def restartable? = card.column.execution? && (needs_input? || failed?) && exhausted? |