From 8fff17dee3460cc63a9ead678de70f1f0f67a748 Mon Sep 17 00:00:00 2001 From: xbgmsharp Date: Tue, 14 Nov 2023 23:51:23 +0100 Subject: [PATCH] Update process_stay_queue_fn, process stays only when gone --- initdb/02_3_2_signalk_public_functions.sql | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/initdb/02_3_2_signalk_public_functions.sql b/initdb/02_3_2_signalk_public_functions.sql index 4be49fa..b45f61d 100644 --- a/initdb/02_3_2_signalk_public_functions.sql +++ b/initdb/02_3_2_signalk_public_functions.sql @@ -555,9 +555,12 @@ CREATE OR REPLACE FUNCTION process_stay_queue_fn(IN _id integer) RETURNS void AS -- Get the stay record with all necessary fields exist SELECT * INTO stay_rec FROM api.stays - WHERE id = _id + WHERE active IS false + AND departed IS NOT NULL + AND arrived IS NOT NULL AND longitude IS NOT NULL - AND latitude IS NOT NULL; + AND latitude IS NOT NULL + AND id = _id; -- Ensure the query is successful IF stay_rec.vessel_id IS NULL THEN RAISE WARNING '-> process_stay_queue_fn invalid stay %', _id;