diff --git a/src/PHPCensor/Languages/lang.en.php b/src/PHPCensor/Languages/lang.en.php index 7d889a21..182fc2ce 100644 --- a/src/PHPCensor/Languages/lang.en.php +++ b/src/PHPCensor/Languages/lang.en.php @@ -191,6 +191,7 @@ PHP Censor', 'all_errors' => 'All errors', 'only_new' => 'Only new errors', 'only_old' => 'Only old errors', + 'new_errors' => 'New errors', 'committed_by_x' => 'Committed by %s', 'commit_id_x' => 'Commit: %s', diff --git a/src/PHPCensor/Languages/lang.ru.php b/src/PHPCensor/Languages/lang.ru.php index 8bf3fbb0..0d6aeec3 100644 --- a/src/PHPCensor/Languages/lang.ru.php +++ b/src/PHPCensor/Languages/lang.ru.php @@ -184,6 +184,7 @@ PHP Censor', 'all_errors' => 'Все ошибки', 'only_new' => 'Только новые', 'only_old' => 'Только старые', + 'new_errors' => 'Новых ошибок', 'committed_by_x' => 'Отправил %s', 'commit_id_x' => 'Коммит: %s', diff --git a/src/PHPCensor/Model/Build.php b/src/PHPCensor/Model/Build.php index f2aadc90..5b9d6d5c 100644 --- a/src/PHPCensor/Model/Build.php +++ b/src/PHPCensor/Model/Build.php @@ -3,6 +3,7 @@ namespace PHPCensor\Model; use PHPCensor\Builder; +use PHPCensor\Store\BuildErrorStore; use Symfony\Component\Yaml\Parser as YamlParser; use PHPCensor\Model; use b8\Store\Factory; @@ -20,12 +21,12 @@ class Build extends Model const STAGE_FAILURE = 'failure'; const STAGE_FIXED = 'fixed'; const STAGE_BROKEN = 'broken'; - + const STATUS_PENDING = 0; const STATUS_RUNNING = 1; const STATUS_SUCCESS = 2; const STATUS_FAILED = 3; - + const SOURCE_UNKNOWN = 0; const SOURCE_MANUAL_WEB = 1; const SOURCE_MANUAL_CONSOLE = 2; @@ -47,6 +48,11 @@ class Build extends Model */ protected $modelName = 'Build'; + /** + * @var integer + */ + protected $newErrorsCount = null; + /** * @var array */ @@ -1042,4 +1048,19 @@ OUT; return 'source_unknown'; } } + + /** + * @return integer + */ + public function getNewErrorsCount() + { + if (null === $this->newErrorsCount) { + /** @var BuildErrorStore $store */ + $store = Factory::getStore('BuildError'); + + $this->newErrorsCount = $store->getNewErrorsCount($this->getId()); + } + + return $this->newErrorsCount; + } } diff --git a/src/PHPCensor/Store/BuildErrorStore.php b/src/PHPCensor/Store/BuildErrorStore.php index f6f14c93..b13ede4a 100644 --- a/src/PHPCensor/Store/BuildErrorStore.php +++ b/src/PHPCensor/Store/BuildErrorStore.php @@ -143,6 +143,7 @@ class BuildErrorStore extends Store * @param integer $buildId * @param string $plugin * @param integer $severity + * @param string $isNew * * @return integer */ @@ -295,4 +296,26 @@ class BuildErrorStore extends Store return true; } + + /** + * @param integer $buildId + * + * @return integer + */ + public function getNewErrorsCount($buildId) + { + $query = 'SELECT COUNT(*) AS {{total}} FROM {{build_error}} WHERE {{build_id}} = :build AND {{is_new}} = true'; + + $stmt = Database::getConnection('read')->prepareCommon($query); + + $stmt->bindValue(':build', $buildId); + + if ($stmt->execute()) { + $res = $stmt->fetch(\PDO::FETCH_ASSOC); + + return (integer)$res['total']; + } + + return 0; + } } diff --git a/src/PHPCensor/View/Project/ajax-builds.phtml b/src/PHPCensor/View/Project/ajax-builds.phtml index d683b131..a04a9787 100644 --- a/src/PHPCensor/View/Project/ajax-builds.phtml +++ b/src/PHPCensor/View/Project/ajax-builds.phtml @@ -1,4 +1,12 @@ - +