summaryrefslogtreecommitdiffstats
path: root/non-puppet/qtmetrics2/src/Database.php
diff options
context:
space:
mode:
authorJuha Sippola <juhasippola@outlook.com>2015-07-01 15:54:56 +0300
committerTony Sarajärvi <tony.sarajarvi@theqtcompany.com>2015-09-16 07:32:01 +0000
commit17114a51b5015b5af18818c30344bbe5365d7a6c (patch)
tree529f1fbdfea6c4279510bebf5f350e3033f0f673 /non-puppet/qtmetrics2/src/Database.php
parent5a2c85839bfb064c7d8faa79ee2d00bb51458e87 (diff)
Qt Metrics 2 (v0.6): Testset page
Implemented the Results in Branches section into testset page. Changed testset URL to include its project to identify testsets with same name clearly. Change-Id: I4ffd7ec6bbbc473af0d742e808568ff7d3b273da 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.php105
1 files changed, 99 insertions, 6 deletions
diff --git a/non-puppet/qtmetrics2/src/Database.php b/non-puppet/qtmetrics2/src/Database.php
index 9f9999c..efc87c3 100644
--- a/non-puppet/qtmetrics2/src/Database.php
+++ b/non-puppet/qtmetrics2/src/Database.php
@@ -34,8 +34,8 @@
/**
* Database class
- * @version 0.3
- * @since 16-06-2015
+ * @version 0.4
+ * @since 22-06-2015
* @author Juha Sippola
*/
@@ -114,16 +114,20 @@ class Database {
{
$result = array();
$query = $this->db->prepare("
- SELECT DISTINCT name
+ SELECT testset.name AS testset, project.name AS project
FROM testset
- WHERE name LIKE ?
- ORDER BY name;
+ INNER JOIN project ON testset.project_id = project.id
+ WHERE testset.name LIKE ?
+ ORDER BY testset.name;
");
$query->execute(array(
'%' . $filter . '%'
));
while($row = $query->fetch(PDO::FETCH_ASSOC)) {
- $result[] = array('name' => $row['name']);
+ $result[] = array(
+ 'name' => $row['testset'],
+ 'project' => $row['project']
+ );
}
return $result;
}
@@ -499,6 +503,95 @@ class Database {
}
/**
+ * Get project build keys and timestamps by branch
+ * @param string $runProject
+ * @param string $runState
+ * @return array (string branch, string build_key, string timestamp)
+ */
+ public function getProjectBuildsByBranch($runProject, $runState)
+ {
+ $result = array();
+ $query = $this->db->prepare("
+ SELECT
+ branch.name AS branch,
+ project_run.build_key,
+ project_run.timestamp
+ FROM project_run
+ INNER JOIN branch ON project_run.branch_id = branch.id
+ WHERE
+ project_run.project_id = (SELECT id FROM project WHERE name = ?) AND
+ project_run.state_id = (SELECT id FROM state WHERE name = ?)
+ ORDER BY branch.name, project_run.timestamp DESC;
+ ");
+ $query->execute(array(
+ $runProject,
+ $runState
+ ));
+ while($row = $query->fetch(PDO::FETCH_ASSOC)) {
+ $result[] = array(
+ 'branch' => $row['branch'],
+ 'buildKey' => $row['build_key'],
+ 'timestamp' => $row['timestamp']
+ );
+ }
+ return $result;
+ }
+
+ /**
+ * Get run results for a testset in specified builds by branch and configuration
+ * @param string $testset
+ * @param $testsetProject
+ * @param string $runProject
+ * @param string $runState
+ * @return array (string branch, string conf, string build_key, string result)
+ */
+ public function getTestsetResultsByBranchConf($testset, $testsetProject, $runProject, $runState)
+ {
+ $result = array();
+ $query = $this->db->prepare("
+ SELECT
+ branch.name AS branch,
+ conf.name AS conf,
+ project_run.build_key,
+ testset_run.result,
+ project_run.timestamp,
+ testset_run.duration,
+ testset_run.run
+ FROM testset_run
+ 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 conf ON conf_run.conf_id = conf.id
+ INNER JOIN project_run ON conf_run.project_run_id = project_run.id
+ INNER JOIN branch ON project_run.branch_id = branch.id
+ WHERE
+ testset.name = ? AND
+ project.name = ? AND
+ project_run.project_id = (SELECT id FROM project WHERE name = ?) AND
+ project_run.state_id = (SELECT id FROM state WHERE name = ?)
+ ORDER BY branch.name, conf.name, project_run.timestamp DESC;
+ ");
+ $query->execute(array(
+ $testset,
+ $testsetProject,
+ $runProject,
+ $runState
+ ));
+ while($row = $query->fetch(PDO::FETCH_ASSOC)) {
+ $result[] = array(
+ 'branch' => $row['branch'],
+ 'conf' => $row['conf'],
+ 'buildKey' => $row['build_key'],
+ 'result' => $row['result'],
+ 'timestamp' => $row['timestamp'],
+ 'duration' => $row['duration'],
+ 'run' => $row['run']
+ );
+ }
+ return $result;
+ }
+
+ /**
* Get the timestamp when database last refreshed
* @return string (timestamp)
*/