Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RadioObservatory
LOFAR
Commits
b340fac5
Commit
b340fac5
authored
9 years ago
by
Ruud Overeem
Browse files
Options
Downloads
Patches
Plain Diff
Task #8531: Nieuw function for the TreeStatusEvent daemon.
parent
cec90f41
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitattributes
+1
-0
1 addition, 0 deletions
.gitattributes
SAS/OTDB/sql/create_tree_table.sql
+5
-1
5 additions, 1 deletion
SAS/OTDB/sql/create_tree_table.sql
SAS/OTDB/sql/getStateChanges_func.sql
+88
-0
88 additions, 0 deletions
SAS/OTDB/sql/getStateChanges_func.sql
with
94 additions
and
1 deletion
.gitattributes
+
1
−
0
View file @
b340fac5
...
@@ -4807,6 +4807,7 @@ SAS/OTDB/sql/getDefaultTemplates_func.sql -text
...
@@ -4807,6 +4807,7 @@ SAS/OTDB/sql/getDefaultTemplates_func.sql -text
SAS/OTDB/sql/getModifiedTrees_func.sql -text
SAS/OTDB/sql/getModifiedTrees_func.sql -text
SAS/OTDB/sql/getMomID2treeID_func.sql -text
SAS/OTDB/sql/getMomID2treeID_func.sql -text
SAS/OTDB/sql/getSchedulerInfo_func.sql -text
SAS/OTDB/sql/getSchedulerInfo_func.sql -text
SAS/OTDB/sql/getStateChanges_func.sql -text
SAS/OTDB/sql/getTreeGroup_func.sql -text
SAS/OTDB/sql/getTreeGroup_func.sql -text
SAS/OTDB/sql/getTreesInPeriod_func.sql -text
SAS/OTDB/sql/getTreesInPeriod_func.sql -text
SAS/OTDB/sql/getVTitem_func.sql -text
SAS/OTDB/sql/getVTitem_func.sql -text
...
...
This diff is collapsed.
Click to expand it.
SAS/OTDB/sql/create_tree_table.sql
+
5
−
1
View file @
b340fac5
...
@@ -37,6 +37,7 @@ DROP SEQUENCE IF EXISTS OTDBtreeID;
...
@@ -37,6 +37,7 @@ DROP SEQUENCE IF EXISTS OTDBtreeID;
DROP
SEQUENCE
IF
EXISTS
OTDBgroupID
;
DROP
SEQUENCE
IF
EXISTS
OTDBgroupID
;
DROP
TABLE
IF
EXISTS
StateHistory
CASCADE
;
DROP
TABLE
IF
EXISTS
StateHistory
CASCADE
;
DROP
INDEX
IF
EXISTS
otdbtree_treeid_indx
;
DROP
INDEX
IF
EXISTS
otdbtree_treeid_indx
;
DROP
INDEX
IF
EXISTS
statehist_creation_idx
;
CREATE
SEQUENCE
OTDBtreeID
START
1
;
CREATE
SEQUENCE
OTDBtreeID
START
1
;
-- Create a new start number based on current time. To prevent overlap in treeid's
-- Create a new start number based on current time. To prevent overlap in treeid's
...
@@ -98,6 +99,9 @@ CREATE TABLE StateHistory (
...
@@ -98,6 +99,9 @@ CREATE TABLE StateHistory (
momID
INT4
NOT
NULL
,
momID
INT4
NOT
NULL
,
state
INT2
NOT
NULL
,
state
INT2
NOT
NULL
,
userID
INT4
NOT
NULL
REFERENCES
operator
(
ID
),
userID
INT4
NOT
NULL
REFERENCES
operator
(
ID
),
timestamp
TIMESTAMP
(
0
)
DEFAULT
now
()
timestamp
TIMESTAMP
(
0
)
DEFAULT
now
(),
creation
TIMESTAMP
(
6
)
DEFAULT
now
()
)
WITHOUT
OIDS
;
)
WITHOUT
OIDS
;
CREATE
INDEX
statehist_creation_idx
ON
statehistory
(
creation
);
This diff is collapsed.
Click to expand it.
SAS/OTDB/sql/getStateChanges_func.sql
0 → 100644
+
88
−
0
View file @
b340fac5
--
-- getStateChanges.sql: function for getting state changes in a given period
--
-- Copyright (C) 2015
-- ASTRON (Netherlands Foundation for Research in Astronomy)
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, softwaresupport@astron.nl
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--
-- $Id: getStateList_func.sql 30919 2015-02-05 15:26:22Z amesfoort $
--
--
-- getStateChanges(begindate, enddate)
--
-- Get a list of statechanges.
--
-- Authorisation: none
--
-- Tables: otdbtree read
-- otdbuser read
--
-- Types: treeState
--
DROP
TYPE
IF
EXISTS
stateChange
CASCADE
;
CREATE
TYPE
stateChange
AS
(
-- $Id: create_types.sql 30919 2015-02-05 15:26:22Z amesfoort $
treeID
INT4
,
-- OTDBtree.treeID%TYPE,
momID
INT4
,
-- OTDBtree.momID%TYPE,
state
INT2
,
-- treestate.ID%TYPE,
username
VARCHAR
(
20
),
-- OTDBuser.username%TYPE,
modtime
timestamp
(
0
),
creation
timestamp
(
6
)
);
CREATE
OR
REPLACE
FUNCTION
getStateChanges
(
TIMESTAMP
(
6
),
TIMESTAMP
(
6
))
RETURNS
SETOF
stateChange
AS
'
-- $Id: getStateList_func.sql 30919 2015-02-05 15:26:22Z amesfoort $
DECLARE
vRecord RECORD;
vQuery TEXT;
vKeyField TEXT;
BEGIN
-- create query for treeID (when filled)
vQuery :=
\'
WHERE
\'
;
IF $1 IS NOT NULL THEN
IF $2 IS NULL THEN
vQuery := vQuery ||
\'
s.creation >
\'
|| chr(39) || $1 || chr(39);
ELSE
vQuery := vQuery ||
\'
s.creation >
\'
|| chr(39) || $1 || chr(39)
||
\'
AND s.creation <=
\'
|| chr(39) || $2 || chr(39);
END IF;
END IF;
-- do selection
FOR vRecord IN EXECUTE
\'
SELECT s.treeID,
s.momID,
s.state,
u.username,
s.timestamp,
s.creation
FROM StateHistory s
INNER JOIN OTDBuser u ON s.userid = u.userid
\'
|| vQuery ||
\'
ORDER BY s.creation ASC
\'
LOOP
RETURN NEXT vRecord;
END LOOP;
RETURN;
END
'
LANGUAGE
plpgsql
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment