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

Commit

Permalink
Finishing the addition of key metrics.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpatrick committed Sep 28, 2015
1 parent fa571f4 commit be16def
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion modules/tracker/configs/module.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ description = "Track scalar results over time"
category = "Visualization"
dependencies = api,scheduler
uuid = "3048a9fa-89ab-4e61-a55e-a49379fa6dc"
version = "1.2.0"
version = "1.2.1"
5 changes: 4 additions & 1 deletion modules/tracker/models/base/TrendModelBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,10 @@ abstract public function getScalars($trendDao, $startDate = null, $endDate = nul
* config/test/truth dataset combinations.
*
* @param Tracker_ProducerDao $producerDao producer DAO
* @param bool $onlyKey whether to return only key trends
* @return array
*/
abstract public function getTrendsGroupByDatasets($producerDao);
abstract public function getTrendsGroupByDatasets($producerDao, $onlyKey = false);

/**
* Save the given trend. Ensure that null values are explicitly set in the database.
Expand Down Expand Up @@ -168,6 +169,8 @@ public function createIfNeeded($producerId, $metricName, $configItemId, $testDat
$trendDao->setTruthDatasetId($truthDatasetId);
}

$trendDao->setIsKeyMetric(false);

$this->save($trendDao);
}

Expand Down
20 changes: 11 additions & 9 deletions modules/tracker/models/pdo/TrendModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,10 @@ public function getScalars($trendDao, $startDate = null, $endDate = null, $userI
* config/test/truth dataset combinations.
*
* @param Tracker_ProducerDao $producerDao producer DAO
* @param bool $onlyKey whether to return only key trends
* @return array array of associative arrays with keys "configItem", "testDataset", "truthDataset", and "trends"
*/
public function getTrendsGroupByDatasets($producerDao)
public function getTrendsGroupByDatasets($producerDao, $onlyKey = false)
{
$sql = $this->database->select()->setIntegrityCheck(false)->from(
$this->_name,
Expand All @@ -139,17 +140,18 @@ public function getTrendsGroupByDatasets($producerDao)
'testDataset' => $testDatasetItemDao,
'truthDataset' => $truthDatasetItemDao,
);
$result['trends'] = $this->getAllByParams(
array(
'producer_id' => $producerDao->getKey(),
'config_item_id' => $row['config_item_id'],
'test_dataset_id' => $row['test_dataset_id'],
'truth_dataset_id' => $row['truth_dataset_id'],
)
$queryParams = array(
'producer_id' => $producerDao->getKey(),
'config_item_id' => $row['config_item_id'],
'test_dataset_id' => $row['test_dataset_id'],
'truth_dataset_id' => $row['truth_dataset_id'],
);
if ($onlyKey) {
$queryParams['is_key_metric'] = true;
}
$result['trends'] = $this->getAllByParams($queryParams);
$results[] = $result;
}

return $results;
}

Expand Down

0 comments on commit be16def

Please sign in to comment.