Documentation
¶
Overview ¶
Package cache maintains a local SQLite database of health/activity samples for trend analysis. Agents can query it directly with SQL via `garmin cache query`; the schema is intentionally narrow (one JSON payload column per sample) so new metrics need no migrations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrReadOnly = fmt.Errorf("only SELECT/WITH queries are allowed")
ErrReadOnly is returned when a query is not a read-only statement.
Functions ¶
func Query ¶
Query executes a single read-only SQL statement and returns columns and rows. Values keep their SQLite types (int64/float64/string/[]byte/nil).
func UpsertActivity ¶
func UpsertActivity(db *sql.DB, a ActivityRow) error
UpsertActivity stores (or replaces) one cached activity.
Types ¶
type ActivityRow ¶
type ActivityRow struct {
Profile string
ActivityID int64
StartTimeLocal string
Type string
Name string
DistanceMeters float64
DurationSeconds float64
Calories int
AvgHR int
Weather string
Payload any
FetchedAt time.Time
}
ActivityRow is one activity cached for SQL analysis. Weather is the raw JSON from the activity weather endpoint (empty when unavailable, e.g. indoor activities).