Skip to content

Commit

Permalink
Fixing fatal error on dashboard, also adding slim view for installs w…
Browse files Browse the repository at this point in the history
…ith more than 10 projects
  • Loading branch information
Dan Cryer committed Dec 3, 2014
1 parent 9eeaabc commit 60dab35
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 74 deletions.
5 changes: 3 additions & 2 deletions PHPCI/Store/BuildStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ public function getLastBuildByStatus($projectId = null, $status = Build::STATUS_
$stmt->bindValue(':status', $status);

if ($stmt->execute()) {
$res = $stmt->fetch(\PDO::FETCH_ASSOC);
return new Build($res);
if ($data = $stmt->fetch(\PDO::FETCH_ASSOC)) {
return new Build($data);
}
} else {
return array();
}
Expand Down
70 changes: 50 additions & 20 deletions PHPCI/View/SummaryTable.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -75,37 +75,66 @@ foreach($projects as $project):
$subcls = 'yellow';
}


$buildCount = count($builds[$project->getId()]);
$lastSuccess = $successful[$project->getId()];
$lastFailure = $failed[$project->getId()];
$message = 'No builds yet!';
$shortMessage = 'No builds yet!';

if ($buildCount > 0) {
if ($failures > 0) {
$shortMessage = $failures . ' / ' . $buildCount . ' failed.';
$message = $failures . ' out of the last ' . $buildCount . ' builds failed.';

if (!is_null($lastSuccess) && !is_null($lastSuccess->getFinished())) {
$message .= ' The last successful build was ' . $lastSuccess->getFinished()->format('M j Y') . '.';
} else {
$message .= ' This project has never built successfully.';
}
} else {
$shortMessage = $buildCount . ' / ' . $buildCount . ' passed.';
$message = 'All of the last ' . $buildCount . ' builds passed.';

if (!is_null($lastFailure) && !is_null($lastFailure->getFinished())) {
$message .= ' The last failed build was ' . $lastFailure->getFinished()->format('M j Y') . '.';
} else {
$message .= ' This project has never failed to build.';
}
}
}

?>

<?php if (count($projects) > 10): ?>

<div class="small-box bg-<?php print $subcls; ?>">
<div class="inner">
<h4>
<strong>
<a href="<?php print PHPCI_URL; ?>project/view/<?php print $project->getId(); ?>">
<?php print $project->getTitle(); ?>
</a>
</strong> -
<?php print $shortMessage; ?>
</h4>
</div>
</div>

<?php else: ?>

<div class="small-box bg-<?php print $subcls; ?>">
<div class="inner">
<h3>
<a href="<?php print PHPCI_URL; ?>project/view/<?php print $project->getId(); ?>">
<?php print $project->getTitle(); ?>
</a>
</h3>

<p>
<?php if ($failures > 0): ?>
<?php print $failures; ?> out of the last
<?php print count($builds[$project->getId()]); ?> builds have failed.

<?php if (!is_null($successful[$project->getId()])): ?>
The last successful build was
<?php print $successful[$project->getId()]->getFinished()->format('M j Y'); ?>
<?php else: ?>
This project has never built successfully.
<?php endif; ?>
<?php else: ?>
All of the last <?php print count($builds[$project->getId()]); ?> builds passed.

<?php if (!is_null($failed[$project->getId()])): ?>
The last failed build was
<?php print $failed[$project->getId()]->getFinished()->format('M j Y'); ?>
<?php else: ?>
This project has never failed to build.
<?php endif; ?>
<?php endif; ?>
<?php print $message; ?>
</p>

</div>
<div class="icon">
<i class="fa fa-<?php print $project->getIcon(); ?>"></i>
Expand All @@ -115,4 +144,5 @@ foreach($projects as $project):
</a>
</div>

<?php endif; ?>
<?php endforeach; ?>
2 changes: 1 addition & 1 deletion PHPCI/View/layout.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
margin-bottom: 20px;
}

.small-box h3 a {
.small-box h3 a, .small-box h4 a {
color: #fff;
}

Expand Down
Loading

0 comments on commit 60dab35

Please sign in to comment.