public function serialize()
{
$user = 'Pantheon';
if (isset($this->get('user')->email)) {
$user = $this->get('user')->email;
}
if ($this->get('total_time')) {
$elapsed_time = $this->get('total_time');
} else {
$elapsed_time = time() - $this->get('created_at');
}
$operations_data = [];
foreach ($this->operations() as $operation) {
$operations_data[] = $operation->serialize();
}
$data = ['id' => $this->id, 'env' => $this->get('environment'), 'workflow' => $this->get('description'), 'user' => $user, 'status' => $this->getStatus(), 'time' => sprintf("%ds", $elapsed_time), 'operations' => $operations_data];
return $data;
}