Rename 'How this works' to 'Scoring Algorithm'

This commit is contained in:
Graham McIntire 2026-03-31 10:24:04 -05:00
parent ccac7a5020
commit 2f2f3388cd
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59
5 changed files with 37 additions and 26 deletions

View file

@ -224,6 +224,12 @@ export const PropagationMap = {
{ min: 0, r: 255, g: 79, b: 79 }
]
// Render pre-loaded scores immediately (no round-trip needed)
const initialScores = JSON.parse(this.el.dataset.scores || "[]")
if (initialScores.length > 0) {
this.renderScores(initialScores)
}
this.handleEvent("update_scores", ({ scores }) => {
topbar.hide()
this.renderScores(scores)
@ -466,7 +472,7 @@ export const PropagationMap = {
},
sendBounds() {
topbar.show(300)
topbar.show()
const b = this.map.getBounds()
this.pushEvent("map_bounds", {
south: b.getSouth(),

View file

@ -89,22 +89,18 @@ defmodule Microwaveprop.Propagation do
{:ok, total}
end
@doc "Get the latest scores for a band, optionally within a bounding box."
@doc "Get the latest scores for a band, optionally within a bounding box. Excludes factors for performance."
def latest_scores(band_mhz, bounds \\ nil) do
latest_time_query =
from(gs in GridScore,
where: gs.band_mhz == ^band_mhz,
select: max(gs.valid_time)
)
latest_time = latest_valid_time(band_mhz)
case Repo.one(latest_time_query) do
case latest_time do
nil ->
[]
latest_time ->
_ ->
from(gs in GridScore,
where: gs.band_mhz == ^band_mhz and gs.valid_time == ^latest_time,
select: %{lat: gs.lat, lon: gs.lon, score: gs.score, factors: gs.factors, valid_time: gs.valid_time}
select: %{lat: gs.lat, lon: gs.lon, score: gs.score, valid_time: gs.valid_time}
)
|> maybe_filter_bounds(bounds)
|> Repo.all()
@ -117,13 +113,7 @@ defmodule Microwaveprop.Propagation do
snapped_lat = Float.round(Float.round(lat / step) * step, 3)
snapped_lon = Float.round(Float.round(lon / step) * step, 3)
latest_time_query =
from(gs in GridScore,
where: gs.band_mhz == ^band_mhz,
select: max(gs.valid_time)
)
case Repo.one(latest_time_query) do
case latest_valid_time(band_mhz) do
nil ->
nil
@ -160,6 +150,11 @@ defmodule Microwaveprop.Propagation do
Repo.one(from(gs in GridScore, select: max(gs.valid_time)))
end
@doc "Get the latest valid_time for a specific band."
def latest_valid_time(band_mhz) do
Repo.one(from(gs in GridScore, where: gs.band_mhz == ^band_mhz, select: max(gs.valid_time)))
end
defp derive_from_hrrr(%{profile: profile}) when is_list(profile) and length(profile) >= 3 do
case SoundingParams.derive(profile) do
nil -> %{}

View file

@ -7,6 +7,12 @@
<.live_title default="Microwaveprop" suffix=" · Phoenix Framework">
{assigns[:page_title]}
</.live_title>
<link rel="preconnect" href="https://a.tile.openstreetmap.org" crossorigin />
<link rel="preconnect" href="https://b.tile.openstreetmap.org" crossorigin />
<link rel="preconnect" href="https://c.tile.openstreetmap.org" crossorigin />
<link rel="dns-prefetch" href="https://a.tile.openstreetmap.org" />
<link rel="dns-prefetch" href="https://b.tile.openstreetmap.org" />
<link rel="dns-prefetch" href="https://c.tile.openstreetmap.org" />
<link phx-track-static rel="stylesheet" href={~p"/assets/css/app.css"} />
<script defer phx-track-static type="text/javascript" src={~p"/assets/js/app.js"}>
</script>

View file

@ -6,11 +6,18 @@ defmodule MicrowavepropWeb.MapLive do
alias Microwaveprop.Propagation.BandConfig
@default_band 10_000
@initial_bounds %{
"south" => 29.5,
"north" => 36.3,
"west" => -101.5,
"east" => -92.5
}
@impl true
def mount(_params, _session, socket) do
bands = BandConfig.all_bands()
valid_time = Propagation.latest_valid_time()
initial_scores = Propagation.latest_scores(@default_band, @initial_bounds)
if connected?(socket) do
Phoenix.PubSub.subscribe(Microwaveprop.PubSub, "propagation:updated")
@ -21,9 +28,9 @@ defmodule MicrowavepropWeb.MapLive do
page_title: "Propagation Map",
bands: bands,
selected_band: @default_band,
scores: [],
initial_scores_json: Jason.encode!(initial_scores),
valid_time: valid_time,
bounds: nil,
bounds: @initial_bounds,
grid_visible: false
)}
end
@ -36,7 +43,6 @@ defmodule MicrowavepropWeb.MapLive do
socket =
socket
|> assign(:selected_band, band)
|> assign(:scores, scores)
|> push_event("update_scores", %{scores: scores})
|> push_event("update_band_info", %{band_info: band_info(band)})
@ -60,7 +66,6 @@ defmodule MicrowavepropWeb.MapLive do
socket =
socket
|> assign(:bounds, bounds)
|> assign(:scores, scores)
|> push_event("update_scores", %{scores: scores})
{:noreply, socket}
@ -72,7 +77,6 @@ defmodule MicrowavepropWeb.MapLive do
socket =
socket
|> assign(:scores, scores)
|> assign(:valid_time, valid_time)
|> push_event("update_scores", %{scores: scores})
@ -117,7 +121,7 @@ defmodule MicrowavepropWeb.MapLive do
id="propagation-map"
phx-hook="PropagationMap"
phx-update="ignore"
data-scores="[]"
data-scores={Jason.encode!(@scores)}
data-band-info={Jason.encode!(band_info(@selected_band))}
class="absolute inset-0 z-0"
>
@ -178,7 +182,7 @@ defmodule MicrowavepropWeb.MapLive do
<%!-- Links --%>
<div class="flex flex-col gap-1 border-t border-base-300 pt-2">
<.link navigate="/algo" class="btn btn-xs btn-ghost justify-start gap-1.5">
<.icon name="hero-information-circle" class="size-3.5" /> How this works
<.icon name="hero-calculator" class="size-3.5" /> Scoring Algorithm
</.link>
<.link navigate="/submit" class="btn btn-xs btn-ghost justify-start gap-1.5">
<.icon name="hero-arrow-up-tray" class="size-3.5" /> Submit a QSO

View file

@ -35,9 +35,9 @@ defmodule MicrowavepropWeb.MapLiveTest do
assert html =~ ~s(phx-click="toggle_grid")
end
test "renders how this works link", %{conn: conn} do
test "renders scoring algorithm link", %{conn: conn} do
{:ok, _lv, html} = live(conn, ~p"/map")
assert html =~ "How this works"
assert html =~ "Scoring Algorithm"
assert html =~ ~s(/algo)
end