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

Commit

Permalink
Default unit param to false
Browse files Browse the repository at this point in the history
  • Loading branch information
mgrauer committed Aug 17, 2015
1 parent 47585a9 commit e83d414
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion modules/tracker/controllers/components/ApiComponent.php
Expand Up @@ -247,7 +247,7 @@ public function scalarAdd($args)
if (isset($args['unit'])) {
$unit = $args['unit'];
} else {
$unit = null;
$unit = false;
}
/** @var Tracker_TrendModel $trendModel */
$trendModel = MidasLoader::loadModel('Trend', 'tracker');
Expand Down
14 changes: 7 additions & 7 deletions modules/tracker/models/base/TrendModelBase.php
Expand Up @@ -75,17 +75,17 @@ public function __construct()
}

/**
* Return the trend DAO that matches the given the producer id, metric name, and associated items.
* Return the trend DAO that matches the given the producer id, metric name, associated items, and unit.
*
* @param int $producerId producer id
* @param string $metricName metric name
* @param null|int $configItemId configuration item id
* @param null|int $testDatasetId test dataset item id
* @param null|int $truthDatasetId truth dataset item id
* @param null|string $unit scalar value unit
* @param false|string $unit (Optional) scalar value unit, defaults to false
* @return false|Tracker_TrendDao trend DAO or false if none exists
*/
abstract public function getMatch($producerId, $metricName, $configItemId, $testDatasetId, $truthDatasetId, $unit);
abstract public function getMatch($producerId, $metricName, $configItemId, $testDatasetId, $truthDatasetId, $unit = false);

/**
* Return the trend DAOs that match the given associative array of database columns and values.
Expand Down Expand Up @@ -129,18 +129,18 @@ public function save($trendDao)
}

/**
* Return the trend DAO that matches the given producer id, metric name, and associated items if it exists.
* Return the trend DAO that matches the given producer id, metric name, associated items, and unit, if the trend exists.
* Otherwise, create the trend DAO.
*
* @param int $producerId producer id
* @param string $metricName metric name
* @param null|int $configItemId configuration item id
* @param null|int $testDatasetId test dataset item id
* @param null|int $truthDatasetId truth dataset item id
* @param null|string $unit scalar value unit
* @param false|string $unit (Optional) scalar value unit, defaults to false
* @return Tracker_TrendDao trend DAO
*/
public function createIfNeeded($producerId, $metricName, $configItemId, $testDatasetId, $truthDatasetId, $unit)
public function createIfNeeded($producerId, $metricName, $configItemId, $testDatasetId, $truthDatasetId, $unit = false)
{
$trendDao = $this->getMatch($producerId, $metricName, $configItemId, $testDatasetId, $truthDatasetId, $unit);

Expand All @@ -150,7 +150,7 @@ public function createIfNeeded($producerId, $metricName, $configItemId, $testDat
$trendDao->setProducerId($producerId);
$trendDao->setMetricName($metricName);
$trendDao->setDisplayName($metricName);
if (is_null($unit)) {
if ($unit === false) {
$unit = '';
}
$trendDao->setUnit($unit);
Expand Down
8 changes: 4 additions & 4 deletions modules/tracker/models/pdo/TrendModel.php
Expand Up @@ -24,17 +24,17 @@
class Tracker_TrendModel extends Tracker_TrendModelBase
{
/**
* Return the trend DAO that matches the given the producer id, metric name, and associated items.
* Return the trend DAO that matches the given the producer id, metric name, associated items, and unit.
*
* @param int $producerId producer id
* @param string $metricName metric name
* @param null|int $configItemId configuration item id
* @param null|int $testDatasetId test dataset item id
* @param null|int $truthDatasetId truth dataset item id
* @param null|string $unit scalar value unit
* @param false|string $unit (Optional) scalar value unit, defaults to false
* @return false|Tracker_TrendDao trend DAO or false if none exists
*/
public function getMatch($producerId, $metricName, $configItemId, $testDatasetId, $truthDatasetId, $unit)
public function getMatch($producerId, $metricName, $configItemId, $testDatasetId, $truthDatasetId, $unit = false)
{
$sql = $this->database->select()->setIntegrityCheck(false)->where('producer_id = ?', $producerId)->where(
'metric_name = ?',
Expand All @@ -59,7 +59,7 @@ public function getMatch($producerId, $metricName, $configItemId, $testDatasetId
$sql->where('test_dataset_id = ?', $testDatasetId);
}

if (!is_null($unit) && ($unit !== '')) {
if ($unit !== false) {
$sql->where('unit = ?', $unit);
}

Expand Down
4 changes: 2 additions & 2 deletions modules/tracker/tests/controllers/ApiControllerTest.php
Expand Up @@ -75,10 +75,10 @@ public function testUploadScalarWithSubmission()
* @param string $uuid the uuid of the submission
* @param string $metric the metric name of the trend
* @param float $value the scalar value
* @param string $unit the unit of the trend, defaults to false
* @param false|string $unit (Optional) the unit of the trend, defaults to false
* @return mixed response object from the API
*/
protected function _submitScalar($token, $uuid, $metric, $value, $unit = false)
private function _submitScalar($token, $uuid, $metric, $value, $unit = false)
{
$this->resetAll();
$this->params['method'] = 'midas.tracker.scalar.add';
Expand Down

0 comments on commit e83d414

Please sign in to comment.