historydb

package
v0.14.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2026 License: GPL-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package historydb persists station position history in a standalone SQLite database. The schema is bootstrapped on every Open so a fresh file (e.g. on a tmpfs after reboot) is ready immediately.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	Path string // resolved absolute path of the database file
	// contains filtered or unexported fields
}

DB wraps a gorm.DB handle to the history database.

func Open

func Open(path string) (*DB, error)

Open opens (or creates) the history database at path, applies pragmas, and ensures the schema exists. Safe to call on an empty file. The returned DB.Path contains the resolved absolute path.

func (*DB) Close

func (d *DB) Close() error

Close releases the database handle.

func (*DB) LoadRecent

func (d *DB) LoadRecent(maxAge time.Duration, trailLimit int) (map[string]*stationcache.Station, error)

LoadRecent returns stations heard within maxAge, each with up to trailLimit positions (newest first). The returned map is keyed by composite station key ("stn:..." or "obj:...").

func (*DB) Prune

func (d *DB) Prune(maxAge time.Duration) error

Prune deletes positions older than maxAge and removes any stations that no longer have any positions.

func (*DB) QueryHeatmap added in v0.14.11

func (d *DB) QueryHeatmap(window time.Duration, bbox stationcache.BBox) (*stationcache.HeatmapResult, error)

QueryHeatmap aggregates directly-received packets over the given window into counted coordinate buckets within bbox. Events whose attributed transmitter has no known position are tallied in Unlocatable rather than dropped.

func (*DB) RecordRxEvent added in v0.14.11

func (d *DB) RecordRxEvent(ev stationcache.RxEvent) error

RecordRxEvent appends one rx_events row for a directly-received RF frame. Attribution is computed once per frame at the ingest edge by stationcache.BuildRxEvent, so this method only persists the result. It is deliberately NOT called from WriteEntries: WriteEntries also runs for the iGate RF->IS re-gate hook and the startup roster reload, neither of which is a fresh reception, so counting there would inflate the heatmap.

func (*DB) WriteEntries

func (d *DB) WriteEntries(entries []stationcache.CacheEntry) error

WriteEntries persists cache entries to the history database. Stations are upserted; positions are appended only when the station has moved beyond posEpsilon from its last stored position.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL