diff --git a/PHPCI/Controller/HomeController.php b/PHPCI/Controller/HomeController.php index 3d42775d..f84bebe0 100644 --- a/PHPCI/Controller/HomeController.php +++ b/PHPCI/Controller/HomeController.php @@ -70,13 +70,24 @@ class HomeController extends \PHPCI\Controller protected function getSummaryHtml($projects) { $summaryBuilds = array(); + $successes = array(); + $failures = array(); + foreach ($projects['items'] as $project) { $summaryBuilds[$project->getId()] = $this->buildStore->getLatestBuilds($project->getId()); + + $success = $this->buildStore->getLastBuildByStatus($project->getId(), Build::STATUS_SUCCESS); + $failure = $this->buildStore->getLastBuildByStatus($project->getId(), Build::STATUS_FAILED); + + $successes[$project->getId()] = $success; + $failures[$project->getId()] = $failure; } $summaryView = new b8\View('SummaryTable'); $summaryView->projects = $projects['items']; $summaryView->builds = $summaryBuilds; + $summaryView->successful = $successes; + $summaryView->failed = $failures; return $summaryView->render(); } diff --git a/PHPCI/Store/BuildStore.php b/PHPCI/Store/BuildStore.php index 8c36b3b1..b28142a7 100644 --- a/PHPCI/Store/BuildStore.php +++ b/PHPCI/Store/BuildStore.php @@ -53,6 +53,21 @@ class BuildStore extends BuildStoreBase } } + public function getLastBuildByStatus($projectId = null, $status = Build::STATUS_SUCCESS) + { + $query = 'SELECT * FROM build WHERE project_id = :pid AND status = :status ORDER BY id DESC LIMIT 1'; + $stmt = Database::getConnection('read')->prepare($query); + $stmt->bindValue(':pid', $projectId); + $stmt->bindValue(':status', $status); + + if ($stmt->execute()) { + $res = $stmt->fetch(\PDO::FETCH_ASSOC); + return new Build($res); + } else { + return array(); + } + } + public function getByProjectAndCommit($projectId, $commitId) { $query = 'SELECT * FROM `build` WHERE `project_id` = :project_id AND `commit_id` = :commit_id'; diff --git a/PHPCI/View/Home/index.phtml b/PHPCI/View/Home/index.phtml index 5a1f7a84..fb49ba88 100644 --- a/PHPCI/View/Home/index.phtml +++ b/PHPCI/View/Home/index.phtml @@ -1,5 +1,10 @@
-
+ +
+ +
+ +

Latest Builds

@@ -12,25 +17,6 @@ getProject()->getType()) { - case 'github': - $icon = 'github'; - break; - - case 'bitbucket': - $icon = 'bitbucket'; - break; - - case 'git': - case 'gitlab': - $icon = 'git'; - break; - - default: - $icon = 'cog'; - break; - } - switch ($build->getStatus()) { case \PHPCI\Model\Build::STATUS_NEW: $updated = $build->getCreated(); @@ -69,13 +55,17 @@
  • - +
    format('g:ia'); ?>

    getProject()->getTitle(); ?> + - + + Build #getId(); ?> +

    @@ -95,21 +85,4 @@
    -
    -
    -

    Project Overview

    - - - - - - - - - - - -
    ProjectHealth
    -
    -
  • diff --git a/PHPCI/View/SummaryTable.phtml b/PHPCI/View/SummaryTable.phtml index 22b0cb50..77d71387 100644 --- a/PHPCI/View/SummaryTable.phtml +++ b/PHPCI/View/SummaryTable.phtml @@ -66,37 +66,51 @@ foreach($projects as $project): if ($failures == 0) { $health = 'Good'; - $subcls = 'success'; + $subcls = 'green'; } elseif ($failures > $successes) { $health = 'Bad'; - $subcls = 'danger'; + $subcls = 'red'; } else { $health = 'Warning'; - $subcls = 'warning'; + $subcls = 'yellow'; } ?> - - - getTitle()) ?> -
    - Last Success: -
    - Last Failure: - - - - - -
    - '; - } - ?> - +
    +
    +

    + getTitle(); ?> +

    +

    + 0): ?> + out of the last + getId()]); ?> builds have failed. + + getId()])): ?> + The last successful build was + getId()]->getFinished()->format('M j Y'); ?> + + This project has never built successfully. + + + All of the last getId()]); ?> builds passed. + + getId()])): ?> + The last failed build was + getId()]->getFinished()->format('M j Y'); ?> + + This project has never failed to build. + + +

    +
    +
    + +
    + + View Project + +
    - build now » -