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 ¶
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) 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 ¶
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.