diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e827359 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +test.yaml diff --git a/internal/db/queries.go b/internal/db/queries.go index db46145..7a32cf5 100644 --- a/internal/db/queries.go +++ b/internal/db/queries.go @@ -4,8 +4,6 @@ import ( "context" "encoding/json" "time" - - "github.com/jackc/pgx/v5/pgtype" ) type InsertWS90Params struct { @@ -38,8 +36,7 @@ type InsertWS90Params struct { func (d *DB) InsertWS90(ctx context.Context, p InsertWS90Params) error { b, _ := json.Marshal(p.Payload) - var payloadJSON pgtype.JSONB - _ = payloadJSON.Set(b) + payloadJSON := json.RawMessage(b) _, err := d.Pool.Exec(ctx, ` INSERT INTO observations_ws90 ( @@ -90,8 +87,7 @@ type InsertOpenMeteoHourlyParams struct { func (d *DB) UpsertOpenMeteoHourly(ctx context.Context, p InsertOpenMeteoHourlyParams) error { b, _ := json.Marshal(p.SourcePayload) - var sourceJSON pgtype.JSONB - _ = sourceJSON.Set(b) + sourceJSON := json.RawMessage(b) _, err := d.Pool.Exec(ctx, ` INSERT INTO forecast_openmeteo_hourly ( diff --git a/internal/mqttingest/latest.go b/internal/mqttingest/latest.go index 9403e8a..9b0922c 100644 --- a/internal/mqttingest/latest.go +++ b/internal/mqttingest/latest.go @@ -40,7 +40,7 @@ func (l *Latest) Update(ts time.Time, p *WS90Payload) { l.lastTS = ts l.last = p - inc := l.computeRainIncrement(ts, p.RainMM) + inc := l.computeRainIncrement(p.RainMM) // Track last hour increments l.rainIncs = append(l.rainIncs, rainIncPoint{ts: ts, mm: inc}) @@ -75,7 +75,7 @@ func localMidnight(t time.Time) time.Time { // computeRainIncrement returns the “incremental rain” in mm for this sample, // regardless of whether the incoming rain_mm is cumulative or incremental. -func (l *Latest) computeRainIncrement(ts time.Time, rainMM float64) float64 { +func (l *Latest) computeRainIncrement(rainMM float64) float64 { // First sample: we can’t infer anything yet if l.lastRainMM == nil { l.lastRainMM = &rainMM