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

Commit 2992838

Browse files
committed
Adding new model and databse for submission_ids.
This includes upgrade scripts as well as the preliminary base, pdo, and dao classes.
1 parent 78aa67a commit 2992838

File tree

8 files changed

+463
-0
lines changed

8 files changed

+463
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
-- Midas Server. Copyright Kitware SAS. Licensed under the Apache License 2.0.
2+
3+
-- MySQL database for the tracker module, version 1.2.0
4+
5+
CREATE TABLE IF NOT EXISTS `tracker_producer` (
6+
`producer_id` bigint(20) NOT NULL AUTO_INCREMENT,
7+
`community_id` bigint(20) NOT NULL,
8+
`repository` varchar(255) NOT NULL,
9+
`executable_name` varchar(255) NOT NULL,
10+
`display_name` varchar(255) NOT NULL,
11+
`description` text NOT NULL,
12+
`revision_url` text NOT NULL,
13+
PRIMARY KEY (`producer_id`),
14+
KEY (`community_id`)
15+
) DEFAULT CHARSET=utf8;
16+
17+
CREATE TABLE IF NOT EXISTS `tracker_scalar` (
18+
`scalar_id` bigint(20) NOT NULL AUTO_INCREMENT,
19+
`trend_id` bigint(20) NOT NULL,
20+
`value` double,
21+
`producer_revision` varchar(255),
22+
`submit_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
23+
`user_id` bigint(20) NOT NULL DEFAULT '-1',
24+
`submission_id` bigint(20) NOT NULL DEFAULT '-1',
25+
`official` tinyint(4) NOT NULL DEFAULT '1',
26+
`build_results_url` text NOT NULL,
27+
`branch` varchar(255) NOT NULL DEFAULT '',
28+
`params` text,
29+
`extra_urls` text,
30+
PRIMARY KEY (`scalar_id`),
31+
KEY (`trend_id`),
32+
KEY (`submit_time`),
33+
KEY (`user_id`),
34+
KEY (`submission_id`),
35+
KEY (`branch`)
36+
) DEFAULT CHARSET=utf8;
37+
38+
CREATE TABLE IF NOT EXISTS `tracker_submission` (
39+
`submission_id` bigint(20) NOT NULL AUTO_INCREMENT,
40+
`name` varchar(255) NOT NULL DEFAULT '',
41+
`uuid` varchar(255) NOT NULL DEFAULT '',
42+
`submit_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
43+
PRIMARY KEY (`submission_id`),
44+
KEY (`uuid`)
45+
) DEFAULT CHARSET=utf8;
46+
47+
CREATE TABLE IF NOT EXISTS `tracker_scalar2item` (
48+
`scalar_id` bigint(20) NOT NULL,
49+
`item_id` bigint(20) NOT NULL,
50+
`label` varchar(255) NOT NULL,
51+
KEY (`scalar_id`)
52+
) DEFAULT CHARSET=utf8;
53+
54+
CREATE TABLE IF NOT EXISTS `tracker_threshold_notification` (
55+
`threshold_id` bigint(20) NOT NULL AUTO_INCREMENT,
56+
`trend_id` bigint(20) NOT NULL,
57+
`value` double,
58+
`comparison` varchar(2),
59+
`action` varchar(80) NOT NULL,
60+
`recipient_id` bigint(20) NOT NULL,
61+
PRIMARY KEY (`threshold_id`),
62+
KEY (`trend_id`)
63+
) DEFAULT CHARSET=utf8;
64+
65+
CREATE TABLE IF NOT EXISTS `tracker_trend` (
66+
`trend_id` bigint(20) NOT NULL AUTO_INCREMENT,
67+
`producer_id` bigint(20) NOT NULL,
68+
`metric_name` varchar(255) NOT NULL,
69+
`display_name` varchar(255) NOT NULL,
70+
`unit` varchar(255) NOT NULL,
71+
`config_item_id` bigint(20),
72+
`test_dataset_id` bigint(20),
73+
`truth_dataset_id` bigint(20),
74+
PRIMARY KEY (`trend_id`),
75+
KEY (`producer_id`)
76+
) DEFAULT CHARSET=utf8;
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
-- Midas Server. Copyright Kitware SAS. Licensed under the Apache License 2.0.
2+
3+
-- PostgreSQL database for the tracker module, version 1.2.0
4+
5+
SET client_encoding = 'UTF8';
6+
SET default_with_oids = FALSE;
7+
8+
CREATE TABLE IF NOT EXISTS "tracker_producer" (
9+
"producer_id" serial PRIMARY KEY,
10+
"community_id" bigint NOT NULL,
11+
"repository" character varying(255) NOT NULL,
12+
"executable_name" character varying(255) NOT NULL,
13+
"display_name" character varying(255) NOT NULL,
14+
"description" text NOT NULL,
15+
"revision_url" text NOT NULL
16+
);
17+
18+
CREATE INDEX "tracker_producer_community_id" ON "tracker_producer" ("community_id");
19+
20+
CREATE TABLE IF NOT EXISTS "tracker_scalar" (
21+
"scalar_id" serial PRIMARY KEY,
22+
"trend_id" bigint NOT NULL,
23+
"value" double precision,
24+
"producer_revision" character varying(255),
25+
"submit_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
26+
"user_id" bigint NOT NULL DEFAULT -1::bigint,
27+
"official" smallint NOT NULL DEFAULT 1::smallint,
28+
"build_results_url" text NOT NULL,
29+
"branch" character varying(255) NOT NULL DEFAULT ''::character varying,
30+
"params" text,
31+
"extra_urls" text
32+
);
33+
34+
CREATE INDEX "tracker_scalar_trend_id" ON "tracker_scalar" ("trend_id");
35+
CREATE INDEX "tracker_scalar_submit_time" ON "tracker_scalar" ("submit_time");
36+
CREATE INDEX "tracker_scalar_idx_branch" ON "tracker_scalar" ("branch");
37+
CREATE INDEX "tracker_scalar_idx_user_id" ON "tracker_scalar" ("user_id");
38+
39+
CREATE TABLE IF NOT EXISTS "tracker_submission" (
40+
"submission_id" serial PRIMARY KEY,
41+
"name" character varying(255) NOT NULL DEFAULT ''::character varying,
42+
"uuid" character varying(255) NOT NULL DEFAULT ''::character varying,
43+
"submit_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
44+
);
45+
CREATE INDEX "tracker_submission_uuid" ON "tracker_submission" ("uuid");
46+
CREATE INDEX "tracker_submission_submit_time" ON "tracker_submission" ("submit_time");
47+
48+
CREATE TABLE IF NOT EXISTS "tracker_scalar2item" (
49+
"id" serial PRIMARY KEY,
50+
"scalar_id" bigint NOT NULL,
51+
"item_id" bigint NOT NULL,
52+
"label" character varying(255) NOT NULL
53+
);
54+
55+
CREATE INDEX "tracker_scalar2item_scalar_id" ON "tracker_scalar2item" ("scalar_id");
56+
57+
CREATE TABLE IF NOT EXISTS "tracker_threshold_notification" (
58+
"threshold_id" serial PRIMARY KEY,
59+
"trend_id" bigint NOT NULL,
60+
"value" double precision,
61+
"comparison" character varying(2),
62+
"action" character varying(80) NOT NULL,
63+
"recipient_id" bigint NOT NULL
64+
);
65+
66+
CREATE INDEX "tracker_threshold_notification_trend_id" ON "tracker_threshold_notification" ("trend_id");
67+
68+
CREATE TABLE IF NOT EXISTS "tracker_trend" (
69+
"trend_id" serial PRIMARY KEY,
70+
"producer_id" bigint NOT NULL,
71+
"metric_name" character varying(255) NOT NULL,
72+
"display_name" character varying(255) NOT NULL,
73+
"unit" character varying(255) NOT NULL,
74+
"config_item_id" bigint,
75+
"test_dataset_id" bigint,
76+
"truth_dataset_id" bigint
77+
);
78+
79+
CREATE INDEX "tracker_trend_producer_id" ON "tracker_trend" ("producer_id");
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
-- Midas Server. Copyright Kitware SAS. Licensed under the Apache License 2.0.
2+
3+
-- SQLite database for the tracker module, version 1.2.0
4+
5+
CREATE TABLE IF NOT EXISTS "tracker_producer" (
6+
"producer_id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
7+
"community_id" INTEGER NOT NULL,
8+
"repository" TEXT NOT NULL,
9+
"executable_name" TEXT NOT NULL,
10+
"display_name" TEXT NOT NULL,
11+
"description" TEXT NOT NULL,
12+
"revision_url" TEXT NOT NULL
13+
);
14+
15+
CREATE INDEX IF NOT EXISTS "tracker_producer_community_id_idx" ON "tracker_producer" ("community_id");
16+
17+
CREATE TABLE IF NOT EXISTS "tracker_scalar" (
18+
"scalar_id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
19+
"trend_id" INTEGER NOT NULL,
20+
"value" REAL,
21+
"producer_revision" TEXT,
22+
"submit_time" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
23+
"user_id" INTEGER NOT NULL DEFAULT -1,
24+
"official" INTEGER NOT NULL DEFAULT 1,
25+
"build_results_url" TEXT NOT NULL,
26+
"branch" TEXT NOT NULL DEFAULT '',
27+
"params" TEXT,
28+
"extra_urls" TEXT
29+
);
30+
31+
CREATE INDEX IF NOT EXISTS "tracker_scalar_trend_id_idx" ON "tracker_scalar" ("trend_id");
32+
CREATE INDEX IF NOT EXISTS "tracker_scalar_submit_time_idx" ON "tracker_scalar" ("submit_time");
33+
CREATE INDEX IF NOT EXISTS "tracker_scalar_branch_idx" ON "tracker_scalar" ("branch");
34+
CREATE INDEX IF NOT EXISTS "tracker_scalar_user_id_idx" ON "tracker_scalar" ("user_id");
35+
36+
37+
CREATE TABLE IF NOT EXISTS "tracker_submission" (
38+
"submission_id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
39+
"name" TEXT NOT NULL DEFAULT '',
40+
"uuid" TEXT NOT NULL DEFAULT '',
41+
"submit_time" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
42+
);
43+
CREATE INDEX "tracker_submission_uuid_idx" ON "tracker_submission" ("uuid");
44+
CREATE INDEX "tracker_submission_submit_time_idx" ON "tracker_submission" ("submit_time");
45+
46+
47+
CREATE TABLE IF NOT EXISTS "tracker_scalar2item" (
48+
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
49+
"scalar_id" INTEGER NOT NULL,
50+
"item_id" INTEGER NOT NULL,
51+
"label" TEXT NOT NULL
52+
);
53+
54+
CREATE INDEX IF NOT EXISTS "tracker_scalar2item_scalar_id_idx" ON "tracker_scalar2item" ("scalar_id");
55+
56+
CREATE TABLE IF NOT EXISTS "tracker_threshold_notification" (
57+
"threshold_id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
58+
"trend_id" INTEGER NOT NULL,
59+
"value" REAL,
60+
"comparison" TEXT,
61+
"action" TEXT NOT NULL,
62+
"recipient_id" INTEGER NOT NULL
63+
);
64+
65+
CREATE INDEX IF NOT EXISTS "tracker_threshold_notification_trend_id_idx" ON "tracker_threshold_notification" ("trend_id");
66+
67+
CREATE TABLE IF NOT EXISTS "tracker_trend" (
68+
"trend_id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
69+
"producer_id" INTEGER NOT NULL,
70+
"metric_name" TEXT NOT NULL,
71+
"display_name" TEXT NOT NULL,
72+
"unit" TEXT NOT NULL,
73+
"config_item_id" INTEGER,
74+
"test_dataset_id" INTEGER,
75+
"truth_dataset_id" INTEGER
76+
);
77+
78+
CREATE INDEX IF NOT EXISTS "tracker_trend_producer_id_idx" ON "tracker_trend" ("producer_id");
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
/*=========================================================================
3+
Midas Server
4+
Copyright Kitware SAS, 26 rue Louis Guérin, 69100 Villeurbanne, France.
5+
All rights reserved.
6+
For more information visit http://www.kitware.com/.
7+
8+
Licensed under the Apache License, Version 2.0 (the "License");
9+
you may not use this file except in compliance with the License.
10+
You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0.txt
13+
14+
Unless required by applicable law or agreed to in writing, software
15+
distributed under the License is distributed on an "AS IS" BASIS,
16+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
See the License for the specific language governing permissions and
18+
limitations under the License.
19+
=========================================================================*/
20+
21+
/**
22+
* Upgrade the tracker module to version 1.2.0.
23+
*
24+
* @package Modules\Tracker\Database
25+
*/
26+
class Tracker_Upgrade_1_2_0 extends MIDASUpgrade
27+
{
28+
29+
/** Upgrade a MySQL database. */
30+
public function mysql()
31+
{
32+
$this->db->query("ALTER TABLE `tracker_scalar` ADD COLUMN `submission_id` bigint(20) NOT NULL DEFAULT '-1';");
33+
$this->db->query(<<<EOD
34+
CREATE TABLE IF NOT EXISTS `tracker_submission` (
35+
`submission_id` bigint(20) NOT NULL AUTO_INCREMENT,
36+
`name` varchar(255) NOT NULL DEFAULT '',
37+
`uuid` varchar(255) NOT NULL DEFAULT '',
38+
`submit_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
39+
PRIMARY KEY (`submission_id`),
40+
KEY (`uuid`)
41+
) DEFAULT CHARSET=utf8;
42+
EOD
43+
);
44+
}
45+
46+
/** Upgrade a PostgreSQL database. */
47+
public function pgsql()
48+
{
49+
$this->db->query("ALTER TABLE tracker_scalar ADD COLUMN submission_id bigint NOT NULL DEFAULT -1::bigint;");
50+
$this->db->query(<<<EOD
51+
CREATE TABLE IF NOT EXISTS "tracker_submission" (
52+
"submission_id" serial PRIMARY KEY,
53+
"name" character varying(255) NOT NULL DEFAULT ''::character varying,
54+
"uuid" character varying(255) NOT NULL DEFAULT ''::character varying,
55+
"submit_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
56+
);
57+
CREATE INDEX "tracker_submission_uuid" ON "tracker_submission" ("uuid");
58+
CREATE INDEX "tracker_submission_submit_time" ON "tracker_submission" ("submit_time");
59+
EOD
60+
);
61+
}
62+
63+
}

modules/tracker/models/base/ScalarModelBase.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ public function __construct()
4747
'parent_column' => 'trend_id',
4848
'child_column' => 'trend_id',
4949
),
50+
'submission' => array(
51+
'type' => MIDAS_MANY_TO_ONE,
52+
'model' => 'Submission',
53+
'module' => $this->moduleName,
54+
'parent_column' => 'submission_id',
55+
'child_column' => 'submission_id',
56+
),
5057
'user' => array(
5158
'type' => MIDAS_MANY_TO_ONE,
5259
'model' => 'User',
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
/*=========================================================================
3+
Midas Server
4+
Copyright Kitware SAS, 26 rue Louis Guérin, 69100 Villeurbanne, France.
5+
All rights reserved.
6+
For more information visit http://www.kitware.com/.
7+
8+
Licensed under the Apache License, Version 2.0 (the "License");
9+
you may not use this file except in compliance with the License.
10+
You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0.txt
13+
14+
Unless required by applicable law or agreed to in writing, software
15+
distributed under the License is distributed on an "AS IS" BASIS,
16+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
See the License for the specific language governing permissions and
18+
limitations under the License.
19+
=========================================================================*/
20+
21+
/**
22+
* Submission base model class for the tracker module.
23+
*
24+
* @package Modules\Tracker\Model
25+
*/
26+
abstract class Tracker_SubmissionModelBase extends Tracker_AppModel
27+
{
28+
/** Constructor. */
29+
public function __construct()
30+
{
31+
parent::__construct();
32+
33+
$this->_name = 'tracker_submission';
34+
$this->_key = 'submission_id';
35+
$this->_mainData = array(
36+
'submission_id' => array('type' => MIDAS_DATA),
37+
'name' => array('type' => MIDAS_DATA),
38+
'uuid' => array('type' => MIDAS_DATA),
39+
'submit_time' => array('type' => MIDAS_DATA),
40+
);
41+
42+
$this->initialize();
43+
}
44+
45+
public abstract function createSubmission($uuid, $userId, $name = '');
46+
public abstract function getScalars($submissionDao, $userId);
47+
}

0 commit comments

Comments
 (0)