From c63bf633086460f188ae5ca680d3d05b1c8df6ed Mon Sep 17 00:00:00 2001 From: xbgmsharp Date: Tue, 15 Aug 2023 10:16:23 +0200 Subject: [PATCH] Update api.timelapse_fn, return only logbook with geojson data. --- initdb/02_1_2_signalk_api_functions.sql | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/initdb/02_1_2_signalk_api_functions.sql b/initdb/02_1_2_signalk_api_functions.sql index ed98ea9..5b5bd50 100644 --- a/initdb/02_1_2_signalk_api_functions.sql +++ b/initdb/02_1_2_signalk_api_functions.sql @@ -25,17 +25,20 @@ CREATE OR REPLACE FUNCTION api.timelapse_fn( SELECT jsonb_agg(track_geojson->'features') INTO _geojson FROM api.logbook WHERE id >= start_log - AND id <= end_log; + AND id <= end_log + AND track_geojson IS NOT NULL; --raise WARNING 'by log _geojson %' , _geojson; ELSIF start_date IS NOT NULL AND public.isdate(start_date::text) AND public.isdate(end_date::text) THEN SELECT jsonb_agg(track_geojson->'features') INTO _geojson FROM api.logbook WHERE _from_time >= start_log::TIMESTAMP WITHOUT TIME ZONE - AND _to_time <= end_date::TIMESTAMP WITHOUT TIME ZONE + interval '23 hours 59 minutes'; + AND _to_time <= end_date::TIMESTAMP WITHOUT TIME ZONE + interval '23 hours 59 minutes' + AND track_geojson IS NOT NULL; --raise WARNING 'by date _geojson %' , _geojson; ELSE SELECT jsonb_agg(track_geojson->'features') INTO _geojson - FROM api.logbook; + FROM api.logbook + WHERE track_geojson IS NOT NULL; --raise WARNING 'all result _geojson %' , _geojson; END IF; -- Return a GeoJSON filter on Point