api.monitoring_view
Description
Monitoring static web view
Table Definition
CREATE VIEW monitoring_view AS (
SELECT "time",
((((now() AT TIME ZONE 'UTC'::text))::timestamp with time zone - "time") > 'PT1H10M'::interval) AS offline,
(metrics -> 'environment.water.temperature'::text) AS watertemperature,
(metrics -> 'environment.inside.temperature'::text) AS insidetemperature,
(metrics -> 'environment.outside.temperature'::text) AS outsidetemperature,
(metrics -> 'environment.wind.speedTrue'::text) AS windspeedoverground,
(metrics -> 'environment.wind.directionTrue'::text) AS winddirectiontrue,
(metrics -> 'environment.inside.relativeHumidity'::text) AS insidehumidity,
(metrics -> 'environment.outside.relativeHumidity'::text) AS outsidehumidity,
(metrics -> 'environment.outside.pressure'::text) AS outsidepressure,
(metrics -> 'environment.inside.pressure'::text) AS insidepressure,
(metrics -> 'electrical.batteries.House.capacity.stateOfCharge'::text) AS batterycharge,
(metrics -> 'electrical.batteries.House.voltage'::text) AS batteryvoltage,
(metrics -> 'environment.depth.belowTransducer'::text) AS depth,
jsonb_build_object('type', 'Feature', 'geometry', (st_asgeojson(st_makepoint(longitude, latitude)))::jsonb, 'properties', jsonb_build_object('name', current_setting('vessel.name'::text, false), 'latitude', latitude, 'longitude', longitude, 'time', "time", 'speedoverground', speedoverground, 'windspeedapparent', windspeedapparent, 'truewindspeed', COALESCE((metrics -> 'environment.wind.speedTrue'::text), NULL::jsonb), 'truewinddirection', COALESCE((metrics -> 'environment.wind.directionTrue'::text), NULL::jsonb), 'status', COALESCE(status, NULL::text))) AS geojson,
current_setting('vessel.name'::text, false) AS name,
status,
CASE
WHEN ((status <> 'moored'::text) AND (status <> 'anchored'::text)) THEN ( SELECT logbook_active_geojson_fn() AS logbook_active_geojson_fn)
WHEN ((status = 'moored'::text) OR (status = 'anchored'::text)) THEN ( SELECT stay_active_geojson_fn(m."time") AS stay_active_geojson_fn)
ELSE NULL::jsonb
END AS live
FROM api.metrics m
ORDER BY "time" DESC
LIMIT 1
)
Columns
| Name | Type | Default | Nullable |
|---|---|---|---|
| batterycharge | jsonb | true | |
| batteryvoltage | jsonb | true | |
| depth | jsonb | true | |
| geojson | jsonb | true | |
| insidehumidity | jsonb | true | |
| insidepressure | jsonb | true | |
| insidetemperature | jsonb | true | |
| live | jsonb | true | |
| name | text | true | |
| offline | boolean | true | |
| outsidehumidity | jsonb | true | |
| outsidepressure | jsonb | true | |
| outsidetemperature | jsonb | true | |
| status | text | true | |
| time | timestamp with time zone | true | |
| watertemperature | jsonb | true | |
| winddirectiontrue | jsonb | true | |
| windspeedoverground | jsonb | true |
Referenced Tables
| Name | Columns | Comment | Type |
|---|---|---|---|
| api.metrics | 11 | Stores metrics from vessel | BASE TABLE |
Relations
erDiagram
"api.monitoring_view" {
jsonb batterycharge ""
jsonb batteryvoltage ""
jsonb depth ""
jsonb geojson ""
jsonb insidehumidity ""
jsonb insidepressure ""
jsonb insidetemperature ""
jsonb live ""
text name ""
boolean offline ""
jsonb outsidehumidity ""
jsonb outsidepressure ""
jsonb outsidetemperature ""
text status ""
timestamp_with_time_zone time ""
jsonb watertemperature ""
jsonb winddirectiontrue ""
jsonb windspeedoverground ""
}
Generated by tbls