Skip to content

Commit

Permalink
Make sure we always show the correct error count on the build errors …
Browse files Browse the repository at this point in the history
…tab.
  • Loading branch information
Dan Cryer committed Apr 27, 2016
1 parent 77e9710 commit 49db1a2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion PHPCI/Controller/BuildController.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ protected function getBuildData(Build $build)
$errorView->build = $build;
$errorView->errors = $errors;

$data['errors'] = count($errors);
$data['errors'] = $errorStore->getErrorTotalForBuild($build->getId());
$data['error_html'] = $errorView->render();
$data['since'] = (new \DateTime())->format('Y-m-d H:i:s');

Expand Down
23 changes: 23 additions & 0 deletions PHPCI/Store/BuildErrorStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,27 @@ public function getErrorsForBuild($buildId, $since = null)
return array();
}
}

/**
* Gets the total number of errors for a given build.
* @param $buildId
* @param string $since date string
* @return array
*/
public function getErrorTotalForBuild($buildId)
{
$query = 'SELECT COUNT(*) AS total FROM build_error
WHERE build_id = :build';

$stmt = Database::getConnection('read')->prepare($query);

$stmt->bindValue(':build', $buildId, \PDO::PARAM_INT);

if ($stmt->execute()) {
$res = $stmt->fetch(\PDO::FETCH_ASSOC);
return $res['total'];
} else {
return array();
}
}
}

0 comments on commit 49db1a2

Please sign in to comment.