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

Commit 4674a1b

Browse files
committed
Fixing issues from review.
1 parent fede6a3 commit 4674a1b

File tree

9 files changed

+22
-13
lines changed

9 files changed

+22
-13
lines changed

modules/tracker/controllers/TrendController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ public function notifysubmitAction()
529529
* Change key metric status of a trend.
530530
*
531531
* Request parameters:
532-
* trendId - The id of the producer to delete
532+
* trendId - The id of the trend to set as a key metric
533533
* state - The state of is_key_metric on the trend
534534
*
535535
* @throws Zend_Exception
@@ -563,7 +563,7 @@ public function setkeymetricAction()
563563
throw new Zend_Exception('The producer does not exist or you do not have the necessary permission on its community', 403);
564564
}
565565

566-
$trendDao->setIsKeyMetric($state === 'true');
566+
$trendDao->setKeyMetric($state === '1' || $state === 'true');
567567
$this->Tracker_Trend->save($trendDao);
568568
}
569569
}

modules/tracker/database/mysql/1.2.1.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ CREATE TABLE IF NOT EXISTS `tracker_trend` (
7272
`config_item_id` bigint(20),
7373
`test_dataset_id` bigint(20),
7474
`truth_dataset_id` bigint(20),
75-
`is_key_metric` boolean NOT NULL DEFAULT FALSE,
75+
`key_metric` tinyint(4) NOT NULL DEFAULT '0',
7676
PRIMARY KEY (`trend_id`),
7777
KEY (`producer_id`)
7878
) DEFAULT CHARSET=utf8;

modules/tracker/database/pgsql/1.2.1.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ CREATE TABLE IF NOT EXISTS "tracker_trend" (
7676
"config_item_id" bigint,
7777
"test_dataset_id" bigint,
7878
"truth_dataset_id" bigint,
79-
is_key_metric boolean NOT NULL DEFAULT FALSE
79+
"key_metric" smallint NOT NULL DEFAULT 0::smallint
8080
);
8181

8282
CREATE INDEX "tracker_trend_producer_id" ON "tracker_trend" ("producer_id");

modules/tracker/database/sqlite/1.2.1.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ CREATE TABLE IF NOT EXISTS "tracker_trend" (
7575
"config_item_id" INTEGER,
7676
"test_dataset_id" INTEGER,
7777
"truth_dataset_id" INTEGER,
78-
"is_key_metric" BOOLEAN NOT NULL DEFAULT FALSE
78+
"key_metric" INTEGER NOT NULL DEFAULT 0
7979
);
8080

8181
CREATE INDEX IF NOT EXISTS "tracker_trend_producer_id_idx" ON "tracker_trend" ("producer_id");

modules/tracker/database/upgrade/1.2.1.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ class Tracker_Upgrade_1_2_1 extends MIDASUpgrade
2525
public function mysql()
2626
{
2727
$this->db->query(
28-
'ALTER TABLE `tracker_trend` ADD COLUMN `is_key_metric` boolean NOT NULL DEFAULT FALSE');
28+
'ALTER TABLE `tracker_trend` ADD COLUMN `key_metric` tinyint(4) NOT NULL DEFAULT \'0\'');
2929
}
3030

3131
/** Upgrade a PostgreSQL database. */
3232
public function pgsql()
3333
{
3434
$this->db->query(
35-
'ALTER TABLE tracker_trend ADD COLUMN is_key_metric boolean NOT NULL DEFAULT FALSE');
35+
'ALTER TABLE tracker_trend ADD COLUMN key_metric smallint NOT NULL DEFAULT 0::smallint');
3636
}
3737
}

modules/tracker/models/base/TrendModelBase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __construct()
3737
'config_item_id' => array('type' => MIDAS_DATA),
3838
'test_dataset_id' => array('type' => MIDAS_DATA),
3939
'truth_dataset_id' => array('type' => MIDAS_DATA),
40-
'is_key_metric' => array('type' => MIDAS_DATA),
40+
'key_metric' => array('type' => MIDAS_DATA),
4141
'producer' => array(
4242
'type' => MIDAS_MANY_TO_ONE,
4343
'model' => 'Producer',
@@ -170,7 +170,7 @@ public function createIfNeeded($producerId, $metricName, $configItemId, $testDat
170170
}
171171

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

175175
$this->save($trendDao);
176176
}

modules/tracker/models/dao/TrendDao.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
* @method void setTruthDatasetItem(ItemDao $truthDatasetItemDao)
4848
* @method array getScalars()
4949
* @method void setScalars(array $scalarDaos)
50+
* @method void setKeyMetric(int $keyMetric)
5051
*/
5152
class Tracker_TrendDao extends Tracker_AppDao
5253
{
@@ -55,4 +56,12 @@ class Tracker_TrendDao extends Tracker_AppDao
5556

5657
/** @var string */
5758
public $_module = 'tracker';
59+
60+
/**
61+
* Alias for getKeyMetric.
62+
* @return mixed
63+
*/
64+
public function isKeyMetric() {
65+
return $this->getKeyMetric();
66+
}
5867
}

modules/tracker/models/pdo/TrendModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public function getTrendsGroupByDatasets($producerDao, $onlyKey = false)
147147
'truth_dataset_id' => $row['truth_dataset_id'],
148148
);
149149
if ($onlyKey !== false) {
150-
$queryParams['is_key_metric'] = true;
150+
$queryParams['key_metric'] = '1';
151151
}
152152
$result['trends'] = $this->getAllByParams($queryParams);
153153
$results[] = $result;

modules/tracker/views/producer/view.phtml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ $this->headScript()->appendFile($this->moduleWebroot.'/public/js/producer/produc
7676
/** @var Tracker_TrendDao $trendDao */
7777
foreach ($trendGroup['trends'] as $trendDao) {
7878
echo '<div class="trendContainer">';
79-
echo '<input type="checkbox" class="selectTrend" iskey="'.$trendDao->getIsKeyMetric().'" element="'.$this->escape($trendDao->getKey()).'" />';
79+
echo '<input type="checkbox" class="selectTrend" iskey="'.$trendDao->isKeyMetric().'" element="'.$this->escape($trendDao->getKey()).'" />';
8080
echo '<a class="trendLink" href="'.$this->webroot.'/tracker/trend/view?trendId='.$this->escape($trendDao->getKey()).'">';
8181
echo $this->escape($trendDao->getDisplayName());
8282
echo '<span ';
83-
if(!$trendDao->getIsKeyMetric()) {
83+
if (!$trendDao->isKeyMetric()) {
8484
echo 'style="display: none;" ';
8585
}
8686
echo 'class="keyMetric"><img src="'.$this->coreWebroot.'/public/images/icons/key.png" alt="Key metric"></span>';
@@ -113,7 +113,7 @@ $this->headScript()->appendFile($this->moduleWebroot.'/public/js/producer/produc
113113
<li>
114114
<a style="display: none;" class="toggleKeyMetric">
115115
<img alt="" src="<?php echo $this->coreWebroot; ?>/public/images/icons/key.png"/>
116-
<span class="keyMetricToggleVerb"></span> metric<span class="keyMetricTogglePlural"></span> as key
116+
<span class="keyMetricToggleVerb">Set</span> as key metric<span class="keyMetricTogglePlural"></span>
117117
</a>
118118
</li>
119119
<?php

0 commit comments

Comments
 (0)