mirror of
https://github.com/xbgmsharp/postgsail.git
synced 2025-09-17 11:17:46 +00:00
Update metrics_trigger_fn, Add validation check for speedOverGround.
Ignore if speedOverGround is over 40.
This commit is contained in:
@@ -357,7 +357,7 @@ CREATE FUNCTION metrics_trigger_fn() RETURNS trigger AS $metrics$
|
|||||||
END IF;
|
END IF;
|
||||||
IF previous_time > NEW.time THEN
|
IF previous_time > NEW.time THEN
|
||||||
-- Ignore entry if new time is later than previous time
|
-- Ignore entry if new time is later than previous time
|
||||||
RAISE WARNING 'Metrics Ignoring metric, vessel_id [%], new time is older [%] > [%]', NEW.vessel_id, previous_time, NEW.time;
|
RAISE WARNING 'Metrics Ignoring metric, vessel_id [%], new time is older than previous_time [%] > [%]', NEW.vessel_id, previous_time, NEW.time;
|
||||||
RETURN NULL;
|
RETURN NULL;
|
||||||
END IF;
|
END IF;
|
||||||
-- Check if latitude or longitude are null
|
-- Check if latitude or longitude are null
|
||||||
@@ -396,6 +396,12 @@ CREATE FUNCTION metrics_trigger_fn() RETURNS trigger AS $metrics$
|
|||||||
RAISE WARNING 'Metrics Ignoring metric, invalid status [%]', NEW.status;
|
RAISE WARNING 'Metrics Ignoring metric, invalid status [%]', NEW.status;
|
||||||
RETURN NULL;
|
RETURN NULL;
|
||||||
END IF;
|
END IF;
|
||||||
|
-- Check if speedOverGround is valid value
|
||||||
|
IF NEW.speedoverground >= 40 THEN
|
||||||
|
-- Ignore entry as speedOverGround is invalid
|
||||||
|
RAISE WARNING 'Metrics Ignoring metric, vessel_id [%], speedOverGround is invalid, over 40 < [%]', NEW.vessel_id, NEW.speedoverground;
|
||||||
|
RETURN NULL;
|
||||||
|
END IF;
|
||||||
|
|
||||||
-- Check the state and if any previous/current entry
|
-- Check the state and if any previous/current entry
|
||||||
-- If change of state and new status is sailing or motoring
|
-- If change of state and new status is sailing or motoring
|
||||||
|
Reference in New Issue
Block a user