Skip to content
Snippets Groups Projects
Commit d10dfe2a authored by a.croix's avatar a.croix
Browse files

Compute and display running time for a training. Fix issue #34

parent ba5b6796
No related branches found
No related tags found
No related merge requests found
Pipeline #6782 passed
......@@ -120,6 +120,7 @@ class WowaJob implements ShouldQueue
public function failed()
{
$this->wowa->status = Wowa::STATE_FAILED;
$this->wowa->end_time = time();
$this->wowa->save();
}
}
......@@ -137,4 +137,22 @@ class Wowa extends Model
$logger->pushHandler(new StreamHandler($this->getLogPathOnDisk()));
return $logger;
}
public function runtime()
{
if ($this->status === Wowa::STATE_RUNNING) {
return $this->convertRuntimeToHumansFormat(time() - $this->start_time);
} elseif ($this->status === Wowa::STATE_SUCCESS || $this->status === Wowa::STATE_FAILED) {
return $this->convertRuntimeToHumansFormat($this->end_time - $this->start_time);
} else {
return "Not running yet";
}
}
private function convertRuntimeToHumansFormat(int $time)
{
$dtF = new \DateTime('@0');
$dtT = new \DateTime("@$time");
return $dtF->diff($dtT)->format('%h hours, %i minutes and %s seconds');
}
}
......@@ -5,18 +5,21 @@
<div class="row justify-content-center">
<div class="col-lg-8">
<div class="card">
<div class="card-header">{{ $wowa->created_at }}</div>
<div class="card-header">{!! $wowa->statusBadge() !!}</div>
<div style="position: relative" class="card-body">
<div class="form-inline">
{!! $wowa->statusBadge() !!}
</div>
<div id="id">
<p>
<i class="fas fa-hashtag"></i>
<b>Id</b> : {{ $wowa->id }}
</p>
</div>
<div id="runtime">
<p>
<i class="fas fa-stopwatch"></i>
<b>Runtime</b> : {{ $wowa->runtime() }}
</p>
</div>
<div id="user">
<p>
<i class="fas fa-user"></i>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment