Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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

NameTypeDefaultNullable
firsttimestamp with time zonetrue
lasttimestamp with time zonetrue
longest_nonstop_sailtexttrue
max_speeddouble precisiontrue
max_wind_speeddouble precisiontrue
nametexttrue
number_of_log_entriesbiginttrue
total_distancenumerictrue
total_time_underwayintervaltrue

Referenced Tables

NameColumnsCommentType
api.metadata18Stores metadata received from vessel, aka signalk pluginBASE TABLE
api.metrics11Stores metrics from vesselBASE TABLE
api.logbook42Stores generated logbookBASE TABLE
public.first_metric11VIEW

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