Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
raven
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
Rune Åvar Ødegård
raven
Commits
745cbbf1
Commit
745cbbf1
authored
2 years ago
by
Christoffer Stoll
Browse files
Options
Downloads
Patches
Plain Diff
Add totime trigger on timeserie
parent
dd5365cc
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
db_scripts/changelog.xml
+1
-0
1 addition, 0 deletions
db_scripts/changelog.xml
db_scripts/update_v12.sql
+41
-0
41 additions, 0 deletions
db_scripts/update_v12.sql
with
42 additions
and
0 deletions
db_scripts/changelog.xml
+
1
−
0
View file @
745cbbf1
...
...
@@ -12,4 +12,5 @@ http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<include
file=
"update_v9.sql"
relativeToChangelogFile=
"true"
/>
<include
file=
"update_v10.sql"
relativeToChangelogFile=
"true"
/>
<include
file=
"update_v11.sql"
relativeToChangelogFile=
"true"
/>
<include
file=
"update_v12.sql"
relativeToChangelogFile=
"true"
/>
</databaseChangeLog>
This diff is collapsed.
Click to expand it.
db_scripts/update_v12.sql
0 → 100644
+
41
−
0
View file @
745cbbf1
-- SET TIMESTEP TO 60
update
eea_times
set
timestep
=
60
where
id
=
'http://dd.eionet.europa.eu/vocabulary/uom/time/minute'
;
-- CREATE A FUNCTION TO UPDATE TOTIME FOR TIMESERIE
CREATE
FUNCTION
raven_timeserie_update_time
()
RETURNS
trigger
LANGUAGE
'plpgsql'
AS
$$
DECLARE
fromtime
timestamp
without
time
zone
;
totime
timestamp
without
time
zone
;
BEGIN
SELECT
oc
.
from_time
,
oc
.
to_time
INTO
fromtime
,
totime
FROM
observing_capabilities
oc
WHERE
sampling_point_id
=
NEW
.
sampling_point_id
;
-- UPDATE FROMTIME IN THE OBSERVING CAPABILITIES TABLE
IF
fromtime
IS
NULL
OR
NEW
.
from_time
<
fromtime
THEN
UPDATE
observing_capabilities
SET
from_time
=
NEW
.
from_time
WHERE
sampling_point_id
=
NEW
.
sampling_point_id
;
END
IF
;
-- UPDATE TOTIME IN THE OBSERVING CAPABILITIES TABLE
IF
totime
IS
NULL
OR
NEW
.
to_time
>
totime
THEN
UPDATE
observing_capabilities
SET
to_time
=
NEW
.
to_time
WHERE
sampling_point_id
=
NEW
.
sampling_point_id
;
END
IF
;
RETURN
NEW
;
END
;
$$
;
-- CREATE A TRIGGER TO RUN FUNCTION AFTER OBS INSERT
CREATE
TRIGGER
raven_timeserie_update_time_trigger
AFTER
INSERT
ON
public
.
observations
FOR
EACH
ROW
EXECUTE
PROCEDURE
public
.
raven_timeserie_update_time
();
\ No newline at end of file
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