Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit e31e99b

Browse files
committed
Add a mechanism to get the scalars of only key metrics.
1 parent 0c81d73 commit e31e99b

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

modules/tracker/models/base/SubmissionModelBase.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ abstract public function getSubmissionsByProducer($producerDao);
8686
/**
8787
* Get the scalars associated with a submission.
8888
* @param Tracker_SubmissionDao $submissionDao submission DAO
89+
* @param bool $key whether to only retrieve scalars of key trends
8990
* @return array submission DAOs
9091
*/
91-
abstract public function getScalars($submissionDao);
92+
abstract public function getScalars($submissionDao, $key = false);
9293
}

modules/tracker/models/pdo/SubmissionModel.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,22 @@ public function createSubmission($producerDao, $uuid, $name = '')
4747
* Return the scalars for a given submission.
4848
*
4949
* @param Tracker_SubmissionDao $submissionDao submission DAO
50+
* @param bool $key whether to only retrieve scalars of key trends
5051
* @return array scalar DAOs
5152
*/
52-
public function getScalars($submissionDao)
53+
public function getScalars($submissionDao, $key=false)
5354
{
54-
$sql = $this->database->select()->setIntegrityCheck(false)
55-
->from('tracker_scalar')
56-
->where('submission_id = ?', $submissionDao->getKey());
55+
if ($key) {
56+
$sql = $this->database->select()->setIntegrityCheck(false)->from('tracker_scalar')->join(
57+
'tracker_trend',
58+
'tracker_scalar.trend_id = tracker_trend.trend_id',
59+
array()
60+
)->where('submission_id = ?', $submissionDao->getKey()
61+
)->where('key_metric = ?', 1);
62+
} else {
63+
$sql = $this->database->select()->setIntegrityCheck(false)->from('tracker_scalar')
64+
->where('submission_id = ?', $submissionDao->getKey());
65+
}
5766

5867
$scalarDaos = array();
5968
$rows = $this->database->fetchAll($sql);

0 commit comments

Comments
 (0)