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

Commit

Permalink
Responding to review and fixing failing tests.
Browse files Browse the repository at this point in the history
This includes a couple of pgsql workarounds and sql scripts.
  • Loading branch information
cpatrick committed Sep 30, 2015
1 parent 2e6c85e commit 3bd3f65
Show file tree
Hide file tree
Showing 7 changed files with 246 additions and 4 deletions.
2 changes: 1 addition & 1 deletion core/controllers/components/UtilityComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ public function installModule($moduleName)
try {
$moduleModel->save($moduleDao);
} catch (Zend_Db_Statement_Exception $e) {
if ($e->getCode() === 23000) {
if ($e->getCode() === 23000 || $e->getCode() === 23505) {
$this->getLogger()->debug('Failed to install '.$moduleName.' due to integrity constraint violation.');
} else {
throw $e;
Expand Down
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"
78 changes: 78 additions & 0 deletions modules/tracker/database/mysql/1.2.1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
-- Midas Server. Copyright Kitware SAS. Licensed under the Apache License 2.0.

-- MySQL database for the tracker module, version 1.2.0

CREATE TABLE IF NOT EXISTS `tracker_producer` (
`producer_id` bigint(20) NOT NULL AUTO_INCREMENT,
`community_id` bigint(20) NOT NULL,
`repository` varchar(255) NOT NULL,
`executable_name` varchar(255) NOT NULL,
`display_name` varchar(255) NOT NULL,
`description` text NOT NULL,
`revision_url` text NOT NULL,
PRIMARY KEY (`producer_id`),
KEY (`community_id`)
) DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `tracker_scalar` (
`scalar_id` bigint(20) NOT NULL AUTO_INCREMENT,
`trend_id` bigint(20) NOT NULL,
`value` double,
`producer_revision` varchar(255),
`submit_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`user_id` bigint(20) NOT NULL DEFAULT '-1',
`submission_id` bigint(20) NOT NULL DEFAULT '-1',
`official` tinyint(4) NOT NULL DEFAULT '1',
`build_results_url` text NOT NULL,
`branch` varchar(255) NOT NULL DEFAULT '',
`params` text,
`extra_urls` text,
PRIMARY KEY (`scalar_id`),
KEY (`trend_id`),
KEY (`submit_time`),
KEY (`user_id`),
KEY (`submission_id`),
KEY (`branch`)
) DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `tracker_submission` (
`submission_id` bigint(20) NOT NULL AUTO_INCREMENT,
`producer_id` bigint(20) NOT NULL,
`name` varchar(255) NOT NULL DEFAULT '',
`uuid` varchar(255) NOT NULL DEFAULT '',
`submit_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`submission_id`),
UNIQUE KEY (`uuid`)
) DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `tracker_scalar2item` (
`scalar_id` bigint(20) NOT NULL,
`item_id` bigint(20) NOT NULL,
`label` varchar(255) NOT NULL,
KEY (`scalar_id`)
) DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `tracker_threshold_notification` (
`threshold_id` bigint(20) NOT NULL AUTO_INCREMENT,
`trend_id` bigint(20) NOT NULL,
`value` double,
`comparison` varchar(2),
`action` varchar(80) NOT NULL,
`recipient_id` bigint(20) NOT NULL,
PRIMARY KEY (`threshold_id`),
KEY (`trend_id`)
) DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `tracker_trend` (
`trend_id` bigint(20) NOT NULL AUTO_INCREMENT,
`producer_id` bigint(20) NOT NULL,
`metric_name` varchar(255) NOT NULL,
`display_name` varchar(255) NOT NULL,
`unit` varchar(255) NOT NULL,
`config_item_id` bigint(20),
`test_dataset_id` bigint(20),
`truth_dataset_id` bigint(20),
`is_key_metric` boolean NOT NULL DEFAULT FALSE,
PRIMARY KEY (`trend_id`),
KEY (`producer_id`)
) DEFAULT CHARSET=utf8;
82 changes: 82 additions & 0 deletions modules/tracker/database/pgsql/1.2.1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
-- Midas Server. Copyright Kitware SAS. Licensed under the Apache License 2.0.

-- PostgreSQL database for the tracker module, version 1.2.0

SET client_encoding = 'UTF8';
SET default_with_oids = FALSE;

CREATE TABLE IF NOT EXISTS "tracker_producer" (
"producer_id" serial PRIMARY KEY,
"community_id" bigint NOT NULL,
"repository" character varying(255) NOT NULL,
"executable_name" character varying(255) NOT NULL,
"display_name" character varying(255) NOT NULL,
"description" text NOT NULL,
"revision_url" text NOT NULL
);

CREATE INDEX "tracker_producer_community_id" ON "tracker_producer" ("community_id");

CREATE TABLE IF NOT EXISTS "tracker_scalar" (
"scalar_id" serial PRIMARY KEY,
"trend_id" bigint NOT NULL,
"value" double precision,
"producer_revision" character varying(255),
"submit_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"user_id" bigint NOT NULL DEFAULT -1::bigint,
"submission_id" bigint NOT NULL DEFAULT -1::bigint,
"official" smallint NOT NULL DEFAULT 1::smallint,
"build_results_url" text NOT NULL,
"branch" character varying(255) NOT NULL DEFAULT ''::character varying,
"params" text,
"extra_urls" text
);

CREATE INDEX "tracker_scalar_trend_id" ON "tracker_scalar" ("trend_id");
CREATE INDEX "tracker_scalar_submit_time" ON "tracker_scalar" ("submit_time");
CREATE INDEX "tracker_scalar_idx_branch" ON "tracker_scalar" ("branch");
CREATE INDEX "tracker_scalar_idx_user_id" ON "tracker_scalar" ("user_id");

CREATE TABLE IF NOT EXISTS "tracker_submission" (
"submission_id" serial PRIMARY KEY,
"producer_id" bigint,
"name" character varying(255) NOT NULL DEFAULT ''::character varying,
"uuid" character varying(255) NOT NULL DEFAULT ''::character varying,
"submit_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE UNIQUE INDEX "tracker_submission_uuid" ON "tracker_submission" ("uuid");
CREATE INDEX "tracker_submission_submit_time" ON "tracker_submission" ("submit_time");

CREATE TABLE IF NOT EXISTS "tracker_scalar2item" (
"id" serial PRIMARY KEY,
"scalar_id" bigint NOT NULL,
"item_id" bigint NOT NULL,
"label" character varying(255) NOT NULL
);

CREATE INDEX "tracker_scalar2item_scalar_id" ON "tracker_scalar2item" ("scalar_id");

CREATE TABLE IF NOT EXISTS "tracker_threshold_notification" (
"threshold_id" serial PRIMARY KEY,
"trend_id" bigint NOT NULL,
"value" double precision,
"comparison" character varying(2),
"action" character varying(80) NOT NULL,
"recipient_id" bigint NOT NULL
);

CREATE INDEX "tracker_threshold_notification_trend_id" ON "tracker_threshold_notification" ("trend_id");

CREATE TABLE IF NOT EXISTS "tracker_trend" (
"trend_id" serial PRIMARY KEY,
"producer_id" bigint NOT NULL,
"metric_name" character varying(255) NOT NULL,
"display_name" character varying(255) NOT NULL,
"unit" character varying(255) NOT NULL,
"config_item_id" bigint,
"test_dataset_id" bigint,
"truth_dataset_id" bigint,
is_key_metric boolean NOT NULL DEFAULT FALSE
);

CREATE INDEX "tracker_trend_producer_id" ON "tracker_trend" ("producer_id");
81 changes: 81 additions & 0 deletions modules/tracker/database/sqlite/1.2.1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
-- Midas Server. Copyright Kitware SAS. Licensed under the Apache License 2.0.

-- SQLite database for the tracker module, version 1.2.0

CREATE TABLE IF NOT EXISTS "tracker_producer" (
"producer_id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"community_id" INTEGER NOT NULL,
"repository" TEXT NOT NULL,
"executable_name" TEXT NOT NULL,
"display_name" TEXT NOT NULL,
"description" TEXT NOT NULL,
"revision_url" TEXT NOT NULL
);

CREATE INDEX IF NOT EXISTS "tracker_producer_community_id_idx" ON "tracker_producer" ("community_id");

CREATE TABLE IF NOT EXISTS "tracker_scalar" (
"scalar_id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"trend_id" INTEGER NOT NULL,
"value" REAL,
"producer_revision" TEXT,
"submit_time" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
"user_id" INTEGER NOT NULL DEFAULT -1,
"submission_id" INTEGER NOT NULL DEFAULT -1,
"official" INTEGER NOT NULL DEFAULT 1,
"build_results_url" TEXT NOT NULL,
"branch" TEXT NOT NULL DEFAULT '',
"params" TEXT,
"extra_urls" TEXT
);

CREATE INDEX IF NOT EXISTS "tracker_scalar_trend_id_idx" ON "tracker_scalar" ("trend_id");
CREATE INDEX IF NOT EXISTS "tracker_scalar_submit_time_idx" ON "tracker_scalar" ("submit_time");
CREATE INDEX IF NOT EXISTS "tracker_scalar_branch_idx" ON "tracker_scalar" ("branch");
CREATE INDEX IF NOT EXISTS "tracker_scalar_user_id_idx" ON "tracker_scalar" ("user_id");


CREATE TABLE IF NOT EXISTS "tracker_submission" (
"submission_id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"producer_id" INTEGER NOT NULL,
"name" TEXT NOT NULL DEFAULT '',
"uuid" TEXT NOT NULL DEFAULT '',
"submit_time" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE UNIQUE INDEX IF NOT EXISTS "tracker_submission_uuid_idx" ON "tracker_submission" ("uuid");
CREATE INDEX IF NOT EXISTS "tracker_submission_submit_time_idx" ON "tracker_submission" ("submit_time");


CREATE TABLE IF NOT EXISTS "tracker_scalar2item" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"scalar_id" INTEGER NOT NULL,
"item_id" INTEGER NOT NULL,
"label" TEXT NOT NULL
);

CREATE INDEX IF NOT EXISTS "tracker_scalar2item_scalar_id_idx" ON "tracker_scalar2item" ("scalar_id");

CREATE TABLE IF NOT EXISTS "tracker_threshold_notification" (
"threshold_id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"trend_id" INTEGER NOT NULL,
"value" REAL,
"comparison" TEXT,
"action" TEXT NOT NULL,
"recipient_id" INTEGER NOT NULL
);

CREATE INDEX IF NOT EXISTS "tracker_threshold_notification_trend_id_idx" ON "tracker_threshold_notification" ("trend_id");

CREATE TABLE IF NOT EXISTS "tracker_trend" (
"trend_id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"producer_id" INTEGER NOT NULL,
"metric_name" TEXT NOT NULL,
"display_name" TEXT NOT NULL,
"unit" TEXT NOT NULL,
"config_item_id" INTEGER,
"test_dataset_id" INTEGER,
"truth_dataset_id" INTEGER,
"is_key_metric" BOOLEAN NOT NULL DEFAULT FALSE
);

CREATE INDEX IF NOT EXISTS "tracker_trend_producer_id_idx" ON "tracker_trend" ("producer_id");
3 changes: 2 additions & 1 deletion modules/tracker/models/base/TrendModelBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ public function createIfNeeded($producerId, $metricName, $configItemId, $testDat
$trendDao->setTruthDatasetId($truthDatasetId);
}

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

$this->save($trendDao);
}
Expand Down
2 changes: 1 addition & 1 deletion modules/tracker/models/pdo/TrendModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function getTrendsGroupByDatasets($producerDao, $onlyKey = false)
'test_dataset_id' => $row['test_dataset_id'],
'truth_dataset_id' => $row['truth_dataset_id'],
);
if ($onlyKey) {
if ($onlyKey !== false) {
$queryParams['is_key_metric'] = true;
}
$result['trends'] = $this->getAllByParams($queryParams);
Expand Down

0 comments on commit 3bd3f65

Please sign in to comment.