Make sure we always show the correct error count on the build errors tab.
This commit is contained in:
parent
77e9710d09
commit
49db1a26ba
|
@ -180,7 +180,7 @@ class BuildController extends \PHPCI\Controller
|
||||||
$errorView->build = $build;
|
$errorView->build = $build;
|
||||||
$errorView->errors = $errors;
|
$errorView->errors = $errors;
|
||||||
|
|
||||||
$data['errors'] = count($errors);
|
$data['errors'] = $errorStore->getErrorTotalForBuild($build->getId());
|
||||||
$data['error_html'] = $errorView->render();
|
$data['error_html'] = $errorView->render();
|
||||||
$data['since'] = (new \DateTime())->format('Y-m-d H:i:s');
|
$data['since'] = (new \DateTime())->format('Y-m-d H:i:s');
|
||||||
|
|
||||||
|
|
|
@ -54,4 +54,27 @@ class BuildErrorStore extends BuildErrorStoreBase
|
||||||
return array();
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue