2 -- File ID: 24babc2a-fafb-11dd-96fe-000475e441b9
4 -- siste_aar: List ut alle plasser siste år, DISTINCT ON name og hver uke
5 CREATE OR REPLACE VIEW siste_aar -- {{{
8 name, date_trunc('week', date)
11 WHERE date > now() + interval '1 year ago'
15 -- siste_halvaar: List ut alle plasser siste halvår, DISTINCT ON name og hver uke
16 CREATE OR REPLACE VIEW siste_halvaar -- {{{
19 name, date_trunc('week', date)
22 WHERE date > now() + interval '0.5 year ago'
26 -- siste_maaned: List ut alle plasser siste måned, DISTINCT ON name og hver time
27 CREATE OR REPLACE VIEW siste_maaned -- {{{
30 name, date_trunc('hour', date)
33 WHERE date > now() + interval '1 month ago'
37 -- siste_uke: List ut alle plasser siste uka, DISTINCT ON name og hver time
38 CREATE OR REPLACE VIEW siste_uke -- {{{
41 name, date_trunc('hour', date)
44 WHERE date > now()+interval '1 week ago'
48 -- siste_dogn: List ut alle plasser siste døgn, DISTINCT ON name og hvert minutt
49 CREATE OR REPLACE VIEW siste_dogn -- {{{
52 name, date_trunc('minute', date)
55 WHERE date > now()+interval '1 day ago'
61 CREATE OR REPLACE VIEW minutt -- {{{
64 date_trunc('minute', date)
69 CREATE OR REPLACE VIEW minuttname -- {{{
72 date_trunc('minute', date),
78 CREATE OR REPLACE VIEW hourname -- {{{
81 date_trunc('hour', date),
90 CREATE OR REPLACE VIEW closest AS -- {{{
92 SELECT DISTINCT ON (name) * FROM (
96 WHERE name IS NOT NULL
100 CREATE OR REPLACE VIEW gpx AS -- {{{
101 SELECT '<trkpt lat="' || coor[0] || '" lon="' || coor[1] || '"> ' ||
102 '<ele>' || ele || '</ele> ' ||
103 '<time>' || date || '</time> ' ||
106 date, coor, ele, name, dist, description
109 CREATE OR REPLACE VIEW gpst AS -- {{{
110 SELECT date, coor, ele, name, dist,
111 '<tp> <time>' || date AT TIME ZONE 'UTC' || 'Z' || '</time> <lat>' || coor[0] || '</lat> <lon>' || coor[1] || '</lon> </tp>'
115 -- ev: Lister ut events sammen med loggen.
116 CREATE OR REPLACE VIEW ev AS -- {{{
118 SELECT 'gps' AS flag, date, coor, name || ' (' || dist || ')' AS name, ele::numeric(8,1), NULL AS descr
121 SELECT 'event' AS flag, date, coor, NULL, NULL, descr AS descr
124 SELECT 'pic' AS flag, date, coor, filename, NULL, NULL
127 SELECT 'film' AS flag, date, coor, filename, NULL, descr
130 SELECT 'lyd' AS flag, date, coor, filename, NULL, descr
133 ORDER BY date; -- }}}
135 CREATE OR REPLACE VIEW media AS -- {{{
136 SELECT 'film' AS what,
139 clname(coor) AS name,
140 cldist(coor) AS dist,
144 SELECT 'pic', date, filename, clname(coor), cldist(coor), coor
147 SELECT 'lyd', date, filename, clname(coor), cldist(coor), coor
151 -- wp: Lister ut veipunktene, sortert nord → sør, vest → øst
152 CREATE OR REPLACE VIEW wp AS -- {{{
155 substr(name, 1, 20) AS name,
158 substr(cmt, 1, 20) AS cmt,
162 ORDER BY coor[0] DESC, coor[1]; -- }}}