historydb

package
v0.13.13 Latest Latest
Warning

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

Go to latest
Published: May 30, 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) 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