Added total builds count to index and project page

This commit is contained in:
corpsee 2015-02-28 23:13:02 +06:00
parent b8983b23a3
commit da9be4930d
4 changed files with 13 additions and 9 deletions

View file

@ -98,12 +98,16 @@ class HomeController extends \PHPCI\Controller
protected function getSummaryHtml($projects) protected function getSummaryHtml($projects)
{ {
$summaryBuilds = array(); $summaryBuilds = array();
$successes = array(); $successes = array();
$failures = array(); $failures = array();
$counts = array();
foreach ($projects['items'] as $project) { foreach ($projects['items'] as $project) {
$summaryBuilds[$project->getId()] = $this->buildStore->getLatestBuilds($project->getId()); $summaryBuilds[$project->getId()] = $this->buildStore->getLatestBuilds($project->getId());
$count = $this->buildStore->getWhere(array('project_id' => $project->getId()), 1, 0, array(), array('id' => 'DESC'));
$counts[$project->getId()] = $count['count'];
$success = $this->buildStore->getLastBuildByStatus($project->getId(), Build::STATUS_SUCCESS); $success = $this->buildStore->getLastBuildByStatus($project->getId(), Build::STATUS_SUCCESS);
$failure = $this->buildStore->getLastBuildByStatus($project->getId(), Build::STATUS_FAILED); $failure = $this->buildStore->getLastBuildByStatus($project->getId(), Build::STATUS_FAILED);
@ -112,10 +116,11 @@ class HomeController extends \PHPCI\Controller
} }
$summaryView = new b8\View('SummaryTable'); $summaryView = new b8\View('SummaryTable');
$summaryView->projects = $projects['items']; $summaryView->projects = $projects['items'];
$summaryView->builds = $summaryBuilds; $summaryView->builds = $summaryBuilds;
$summaryView->successful = $successes; $summaryView->successful = $successes;
$summaryView->failed = $failures; $summaryView->failed = $failures;
$summaryView->counts = $counts;
return $summaryView->render(); return $summaryView->render();
} }

View file

@ -86,7 +86,7 @@ class ProjectController extends PHPCI\Controller
$this->view->builds = $builds[0]; $this->view->builds = $builds[0];
$this->view->total = $builds[1]; $this->view->total = $builds[1];
$this->view->project = $project; $this->view->project = $project;
$this->view->branch = urldecode($branch); $this->view->branch = urldecode($branch);
$this->view->branches = $this->projectStore->getKnownBranches($projectId); $this->view->branches = $this->projectStore->getKnownBranches($projectId);
$this->view->page = $page; $this->view->page = $page;
$this->view->pages = $pages; $this->view->pages = $pages;

View file

@ -36,8 +36,7 @@
<div class="col-lg-9 col-md-8 col-sm-8"> <div class="col-lg-9 col-md-8 col-sm-8">
<div class="box box-primary"> <div class="box box-primary">
<div class="box-header"> <div class="box-header">
<h3 class="box-title"><?php Lang::out('builds'); ?> (<?php print $total; ?>)</h3>
<h3 class="box-title"><?php Lang::out('builds'); ?></h3>
</div> </div>
<table class="table"> <table class="table">
<thead> <thead>

View file

@ -123,7 +123,7 @@ foreach($projects as $project):
<i class="fa fa-<?php print $project->getIcon(); ?>"></i> <i class="fa fa-<?php print $project->getIcon(); ?>"></i>
</div> </div>
<a href="<?php print PHPCI_URL; ?>project/view/<?php print $project->getId(); ?>" class="small-box-footer small-box-footer-project"> <a href="<?php print PHPCI_URL; ?>project/view/<?php print $project->getId(); ?>" class="small-box-footer small-box-footer-project">
<?php Lang::out('view_project'); ?> <i class="fa fa-arrow-circle-right"></i> <?php Lang::out('view_project'); ?> (<?php print $counts[$project->getId()]; ?>) <i class="fa fa-arrow-circle-right"></i>
</a> </a>
<?php endif; ?> <?php endif; ?>