improve charts and logs

This commit is contained in:
2026-01-28 17:00:24 +11:00
parent aa71b51524
commit 536ec7ad70
4 changed files with 25 additions and 29 deletions

View File

@@ -34,6 +34,7 @@ type ForecastPoint struct {
WindGustMS *float64 `json:"wind_gust_m_s,omitempty"`
WindDirDeg *float64 `json:"wind_dir_deg,omitempty"`
PrecipMM *float64 `json:"precip_mm,omitempty"`
PrecipProb *float64 `json:"precip_prob,omitempty"`
CloudCover *float64 `json:"cloud_cover,omitempty"`
}
@@ -195,6 +196,7 @@ func (d *DB) ForecastSeriesLatest(ctx context.Context, site, model string) (Fore
wind_gust_m_s,
wind_dir_deg,
precip_mm,
precip_prob,
cloud_cover
FROM forecast_openmeteo_hourly
WHERE site = $1 AND model = $2 AND retrieved_at = $3
@@ -210,9 +212,9 @@ func (d *DB) ForecastSeriesLatest(ctx context.Context, site, model string) (Fore
var (
ts time.Time
temp, rh, msl, wind, gust sql.NullFloat64
dir, precip, cloud sql.NullFloat64
dir, precip, prob, cloud sql.NullFloat64
)
if err := rows.Scan(&ts, &temp, &rh, &msl, &wind, &gust, &dir, &precip, &cloud); err != nil {
if err := rows.Scan(&ts, &temp, &rh, &msl, &wind, &gust, &dir, &precip, &prob, &cloud); err != nil {
return ForecastSeries{}, err
}
points = append(points, ForecastPoint{
@@ -224,6 +226,7 @@ func (d *DB) ForecastSeriesLatest(ctx context.Context, site, model string) (Fore
WindGustMS: nullFloatPtr(gust),
WindDirDeg: nullFloatPtr(dir),
PrecipMM: nullFloatPtr(precip),
PrecipProb: nullFloatPtr(prob),
CloudCover: nullFloatPtr(cloud),
})
}
@@ -249,6 +252,7 @@ func (d *DB) ForecastSeriesRange(ctx context.Context, site, model string, start,
wind_gust_m_s,
wind_dir_deg,
precip_mm,
precip_prob,
cloud_cover
FROM forecast_openmeteo_hourly
WHERE site = $1 AND model = $2 AND ts >= $3 AND ts <= $4
@@ -266,9 +270,9 @@ func (d *DB) ForecastSeriesRange(ctx context.Context, site, model string, start,
ts time.Time
retrieved time.Time
temp, rh, msl, wind, gust sql.NullFloat64
dir, precip, cloud sql.NullFloat64
dir, precip, prob, cloud sql.NullFloat64
)
if err := rows.Scan(&ts, &retrieved, &temp, &rh, &msl, &wind, &gust, &dir, &precip, &cloud); err != nil {
if err := rows.Scan(&ts, &retrieved, &temp, &rh, &msl, &wind, &gust, &dir, &precip, &prob, &cloud); err != nil {
return ForecastSeries{}, err
}
if retrieved.After(maxRetrieved) {
@@ -283,6 +287,7 @@ func (d *DB) ForecastSeriesRange(ctx context.Context, site, model string, start,
WindGustMS: nullFloatPtr(gust),
WindDirDeg: nullFloatPtr(dir),
PrecipMM: nullFloatPtr(precip),
PrecipProb: nullFloatPtr(prob),
CloudCover: nullFloatPtr(cloud),
})
}