Filter forecast graph to only show current and future hours
This commit is contained in:
parent
376e855217
commit
14e86c4ddb
2 changed files with 9 additions and 5 deletions
|
|
@ -142,8 +142,9 @@ function buildForecastSvg(forecast) {
|
||||||
Math.abs(p.time - now) < Math.abs(points[best].time - now) ? i : best, 0)
|
Math.abs(p.time - now) < Math.abs(points[best].time - now) ? i : best, 0)
|
||||||
const nowPt = points[nowIdx]
|
const nowPt = points[nowIdx]
|
||||||
|
|
||||||
// Trend
|
// Trend (from now onward)
|
||||||
const firstScore = points[0].score
|
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 lastScore = points[points.length - 1].score
|
||||||
const diff = lastScore - firstScore
|
const diff = lastScore - firstScore
|
||||||
let trend = ""
|
let trend = ""
|
||||||
|
|
@ -151,8 +152,9 @@ function buildForecastSvg(forecast) {
|
||||||
else if (diff < -5) trend = `<span style="color:#ff4f4f;">▼ Declining</span>`
|
else if (diff < -5) trend = `<span style="color:#ff4f4f;">▼ Declining</span>`
|
||||||
else trend = `<span style="color:#ffe566;">→ Steady</span>`
|
else trend = `<span style="color:#ffe566;">→ Steady</span>`
|
||||||
|
|
||||||
// Best time
|
// Best time (only future points)
|
||||||
const bestPt = points.reduce((best, p) => p.score > best.score ? p : best, points[0])
|
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 bestUtc = `${bestPt.time.getUTCHours().toString().padStart(2, "0")}:00 UTC`
|
||||||
const bestTier = scoreTier(bestPt.score)
|
const bestTier = scoreTier(bestPt.score)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -186,13 +186,15 @@ defmodule Microwaveprop.Propagation do
|
||||||
step = Grid.step()
|
step = Grid.step()
|
||||||
snapped_lat = Float.round(Float.round(lat / step) * step, 3)
|
snapped_lat = Float.round(Float.round(lat / step) * step, 3)
|
||||||
snapped_lon = Float.round(Float.round(lon / step) * step, 3)
|
snapped_lon = Float.round(Float.round(lon / step) * step, 3)
|
||||||
|
now = DateTime.utc_now()
|
||||||
|
|
||||||
Repo.all(
|
Repo.all(
|
||||||
from(gs in GridScore,
|
from(gs in GridScore,
|
||||||
where:
|
where:
|
||||||
gs.band_mhz == ^band_mhz and
|
gs.band_mhz == ^band_mhz and
|
||||||
gs.lat == ^snapped_lat 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},
|
select: %{valid_time: gs.valid_time, score: gs.score},
|
||||||
order_by: [asc: gs.valid_time]
|
order_by: [asc: gs.valid_time]
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue