Documentation
¶
Index ¶
- Variables
- func DefaultDBPath() string
- func ValidTableNames() []string
- type DB
- func (db *DB) BatchInsertRecords(table string, columns []string, records [][]interface{}) (*InsertStats, error)
- func (db *DB) Close() error
- func (db *DB) Conn() *sql.DB
- func (db *DB) CountRows(table string) (int64, error)
- func (db *DB) GetDBInfo(dbPath string) (*DBInfo, error)
- func (db *DB) QueryActiveEnergyDailyTotal(params QueryParams) ([]map[string]interface{}, error)
- func (db *DB) QueryBasalEnergyDailyTotal(params QueryParams) ([]map[string]interface{}, error)
- func (db *DB) QueryRows(params QueryParams) ([]map[string]interface{}, error)
- func (db *DB) QueryStepsDailyTotal(params QueryParams) ([]map[string]interface{}, error)
- type DBInfo
- type InsertStats
- type QueryParams
- type TableInfo
Constants ¶
This section is empty.
Variables ¶
var TableNameMap = map[string]string{
"heart-rate": "heart_rate",
"heart_rate": "heart_rate",
"steps": "steps",
"spo2": "spo2",
"vo2max": "vo2_max",
"vo2_max": "vo2_max",
"sleep": "sleep",
"workouts": "workouts",
"resting-heart-rate": "resting_heart_rate",
"resting_heart_rate": "resting_heart_rate",
"hrv": "hrv",
"heart-rate-recovery": "heart_rate_recovery",
"heart_rate_recovery": "heart_rate_recovery",
"respiratory-rate": "respiratory_rate",
"respiratory_rate": "respiratory_rate",
"blood-pressure": "blood_pressure",
"blood_pressure": "blood_pressure",
"active-energy": "active_energy",
"active_energy": "active_energy",
"basal-energy": "basal_energy",
"basal_energy": "basal_energy",
"exercise-time": "exercise_time",
"exercise_time": "exercise_time",
"stand-time": "stand_time",
"stand_time": "stand_time",
"flights-climbed": "flights_climbed",
"flights_climbed": "flights_climbed",
"distance-walking-running": "distance_walking_running",
"distance_walking_running": "distance_walking_running",
"distance-cycling": "distance_cycling",
"distance_cycling": "distance_cycling",
"body-mass": "body_mass",
"body_mass": "body_mass",
"bmi": "body_mass_index",
"body-mass-index": "body_mass_index",
"body_mass_index": "body_mass_index",
"height": "height",
"walking-speed": "walking_speed",
"walking_speed": "walking_speed",
"walking-step-length": "walking_step_length",
"walking_step_length": "walking_step_length",
"walking-asymmetry": "walking_asymmetry",
"walking_asymmetry": "walking_asymmetry",
"walking-double-support": "walking_double_support",
"walking_double_support": "walking_double_support",
"walking-steadiness": "walking_steadiness",
"walking_steadiness": "walking_steadiness",
"stair-ascent-speed": "stair_ascent_speed",
"stair_ascent_speed": "stair_ascent_speed",
"stair-descent-speed": "stair_descent_speed",
"stair_descent_speed": "stair_descent_speed",
"six-minute-walk": "six_minute_walk",
"six_minute_walk": "six_minute_walk",
"running-speed": "running_speed",
"running_speed": "running_speed",
"running-power": "running_power",
"running_power": "running_power",
"running-stride-length": "running_stride_length",
"running_stride_length": "running_stride_length",
"running-ground-contact-time": "running_ground_contact_time",
"running_ground_contact_time": "running_ground_contact_time",
"running-vertical-oscillation": "running_vertical_oscillation",
"running_vertical_oscillation": "running_vertical_oscillation",
"wrist-temperature": "wrist_temperature",
"wrist_temperature": "wrist_temperature",
"time-in-daylight": "time_in_daylight",
"time_in_daylight": "time_in_daylight",
"dietary-water": "dietary_water",
"dietary_water": "dietary_water",
"physical-effort": "physical_effort",
"physical_effort": "physical_effort",
"walking-heart-rate": "walking_heart_rate",
"walking_heart_rate": "walking_heart_rate",
"mindful-sessions": "mindful_sessions",
"mindful_sessions": "mindful_sessions",
"stand-hours": "stand_hours",
"stand_hours": "stand_hours",
}
TableNameMap maps CLI-friendly names to actual table names.
Functions ¶
func ValidTableNames ¶
func ValidTableNames() []string
ValidTableNames returns the list of valid CLI table names.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB wraps the sql.DB connection and provides health data operations.
func (*DB) BatchInsertRecords ¶
func (db *DB) BatchInsertRecords(table string, columns []string, records [][]interface{}) (*InsertStats, error)
BatchInsertRecords inserts health records in batches using INSERT OR IGNORE. records should be a slice of []interface{} where each element is a row's values.
func (*DB) QueryActiveEnergyDailyTotal ¶ added in v0.4.0
func (db *DB) QueryActiveEnergyDailyTotal(params QueryParams) ([]map[string]interface{}, error)
QueryActiveEnergyDailyTotal returns deduplicated daily active energy totals aggregated by calendar day.
func (*DB) QueryBasalEnergyDailyTotal ¶ added in v0.4.0
func (db *DB) QueryBasalEnergyDailyTotal(params QueryParams) ([]map[string]interface{}, error)
QueryBasalEnergyDailyTotal returns deduplicated daily basal energy totals aggregated by calendar day.
func (*DB) QueryRows ¶
func (db *DB) QueryRows(params QueryParams) ([]map[string]interface{}, error)
QueryRows executes a query against the specified table and returns rows as maps.
func (*DB) QueryStepsDailyTotal ¶ added in v0.2.0
func (db *DB) QueryStepsDailyTotal(params QueryParams) ([]map[string]interface{}, error)
QueryStepsDailyTotal returns deduplicated step totals aggregated by calendar day.
type DBInfo ¶ added in v0.5.0
type DBInfo struct {
Path string
FileSizeMB float64
Tables []TableInfo // only non-empty tables, sorted by row count desc
TotalRows int64
}
DBInfo holds overall database statistics.
type InsertStats ¶
InsertStats tracks how many rows were inserted vs skipped (duplicates).