mirror of
https://github.com/xbgmsharp/postgsail.git
synced 2025-09-17 03:07:47 +00:00
Update migration 202411
Update public.logbook_update_metrics_fn, aggregate metrics by time-series to reduce size
This commit is contained in:
@@ -268,7 +268,7 @@ BEGIN
|
|||||||
avg(m.courseovergroundtrue) as courseovergroundtrue,
|
avg(m.courseovergroundtrue) as courseovergroundtrue,
|
||||||
avg(m.speedoverground) as speedoverground,
|
avg(m.speedoverground) as speedoverground,
|
||||||
avg(m.windspeedapparent) as windspeedapparent,
|
avg(m.windspeedapparent) as windspeedapparent,
|
||||||
--last(m.longitude, m.time) as longitude, last(m.latitude, m.time) as latitude,
|
last(m.longitude, m.time) as longitude, last(m.latitude, m.time) as latitude,
|
||||||
'' AS notes,
|
'' AS notes,
|
||||||
last(m.status, m.time) as status,
|
last(m.status, m.time) as status,
|
||||||
COALESCE(metersToKnots(avg((m.metrics->'environment.wind.speedTrue')::NUMERIC)), NULL) as truewindspeed,
|
COALESCE(metersToKnots(avg((m.metrics->'environment.wind.speedTrue')::NUMERIC)), NULL) as truewindspeed,
|
||||||
@@ -334,11 +334,11 @@ BEGIN
|
|||||||
SELECT * FROM metrics
|
SELECT * FROM metrics
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT * FROM last_metric
|
SELECT * FROM last_metric
|
||||||
ORDER BY time ASC
|
ORDER BY time_bucket ASC
|
||||||
)
|
)
|
||||||
-- Create mobilitydb temporal sequences
|
-- Create mobilitydb temporal sequences
|
||||||
SELECT
|
SELECT
|
||||||
tgeogpointseq(array_agg(tgeogpoint(ST_SetSRID(o.geo_point, 4326)::geography, o.time_bucket) ORDER BY o.time ASC)) AS trajectory,
|
tgeogpointseq(array_agg(tgeogpoint(ST_SetSRID(o.geo_point, 4326)::geography, o.time_bucket) ORDER BY o.time_bucket ASC)) AS trajectory,
|
||||||
tfloatseq(array_agg(tfloat(o.courseovergroundtrue, o.time_bucket) ORDER BY o.time_bucket ASC) FILTER (WHERE o.courseovergroundtrue IS NOT NULL)) AS courseovergroundtrue,
|
tfloatseq(array_agg(tfloat(o.courseovergroundtrue, o.time_bucket) ORDER BY o.time_bucket ASC) FILTER (WHERE o.courseovergroundtrue IS NOT NULL)) AS courseovergroundtrue,
|
||||||
tfloatseq(array_agg(tfloat(o.speedoverground, o.time_bucket) ORDER BY o.time_bucket ASC) FILTER (WHERE o.speedoverground IS NOT NULL)) AS speedoverground,
|
tfloatseq(array_agg(tfloat(o.speedoverground, o.time_bucket) ORDER BY o.time_bucket ASC) FILTER (WHERE o.speedoverground IS NOT NULL)) AS speedoverground,
|
||||||
tfloatseq(array_agg(tfloat(o.windspeedapparent, o.time_bucket) ORDER BY o.time_bucket ASC) FILTER (WHERE o.windspeedapparent IS NOT NULL)) AS windspeedapparent,
|
tfloatseq(array_agg(tfloat(o.windspeedapparent, o.time_bucket) ORDER BY o.time_bucket ASC) FILTER (WHERE o.windspeedapparent IS NOT NULL)) AS windspeedapparent,
|
||||||
|
Reference in New Issue
Block a user