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

Commit

Permalink
Add a mechanism to get the scalars of only key metrics.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpatrick committed Oct 22, 2015
1 parent 0c81d73 commit e31e99b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
3 changes: 2 additions & 1 deletion modules/tracker/models/base/SubmissionModelBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ abstract public function getSubmissionsByProducer($producerDao);
/**
* Get the scalars associated with a submission.
* @param Tracker_SubmissionDao $submissionDao submission DAO
* @param bool $key whether to only retrieve scalars of key trends
* @return array submission DAOs
*/
abstract public function getScalars($submissionDao);
abstract public function getScalars($submissionDao, $key = false);
}
17 changes: 13 additions & 4 deletions modules/tracker/models/pdo/SubmissionModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,22 @@ public function createSubmission($producerDao, $uuid, $name = '')
* Return the scalars for a given submission.
*
* @param Tracker_SubmissionDao $submissionDao submission DAO
* @param bool $key whether to only retrieve scalars of key trends
* @return array scalar DAOs
*/
public function getScalars($submissionDao)
public function getScalars($submissionDao, $key=false)
{
$sql = $this->database->select()->setIntegrityCheck(false)
->from('tracker_scalar')
->where('submission_id = ?', $submissionDao->getKey());
if ($key) {
$sql = $this->database->select()->setIntegrityCheck(false)->from('tracker_scalar')->join(
'tracker_trend',
'tracker_scalar.trend_id = tracker_trend.trend_id',
array()
)->where('submission_id = ?', $submissionDao->getKey()
)->where('key_metric = ?', 1);
} else {
$sql = $this->database->select()->setIntegrityCheck(false)->from('tracker_scalar')
->where('submission_id = ?', $submissionDao->getKey());
}

$scalarDaos = array();
$rows = $this->database->fetchAll($sql);
Expand Down

0 comments on commit e31e99b

Please sign in to comment.