3 CREATE OR REPLACE VIEW siste_aar
6 sted, date_trunc('week', date)
9 WHERE date > now() + interval '1 year ago'
13 CREATE OR REPLACE VIEW siste_halvaar
16 sted, date_trunc('week', date)
19 WHERE date > now() + interval '0.5 year ago'
23 CREATE OR REPLACE VIEW siste_maaned
26 sted, date_trunc('hour', date)
29 WHERE date > now() + interval '1 month ago'
33 CREATE OR REPLACE VIEW siste_uke
36 sted, date_trunc('hour', date)
39 WHERE date > now()+interval '1 week ago'
43 CREATE OR REPLACE VIEW siste_dogn
46 sted, date_trunc('minute', date)
49 WHERE date > now()+interval '1 day ago'
53 /*** De 50.000 punktene med høyest fjernesthjemmefrahet. ***/
55 CREATE OR REPLACE VIEW fjernest
57 ORDER BY avst DESC LIMIT 50000;
59 CREATE OR REPLACE VIEW fjernest_siste_aar
61 WHERE date > now()+interval '1 year ago'
62 ORDER BY avst DESC LIMIT 50000;
64 CREATE OR REPLACE VIEW fjernest_siste_halvaar
66 WHERE date > now()+interval '0.5 year ago'
67 ORDER BY avst DESC LIMIT 50000;
69 CREATE OR REPLACE VIEW fjernest_siste_maaned
71 WHERE date > now() + interval '1 month ago'
72 ORDER BY avst DESC LIMIT 50000;
74 CREATE OR REPLACE VIEW fjernest_siste_uke
76 WHERE date > now() + interval '1 week ago'
77 ORDER BY avst DESC LIMIT 50000;
79 CREATE OR REPLACE VIEW fjernest_siste_dogn
81 WHERE date > now() + interval '1 day ago'
82 ORDER BY avst DESC LIMIT 50000;
86 CREATE OR REPLACE VIEW minutt
89 date_trunc('minute', date)
97 CREATE OR REPLACE VIEW closest AS
99 SELECT DISTINCT ON (sted) * FROM (
103 WHERE sted IS NOT NULL
107 CREATE OR REPLACE VIEW gpx AS
108 SELECT '<trkpt lat="' || coor[0] || '" lon="' || coor[1] || '"> ' ||
109 '<ele>' || ele || '</ele> ' ||
110 '<time>' || date || '</time> ' ||
113 date, coor, ele, sted, dist, description
116 CREATE OR REPLACE VIEW gpst AS
117 SELECT date, coor, ele, sted, dist, avst,
118 '<tp> <time>' || date at time zone 'UTC' || 'Z' || '</time> <lat>' || coor[0] || '</lat> <lon>' || coor[1] || '</lon> </tp>'
122 -- Lister ut events sammen med loggen.
123 CREATE OR REPLACE VIEW ev AS
125 SELECT 'gps' AS flag, date, coor, sted || ' (' || dist || ')' AS sted, ele::numeric(8,1), NULL AS descr, avst
128 SELECT 'event' AS flag, date, coor, NULL, NULL, descr AS descr, NULL
131 SELECT 'pic' AS flag, date, coor, filename, NULL, NULL, NULL
136 CREATE OR REPLACE VIEW wp AS
139 substr(name, 1, 20) AS name,
141 substr(cmt, 1, 20) AS cmt,
145 ORDER BY coor[0] desc, coor[1];