api.stats_logs_view
Description
Statistics Logs web view
Table Definition
CREATE VIEW stats_logs_view AS (
WITH meta AS (
SELECT m_1.name
FROM api.metadata m_1
), last_metric AS (
SELECT m_1."time"
FROM api.metrics m_1
ORDER BY m_1."time" DESC
LIMIT 1
), first_metric AS (
SELECT m_1."time"
FROM api.metrics m_1
ORDER BY m_1."time"
LIMIT 1
), logbook AS (
SELECT count(*) AS number_of_log_entries,
max(l_1.max_speed) AS max_speed,
max(l_1.max_wind_speed) AS max_wind_speed,
sum(l_1.distance) AS total_distance,
sum(l_1.duration) AS total_time_underway,
concat(max(l_1.distance), ' NM, ', max(l_1.duration), ' hours') AS longest_nonstop_sail
FROM api.logbook l_1
)
SELECT m.name,
fm."time" AS first,
lm."time" AS last,
l.number_of_log_entries,
l.max_speed,
l.max_wind_speed,
l.total_distance,
l.total_time_underway,
l.longest_nonstop_sail
FROM first_metric fm,
last_metric lm,
logbook l,
meta m
)
Columns
| Name | Type | Default | Nullable |
|---|---|---|---|
| first | timestamp with time zone | true | |
| last | timestamp with time zone | true | |
| longest_nonstop_sail | text | true | |
| max_speed | double precision | true | |
| max_wind_speed | double precision | true | |
| name | text | true | |
| number_of_log_entries | bigint | true | |
| total_distance | numeric | true | |
| total_time_underway | interval | true |
Referenced Tables
| Name | Columns | Comment | Type |
|---|---|---|---|
| api.metadata | 18 | Stores metadata received from vessel, aka signalk plugin | BASE TABLE |
| api.metrics | 11 | Stores metrics from vessel | BASE TABLE |
| api.logbook | 42 | Stores generated logbook | BASE TABLE |
| public.first_metric | 11 | VIEW |
Relations
erDiagram
"api.stats_logs_view" {
timestamp_with_time_zone first ""
timestamp_with_time_zone last ""
text longest_nonstop_sail ""
double_precision max_speed ""
double_precision max_wind_speed ""
text name ""
bigint number_of_log_entries ""
numeric total_distance ""
interval total_time_underway ""
}
Generated by tbls