Skip to content

Commit 49db1a2

Browse files
author
Dan Cryer
committed
Make sure we always show the correct error count on the build errors tab.
1 parent 77e9710 commit 49db1a2

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

PHPCI/Controller/BuildController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ protected function getBuildData(Build $build)
180180
$errorView->build = $build;
181181
$errorView->errors = $errors;
182182

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

PHPCI/Store/BuildErrorStore.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,27 @@ public function getErrorsForBuild($buildId, $since = null)
5454
return array();
5555
}
5656
}
57+
58+
/**
59+
* Gets the total number of errors for a given build.
60+
* @param $buildId
61+
* @param string $since date string
62+
* @return array
63+
*/
64+
public function getErrorTotalForBuild($buildId)
65+
{
66+
$query = 'SELECT COUNT(*) AS total FROM build_error
67+
WHERE build_id = :build';
68+
69+
$stmt = Database::getConnection('read')->prepare($query);
70+
71+
$stmt->bindValue(':build', $buildId, \PDO::PARAM_INT);
72+
73+
if ($stmt->execute()) {
74+
$res = $stmt->fetch(\PDO::FETCH_ASSOC);
75+
return $res['total'];
76+
} else {
77+
return array();
78+
}
79+
}
5780
}

0 commit comments

Comments
 (0)