diff options
author | Juha Sippola <juhasippola@outlook.com> | 2015-09-21 16:40:16 +0300 |
---|---|---|
committer | Tony Sarajärvi <tony.sarajarvi@theqtcompany.com> | 2015-09-23 09:39:50 +0000 |
commit | 18a1f4f3e92986a0b29577f5c34a4507e690bce3 (patch) | |
tree | 8e7ce89a40f82b60b58ac93b76f748a1d3338014 /non-puppet/qtmetrics2/src/Database.php | |
parent | 5943fba9d274c49e00a6f956536841a99f247e2d (diff) |
Qt Metrics 2 (v0.30): Top test function failures
New page to list top failed testfunctions since a
specific date.
The date scope can be configured in the ini file.
The query duration is about 30 seconds with the
scope of last seven days.
Change-Id: I7b718f8df63efd31a62edff02a15f32e64279efc
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@theqtcompany.com>
Diffstat (limited to 'non-puppet/qtmetrics2/src/Database.php')
-rw-r--r-- | non-puppet/qtmetrics2/src/Database.php | 60 |
1 files changed, 59 insertions, 1 deletions
diff --git a/non-puppet/qtmetrics2/src/Database.php b/non-puppet/qtmetrics2/src/Database.php index 675779f..5b76d7e 100644 --- a/non-puppet/qtmetrics2/src/Database.php +++ b/non-puppet/qtmetrics2/src/Database.php @@ -34,7 +34,7 @@ /** * Database class - * @since 17-09-2015 + * @since 20-09-2015 * @author Juha Sippola */ @@ -757,6 +757,64 @@ class Database { } /** + * Get counts of all passed, failed and skipped runs by testfunction in specified builds since specified date (list length limited) + * Only the testfunctions that have failed since the specified date are listed + * @param string $runProject + * @param string $runState + * @param string $date + * @param int $limit + * @return array (string name, string testset, string project, int passed, int failed, int skipped) + */ + public function getTestfunctionsResultCounts($runProject, $runState, $date, $limit) + { + $result = array(); + $query = $this->db->prepare(" + SELECT + testfunction.name AS testfunction, + testset.name AS testset, + project.name AS project, + COUNT(CASE WHEN testfunction_run.result IN ('pass', 'xfail', 'bpass', 'bxfail', 'tr_pass') THEN testfunction_run.result END) AS passed, + COUNT(CASE WHEN testfunction_run.result IN ('fail', 'xpass', 'bfail', 'bxpass', 'tr_fail') THEN testfunction_run.result END) AS failed, + COUNT(CASE WHEN testfunction_run.result LIKE '%skip' THEN testfunction_run.result END) AS skipped + FROM testfunction_run + INNER JOIN testfunction ON testfunction_run.testfunction_id = testfunction.id + INNER JOIN testset_run ON testfunction_run.testset_run_id = testset_run.id + INNER JOIN testset ON testset_run.testset_id = testset.id + INNER JOIN project ON testset.project_id = project.id + INNER JOIN conf_run ON testset_run.conf_run_id = conf_run.id + INNER JOIN project_run ON conf_run.project_run_id = project_run.id + INNER JOIN branch ON project_run.branch_id = branch.id + INNER JOIN state ON project_run.state_id = state.id + WHERE + project_run.project_id = (SELECT id FROM project WHERE name = ?) AND + project_run.state_id = (SELECT id FROM state WHERE name = ?) AND + project_run.timestamp >= ? AND + branch.archived = 0 + GROUP BY testfunction.name, testset.name + ORDER BY failed DESC, testfunction.name ASC + LIMIT ?; + "); + $query->bindParam(1, $runProject); + $query->bindParam(2, $runState); + $query->bindParam(3, $date); + $query->bindParam(4, $limit, PDO::PARAM_INT); // int data type must be separately set + $query->execute(); + while($row = $query->fetch(PDO::FETCH_ASSOC)) { + if ($row['failed'] > 0) { // return only those where failures identified + $result[] = array( + 'name' => $row['testfunction'], + 'testset' => $row['testset'], + 'project' => $row['project'], + 'passed' => $row['passed'], + 'failed' => $row['failed'], + 'skipped' => $row['skipped'] + ); + } + } + return $result; + } + + /** * Get project run data by branch * @param string $runProject * @param string $runState |