add support for barometric pressure
This commit is contained in:
@@ -122,3 +122,27 @@ func (d *DB) UpsertOpenMeteoHourly(ctx context.Context, p InsertOpenMeteoHourlyP
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
type InsertBarometerParams struct {
|
||||
TS time.Time
|
||||
Site string
|
||||
Source string
|
||||
PressureHPA float64
|
||||
Payload map[string]any
|
||||
}
|
||||
|
||||
func (d *DB) InsertBarometer(ctx context.Context, p InsertBarometerParams) error {
|
||||
b, _ := json.Marshal(p.Payload)
|
||||
|
||||
payloadJSON := json.RawMessage(b)
|
||||
|
||||
_, err := d.Pool.Exec(ctx, `
|
||||
INSERT INTO observations_baro (
|
||||
ts, site, source, pressure_hpa, payload_json
|
||||
) VALUES (
|
||||
$1,$2,$3,$4,$5
|
||||
)
|
||||
`, p.TS, p.Site, p.Source, p.PressureHPA, payloadJSON)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user