show build duration on Dashboard -> Latest Builds
if a build is not pending then its duration will be displayed next to last updated time, with time units: 1h 28m 52s
This commit is contained in:
parent
89817f456f
commit
7165e8de3c
|
@ -883,6 +883,32 @@ class Build extends Model
|
|||
return $end->getTimestamp() - $start->getTimestamp();
|
||||
}
|
||||
|
||||
/**
|
||||
* get time a build has been running for in hour/minute/seconds format (e.g. 1h 21m 45s)
|
||||
* @return string
|
||||
*/
|
||||
public function getPrettyDuration()
|
||||
{
|
||||
$start = $this->getStarted();
|
||||
if (!$start) {
|
||||
$start = new \DateTime();
|
||||
}
|
||||
$end = $this->getFinished();
|
||||
if (!$end) {
|
||||
$end = new \DateTime();
|
||||
}
|
||||
|
||||
$diff = date_diff($start, $end);
|
||||
$parts = [];
|
||||
foreach (['y', 'm', 'd', 'h', 'i', 's'] as $time_part) {
|
||||
if ($diff->{$time_part} != 0) {
|
||||
$parts[] = $diff->{$time_part} . ($time_part == 'i' ? 'm' : $time_part);
|
||||
}
|
||||
}
|
||||
|
||||
return implode(" ", $parts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a working copy by cloning, copying, or similar.
|
||||
*
|
||||
|
|
|
@ -48,7 +48,14 @@
|
|||
<li>
|
||||
<i class="fa fa-<?php print $build->getProject()->getIcon(); ?> bg-<?php print $color; ?>"></i>
|
||||
<div class="timeline-item">
|
||||
<span class="time"><i class="fa fa-clock-o"></i> <?= $updated->format('H:i:s'); ?></span>
|
||||
<span class="time"><i class="fa fa-clock-o"></i>
|
||||
<?php
|
||||
echo $updated->format('H:i:s');
|
||||
if ($build->getStatus() != \PHPCensor\Model\Build::STATUS_PENDING) {
|
||||
echo ' (' . $build->getPrettyDuration() . ')';
|
||||
}
|
||||
?>
|
||||
</span>
|
||||
<h3 class="timeline-header">
|
||||
<a href="<?php print APP_URL; ?>project/view/<?php print $build->getProjectId(); ?>">
|
||||
<?php print $build->getProject()->getTitle(); ?>
|
||||
|
|
|
@ -63,9 +63,9 @@
|
|||
if ($updated->format('Y-m-d') != $last->format('Y-m-d')): $last = $updated;
|
||||
?>
|
||||
<li class="time-label">
|
||||
<span class="bg-gray">
|
||||
<?= $last->format('Y-m-d'); ?>
|
||||
</span>
|
||||
<span class="bg-gray">
|
||||
<?= $last->format('Y-m-d'); ?>
|
||||
</span>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
|
||||
|
@ -74,7 +74,14 @@
|
|||
<li>
|
||||
<i class="fa fa-<?php print $build->getProject()->getIcon(); ?> bg-<?php print $color; ?>"></i>
|
||||
<div class="timeline-item">
|
||||
<span class="time"><i class="fa fa-clock-o"></i> <?= $updated->format('H:i:s'); ?></span>
|
||||
<span class="time"><i class="fa fa-clock-o"></i>
|
||||
<?php
|
||||
echo $updated->format('H:i:s');
|
||||
if ($build->getStatus() != \PHPCensor\Model\Build::STATUS_PENDING) {
|
||||
echo ' (' . $build->getPrettyDuration() . ')';
|
||||
}
|
||||
?>
|
||||
</span>
|
||||
<h3 class="timeline-header">
|
||||
<a href="<?php print APP_URL; ?>project/view/<?php print $build->getProjectId(); ?>">
|
||||
<?php print $build->getProject()->getTitle(); ?>
|
||||
|
|
|
@ -249,7 +249,7 @@
|
|||
<script src="<?php print APP_URL; ?>assets/vendor/admin-lte/plugins/jQueryUI/jquery-ui.min.js" type="text/javascript"></script>
|
||||
<script src="<?php print APP_URL; ?>assets/vendor/admin-lte/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
|
||||
|
||||
<link href="<?php print APP_URL; ?>assets/vendor/raphael/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
|
||||
<link href="<?php print APP_URL; ?>assets/vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
|
||||
|
||||
<script src="<?php print APP_URL; ?>assets/vendor/admin-lte/plugins/chartjs/Chart.min.js" type="text/javascript"></script>
|
||||
<script src="<?php print APP_URL; ?>assets/vendor/admin-lte/plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
|
||||
|
|
Loading…
Reference in a new issue