Added new errors label in build "Errors" tab.
This commit is contained in:
parent
1b65b02fa6
commit
13f763c9e2
9 changed files with 186 additions and 18 deletions
|
|
@ -201,7 +201,7 @@ class BuildErrorStore extends Store
|
|||
*/
|
||||
public function getKnownSeverities($buildId, $plugin = '')
|
||||
{
|
||||
$query = 'SELECT DISTINCT {{severity}} from {{build_error}} WHERE {{build_id}} = :build';
|
||||
$query = 'SELECT DISTINCT {{severity}} FROM {{build_error}} WHERE {{build_id}} = :build';
|
||||
if ($plugin) {
|
||||
$query .= ' AND {{plugin}} = :plugin';
|
||||
}
|
||||
|
|
@ -225,4 +225,28 @@ class BuildErrorStore extends Store
|
|||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a build error is new.
|
||||
*
|
||||
* @param string $hash
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getIsNewError($hash)
|
||||
{
|
||||
$query = 'SELECT COUNT(*) AS {{total}} FROM {{build_error}} WHERE {{hash}} = :hash';
|
||||
|
||||
$stmt = Database::getConnection('read')->prepareCommon($query);
|
||||
|
||||
$stmt->bindValue(':hash', $hash);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
$res = $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||
|
||||
return (0 === $res['total']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ namespace PHPCensor\Store;
|
|||
|
||||
use b8\Config;
|
||||
use b8\Database;
|
||||
use PHPCensor\Model\BuildError;
|
||||
use b8\Store\Factory;
|
||||
|
||||
/**
|
||||
* Class BuildErrorWriter
|
||||
|
|
@ -69,6 +71,11 @@ class BuildErrorWriter
|
|||
if (is_null($createdDate)) {
|
||||
$createdDate = new \DateTime();
|
||||
}
|
||||
|
||||
/** @var BuildErrorStore $errorStore */
|
||||
$errorStore = Factory::getStore('BuildError');
|
||||
$hash = BuildError::generateHash($plugin, $file, $lineStart, $lineEnd, $severity, $message);
|
||||
|
||||
$this->errors[] = [
|
||||
'plugin' => (string)$plugin,
|
||||
'message' => (string)$message,
|
||||
|
|
@ -77,6 +84,8 @@ class BuildErrorWriter
|
|||
'line_start' => !is_null($lineStart) ? (int)$lineStart : null,
|
||||
'line_end' => !is_null($lineEnd) ? (int)$lineEnd : null,
|
||||
'create_date' => $createdDate->format('Y-m-d H:i:s'),
|
||||
'hash' => $hash,
|
||||
'is_new' => (integer)$errorStore->getIsNewError($hash),
|
||||
];
|
||||
|
||||
if (count($this->errors) >= $this->bufferSize) {
|
||||
|
|
@ -104,7 +113,9 @@ class BuildErrorWriter
|
|||
:line_end' . $i . ',
|
||||
:severity' . $i . ',
|
||||
:message' . $i . ',
|
||||
:create_date' . $i . '
|
||||
:create_date' . $i . ',
|
||||
:hash' . $i . ',
|
||||
:is_new' . $i . '
|
||||
)';
|
||||
$insertValuesData['build_id' . $i] = $this->buildId;
|
||||
$insertValuesData['plugin' . $i] = $error['plugin'];
|
||||
|
|
@ -114,6 +125,8 @@ class BuildErrorWriter
|
|||
$insertValuesData['severity' . $i] = $error['severity'];
|
||||
$insertValuesData['message' . $i] = $error['message'];
|
||||
$insertValuesData['create_date' . $i] = $error['create_date'];
|
||||
$insertValuesData['hash' . $i] = $error['hash'];
|
||||
$insertValuesData['is_new' . $i] = $error['is_new'];
|
||||
}
|
||||
$query = '
|
||||
INSERT INTO {{build_error}} (
|
||||
|
|
@ -124,12 +137,15 @@ class BuildErrorWriter
|
|||
{{line_end}},
|
||||
{{severity}},
|
||||
{{message}},
|
||||
{{create_date}}
|
||||
{{create_date}},
|
||||
{{hash}},
|
||||
{{is_new}}
|
||||
)
|
||||
VALUES ' . join(', ', $insertValuesPlaceholders) . '
|
||||
';
|
||||
$stmt = Database::getConnection('write')->prepareCommon($query);
|
||||
$stmt->execute($insertValuesData);
|
||||
|
||||
$this->errors = [];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue