Filter forecast graph to only show current and future hours

This commit is contained in:
Graham McIntire 2026-04-01 08:14:29 -05:00
parent 376e855217
commit 14e86c4ddb
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59
2 changed files with 9 additions and 5 deletions

View file

@ -142,8 +142,9 @@ function buildForecastSvg(forecast) {
Math.abs(p.time - now) < Math.abs(points[best].time - now) ? i : best, 0)
const nowPt = points[nowIdx]
// Trend
const firstScore = points[0].score
// Trend (from now onward)
const futurePoints = points.filter(p => p.time >= now)
const firstScore = futurePoints.length > 0 ? futurePoints[0].score : points[0].score
const lastScore = points[points.length - 1].score
const diff = lastScore - firstScore
let trend = ""
@ -151,8 +152,9 @@ function buildForecastSvg(forecast) {
else if (diff < -5) trend = `<span style="color:#ff4f4f;">&#9660; Declining</span>`
else trend = `<span style="color:#ffe566;">&#8594; Steady</span>`
// Best time
const bestPt = points.reduce((best, p) => p.score > best.score ? p : best, points[0])
// Best time (only future points)
const bestPool = futurePoints.length > 0 ? futurePoints : points
const bestPt = bestPool.reduce((best, p) => p.score > best.score ? p : best, bestPool[0])
const bestUtc = `${bestPt.time.getUTCHours().toString().padStart(2, "0")}:00 UTC`
const bestTier = scoreTier(bestPt.score)

View file

@ -186,13 +186,15 @@ defmodule Microwaveprop.Propagation do
step = Grid.step()
snapped_lat = Float.round(Float.round(lat / step) * step, 3)
snapped_lon = Float.round(Float.round(lon / step) * step, 3)
now = DateTime.utc_now()
Repo.all(
from(gs in GridScore,
where:
gs.band_mhz == ^band_mhz and
gs.lat == ^snapped_lat and
gs.lon == ^snapped_lon,
gs.lon == ^snapped_lon and
gs.valid_time >= ^now,
select: %{valid_time: gs.valid_time, score: gs.score},
order_by: [asc: gs.valid_time]
)