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

Commit

Permalink
Fixing issues from review.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpatrick committed Oct 1, 2015
1 parent fede6a3 commit 4674a1b
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 13 deletions.
4 changes: 2 additions & 2 deletions modules/tracker/controllers/TrendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ public function notifysubmitAction()
* Change key metric status of a trend.
*
* Request parameters:
* trendId - The id of the producer to delete
* trendId - The id of the trend to set as a key metric
* state - The state of is_key_metric on the trend
*
* @throws Zend_Exception
Expand Down Expand Up @@ -563,7 +563,7 @@ public function setkeymetricAction()
throw new Zend_Exception('The producer does not exist or you do not have the necessary permission on its community', 403);
}

$trendDao->setIsKeyMetric($state === 'true');
$trendDao->setKeyMetric($state === '1' || $state === 'true');
$this->Tracker_Trend->save($trendDao);
}
}
2 changes: 1 addition & 1 deletion modules/tracker/database/mysql/1.2.1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ CREATE TABLE IF NOT EXISTS `tracker_trend` (
`config_item_id` bigint(20),
`test_dataset_id` bigint(20),
`truth_dataset_id` bigint(20),
`is_key_metric` boolean NOT NULL DEFAULT FALSE,
`key_metric` tinyint(4) NOT NULL DEFAULT '0',
PRIMARY KEY (`trend_id`),
KEY (`producer_id`)
) DEFAULT CHARSET=utf8;
2 changes: 1 addition & 1 deletion modules/tracker/database/pgsql/1.2.1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ CREATE TABLE IF NOT EXISTS "tracker_trend" (
"config_item_id" bigint,
"test_dataset_id" bigint,
"truth_dataset_id" bigint,
is_key_metric boolean NOT NULL DEFAULT FALSE
"key_metric" smallint NOT NULL DEFAULT 0::smallint
);

CREATE INDEX "tracker_trend_producer_id" ON "tracker_trend" ("producer_id");
2 changes: 1 addition & 1 deletion modules/tracker/database/sqlite/1.2.1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ CREATE TABLE IF NOT EXISTS "tracker_trend" (
"config_item_id" INTEGER,
"test_dataset_id" INTEGER,
"truth_dataset_id" INTEGER,
"is_key_metric" BOOLEAN NOT NULL DEFAULT FALSE
"key_metric" INTEGER NOT NULL DEFAULT 0
);

CREATE INDEX IF NOT EXISTS "tracker_trend_producer_id_idx" ON "tracker_trend" ("producer_id");
4 changes: 2 additions & 2 deletions modules/tracker/database/upgrade/1.2.1.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ class Tracker_Upgrade_1_2_1 extends MIDASUpgrade
public function mysql()
{
$this->db->query(
'ALTER TABLE `tracker_trend` ADD COLUMN `is_key_metric` boolean NOT NULL DEFAULT FALSE');
'ALTER TABLE `tracker_trend` ADD COLUMN `key_metric` tinyint(4) NOT NULL DEFAULT \'0\'');
}

/** Upgrade a PostgreSQL database. */
public function pgsql()
{
$this->db->query(
'ALTER TABLE tracker_trend ADD COLUMN is_key_metric boolean NOT NULL DEFAULT FALSE');
'ALTER TABLE tracker_trend ADD COLUMN key_metric smallint NOT NULL DEFAULT 0::smallint');
}
}
4 changes: 2 additions & 2 deletions modules/tracker/models/base/TrendModelBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct()
'config_item_id' => array('type' => MIDAS_DATA),
'test_dataset_id' => array('type' => MIDAS_DATA),
'truth_dataset_id' => array('type' => MIDAS_DATA),
'is_key_metric' => array('type' => MIDAS_DATA),
'key_metric' => array('type' => MIDAS_DATA),
'producer' => array(
'type' => MIDAS_MANY_TO_ONE,
'model' => 'Producer',
Expand Down Expand Up @@ -170,7 +170,7 @@ public function createIfNeeded($producerId, $metricName, $configItemId, $testDat
}

// Our pgsql code can't handle ACTUAL booleans :deep_sigh:
$trendDao->setIsKeyMetric('false');
$trendDao->setKeyMetric('0');

$this->save($trendDao);
}
Expand Down
9 changes: 9 additions & 0 deletions modules/tracker/models/dao/TrendDao.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
* @method void setTruthDatasetItem(ItemDao $truthDatasetItemDao)
* @method array getScalars()
* @method void setScalars(array $scalarDaos)
* @method void setKeyMetric(int $keyMetric)
*/
class Tracker_TrendDao extends Tracker_AppDao
{
Expand All @@ -55,4 +56,12 @@ class Tracker_TrendDao extends Tracker_AppDao

/** @var string */
public $_module = 'tracker';

/**
* Alias for getKeyMetric.
* @return mixed
*/
public function isKeyMetric() {
return $this->getKeyMetric();
}
}
2 changes: 1 addition & 1 deletion modules/tracker/models/pdo/TrendModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function getTrendsGroupByDatasets($producerDao, $onlyKey = false)
'truth_dataset_id' => $row['truth_dataset_id'],
);
if ($onlyKey !== false) {
$queryParams['is_key_metric'] = true;
$queryParams['key_metric'] = '1';
}
$result['trends'] = $this->getAllByParams($queryParams);
$results[] = $result;
Expand Down
6 changes: 3 additions & 3 deletions modules/tracker/views/producer/view.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ $this->headScript()->appendFile($this->moduleWebroot.'/public/js/producer/produc
/** @var Tracker_TrendDao $trendDao */
foreach ($trendGroup['trends'] as $trendDao) {
echo '<div class="trendContainer">';
echo '<input type="checkbox" class="selectTrend" iskey="'.$trendDao->getIsKeyMetric().'" element="'.$this->escape($trendDao->getKey()).'" />';
echo '<input type="checkbox" class="selectTrend" iskey="'.$trendDao->isKeyMetric().'" element="'.$this->escape($trendDao->getKey()).'" />';
echo '<a class="trendLink" href="'.$this->webroot.'/tracker/trend/view?trendId='.$this->escape($trendDao->getKey()).'">';
echo $this->escape($trendDao->getDisplayName());
echo '<span ';
if(!$trendDao->getIsKeyMetric()) {
if (!$trendDao->isKeyMetric()) {
echo 'style="display: none;" ';
}
echo 'class="keyMetric"><img src="'.$this->coreWebroot.'/public/images/icons/key.png" alt="Key metric"></span>';
Expand Down Expand Up @@ -113,7 +113,7 @@ $this->headScript()->appendFile($this->moduleWebroot.'/public/js/producer/produc
<li>
<a style="display: none;" class="toggleKeyMetric">
<img alt="" src="<?php echo $this->coreWebroot; ?>/public/images/icons/key.png"/>
<span class="keyMetricToggleVerb"></span> metric<span class="keyMetricTogglePlural"></span> as key
<span class="keyMetricToggleVerb">Set</span> as key metric<span class="keyMetricTogglePlural"></span>
</a>
</li>
<?php
Expand Down

0 comments on commit 4674a1b

Please sign in to comment.