From c51059a4317158209c8300b15d145b35dde70d3d Mon Sep 17 00:00:00 2001 From: xbgmsharp Date: Sat, 7 Dec 2024 12:05:51 +0100 Subject: [PATCH] Update migration 202411 Update public.logbook_update_metrics_fn, aggregate metrics by time-series to reduce size --- initdb/99_migrations_202411.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/initdb/99_migrations_202411.sql b/initdb/99_migrations_202411.sql index cfcd9d7..517b268 100644 --- a/initdb/99_migrations_202411.sql +++ b/initdb/99_migrations_202411.sql @@ -268,7 +268,7 @@ BEGIN avg(m.courseovergroundtrue) as courseovergroundtrue, avg(m.speedoverground) as speedoverground, 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, last(m.status, m.time) as status, COALESCE(metersToKnots(avg((m.metrics->'environment.wind.speedTrue')::NUMERIC)), NULL) as truewindspeed, @@ -334,11 +334,11 @@ BEGIN SELECT * FROM metrics UNION ALL SELECT * FROM last_metric - ORDER BY time ASC + ORDER BY time_bucket ASC ) -- Create mobilitydb temporal sequences 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.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,