Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion src/PHPCensor/Model/Build.php
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ public function getBuildPath()

if (empty($this->currentBuildPath)) {
$buildDirectory = $this->getId() . '_' . substr(md5(microtime(true)), 0, 5);
$this->currentBuildPath =
$this->currentBuildPath =
RUNTIME_DIR .
'builds' .
DIRECTORY_SEPARATOR .
Expand Down Expand Up @@ -883,6 +883,32 @@ public function getDuration()
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.
*
Expand Down
11 changes: 9 additions & 2 deletions src/PHPCensor/View/Home/ajax-timeline.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -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(); ?>
Expand All @@ -62,7 +69,7 @@
</h3>

<div class="timeline-body">
<a href="<?php echo $build->getBranchLink();?>"><?php echo $build->getProject()->getBranch(); ?></a> -
<a href="<?php echo $build->getBranchLink();?>"><?php echo $build->getProject()->getBranch(); ?></a> -
<?php
if ($build->getCommitId() !== 'Manual') {
print sprintf(
Expand Down
17 changes: 12 additions & 5 deletions src/PHPCensor/View/Home/index.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -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; ?>

Expand All @@ -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(); ?>
Expand All @@ -88,7 +95,7 @@
</h3>

<div class="timeline-body">
<a href="<?php echo $build->getBranchLink();?>"><?php echo $build->getProject()->getBranch(); ?></a> -
<a href="<?php echo $build->getBranchLink();?>"><?php echo $build->getProject()->getBranch(); ?></a> -
<?php
if ($build->getCommitId() !== 'Manual') {
print sprintf(
Expand Down
8 changes: 4 additions & 4 deletions src/PHPCensor/View/layout.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
<span><?php print $group['title']; ?></span>
<i class="fa fa-angle-left pull-right"></i>
</a>

<?php if (count($group['projects'])): ?>
<ul class="treeview-menu">
<?php foreach($group['projects'] as $project): ?>
Expand All @@ -183,10 +183,10 @@
<?php endforeach; ?>
</ul>
<?php endif; ?>

</li>
<?php endforeach; ?>

<li class="treeview">
<a href="#">
<i class="fa fa-archive"></i> <span><?php Lang::out('archived_menu'); ?></span>
Expand Down Expand Up @@ -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>
Expand Down