- ec = exit_code
- return "Failed" if (ec && ec != 0)
- state = get_combined(:state)
- return "Ready" if ((priority == 0) and (["Queued", "Locked"].include?(state)))
- state
+ if get(:state) == 'Final' && get(:state, @container) != 'Complete'
+ # Request was finalized before its container started (or the
+ # container was cancelled)
+ return 'Cancelled'
+ end
+ state = get(:state, @container) || get(:state, @proxied)
+ case state
+ when 'Locked', 'Queued'
+ if priority == 0
+ 'On hold'
+ else
+ 'Queued'
+ end
+ when 'Complete'
+ if exit_code == 0
+ state
+ else
+ 'Failed'
+ end
+ when 'Running'
+ if runtime_status[:error]
+ 'Failing'
+ elsif runtime_status[:warning]
+ 'Warning'
+ else
+ state
+ end
+ else
+ # Cancelled, or Uncommitted (no container assigned)
+ state
+ end
+ end
+
+ def runtime_status
+ return get(:runtime_status, @container) || get(:runtime_status, @proxied)
+ end
+
+ def state_bootstrap_class
+ case state_label
+ when 'Failing'
+ 'danger'
+ when 'Warning'
+ 'warning'
+ else
+ super
+ end