Rename 'How this works' to 'Scoring Algorithm'
This commit is contained in:
parent
ccac7a5020
commit
2f2f3388cd
5 changed files with 37 additions and 26 deletions
|
|
@ -224,6 +224,12 @@ export const PropagationMap = {
|
||||||
{ min: 0, r: 255, g: 79, b: 79 }
|
{ 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 }) => {
|
this.handleEvent("update_scores", ({ scores }) => {
|
||||||
topbar.hide()
|
topbar.hide()
|
||||||
this.renderScores(scores)
|
this.renderScores(scores)
|
||||||
|
|
@ -466,7 +472,7 @@ export const PropagationMap = {
|
||||||
},
|
},
|
||||||
|
|
||||||
sendBounds() {
|
sendBounds() {
|
||||||
topbar.show(300)
|
topbar.show()
|
||||||
const b = this.map.getBounds()
|
const b = this.map.getBounds()
|
||||||
this.pushEvent("map_bounds", {
|
this.pushEvent("map_bounds", {
|
||||||
south: b.getSouth(),
|
south: b.getSouth(),
|
||||||
|
|
|
||||||
|
|
@ -89,22 +89,18 @@ defmodule Microwaveprop.Propagation do
|
||||||
{:ok, total}
|
{:ok, total}
|
||||||
end
|
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
|
def latest_scores(band_mhz, bounds \\ nil) do
|
||||||
latest_time_query =
|
latest_time = latest_valid_time(band_mhz)
|
||||||
from(gs in GridScore,
|
|
||||||
where: gs.band_mhz == ^band_mhz,
|
|
||||||
select: max(gs.valid_time)
|
|
||||||
)
|
|
||||||
|
|
||||||
case Repo.one(latest_time_query) do
|
case latest_time do
|
||||||
nil ->
|
nil ->
|
||||||
[]
|
[]
|
||||||
|
|
||||||
latest_time ->
|
_ ->
|
||||||
from(gs in GridScore,
|
from(gs in GridScore,
|
||||||
where: gs.band_mhz == ^band_mhz and gs.valid_time == ^latest_time,
|
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)
|
|> maybe_filter_bounds(bounds)
|
||||||
|> Repo.all()
|
|> Repo.all()
|
||||||
|
|
@ -117,13 +113,7 @@ defmodule Microwaveprop.Propagation do
|
||||||
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)
|
||||||
|
|
||||||
latest_time_query =
|
case latest_valid_time(band_mhz) do
|
||||||
from(gs in GridScore,
|
|
||||||
where: gs.band_mhz == ^band_mhz,
|
|
||||||
select: max(gs.valid_time)
|
|
||||||
)
|
|
||||||
|
|
||||||
case Repo.one(latest_time_query) do
|
|
||||||
nil ->
|
nil ->
|
||||||
nil
|
nil
|
||||||
|
|
||||||
|
|
@ -160,6 +150,11 @@ defmodule Microwaveprop.Propagation do
|
||||||
Repo.one(from(gs in GridScore, select: max(gs.valid_time)))
|
Repo.one(from(gs in GridScore, select: max(gs.valid_time)))
|
||||||
end
|
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
|
defp derive_from_hrrr(%{profile: profile}) when is_list(profile) and length(profile) >= 3 do
|
||||||
case SoundingParams.derive(profile) do
|
case SoundingParams.derive(profile) do
|
||||||
nil -> %{}
|
nil -> %{}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,12 @@
|
||||||
<.live_title default="Microwaveprop" suffix=" · Phoenix Framework">
|
<.live_title default="Microwaveprop" suffix=" · Phoenix Framework">
|
||||||
{assigns[:page_title]}
|
{assigns[:page_title]}
|
||||||
</.live_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"} />
|
<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 defer phx-track-static type="text/javascript" src={~p"/assets/js/app.js"}>
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,18 @@ defmodule MicrowavepropWeb.MapLive do
|
||||||
alias Microwaveprop.Propagation.BandConfig
|
alias Microwaveprop.Propagation.BandConfig
|
||||||
|
|
||||||
@default_band 10_000
|
@default_band 10_000
|
||||||
|
@initial_bounds %{
|
||||||
|
"south" => 29.5,
|
||||||
|
"north" => 36.3,
|
||||||
|
"west" => -101.5,
|
||||||
|
"east" => -92.5
|
||||||
|
}
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def mount(_params, _session, socket) do
|
def mount(_params, _session, socket) do
|
||||||
bands = BandConfig.all_bands()
|
bands = BandConfig.all_bands()
|
||||||
valid_time = Propagation.latest_valid_time()
|
valid_time = Propagation.latest_valid_time()
|
||||||
|
initial_scores = Propagation.latest_scores(@default_band, @initial_bounds)
|
||||||
|
|
||||||
if connected?(socket) do
|
if connected?(socket) do
|
||||||
Phoenix.PubSub.subscribe(Microwaveprop.PubSub, "propagation:updated")
|
Phoenix.PubSub.subscribe(Microwaveprop.PubSub, "propagation:updated")
|
||||||
|
|
@ -21,9 +28,9 @@ defmodule MicrowavepropWeb.MapLive do
|
||||||
page_title: "Propagation Map",
|
page_title: "Propagation Map",
|
||||||
bands: bands,
|
bands: bands,
|
||||||
selected_band: @default_band,
|
selected_band: @default_band,
|
||||||
scores: [],
|
initial_scores_json: Jason.encode!(initial_scores),
|
||||||
valid_time: valid_time,
|
valid_time: valid_time,
|
||||||
bounds: nil,
|
bounds: @initial_bounds,
|
||||||
grid_visible: false
|
grid_visible: false
|
||||||
)}
|
)}
|
||||||
end
|
end
|
||||||
|
|
@ -36,7 +43,6 @@ defmodule MicrowavepropWeb.MapLive do
|
||||||
socket =
|
socket =
|
||||||
socket
|
socket
|
||||||
|> assign(:selected_band, band)
|
|> assign(:selected_band, band)
|
||||||
|> assign(:scores, scores)
|
|
||||||
|> push_event("update_scores", %{scores: scores})
|
|> push_event("update_scores", %{scores: scores})
|
||||||
|> push_event("update_band_info", %{band_info: band_info(band)})
|
|> push_event("update_band_info", %{band_info: band_info(band)})
|
||||||
|
|
||||||
|
|
@ -60,7 +66,6 @@ defmodule MicrowavepropWeb.MapLive do
|
||||||
socket =
|
socket =
|
||||||
socket
|
socket
|
||||||
|> assign(:bounds, bounds)
|
|> assign(:bounds, bounds)
|
||||||
|> assign(:scores, scores)
|
|
||||||
|> push_event("update_scores", %{scores: scores})
|
|> push_event("update_scores", %{scores: scores})
|
||||||
|
|
||||||
{:noreply, socket}
|
{:noreply, socket}
|
||||||
|
|
@ -72,7 +77,6 @@ defmodule MicrowavepropWeb.MapLive do
|
||||||
|
|
||||||
socket =
|
socket =
|
||||||
socket
|
socket
|
||||||
|> assign(:scores, scores)
|
|
||||||
|> assign(:valid_time, valid_time)
|
|> assign(:valid_time, valid_time)
|
||||||
|> push_event("update_scores", %{scores: scores})
|
|> push_event("update_scores", %{scores: scores})
|
||||||
|
|
||||||
|
|
@ -117,7 +121,7 @@ defmodule MicrowavepropWeb.MapLive do
|
||||||
id="propagation-map"
|
id="propagation-map"
|
||||||
phx-hook="PropagationMap"
|
phx-hook="PropagationMap"
|
||||||
phx-update="ignore"
|
phx-update="ignore"
|
||||||
data-scores="[]"
|
data-scores={Jason.encode!(@scores)}
|
||||||
data-band-info={Jason.encode!(band_info(@selected_band))}
|
data-band-info={Jason.encode!(band_info(@selected_band))}
|
||||||
class="absolute inset-0 z-0"
|
class="absolute inset-0 z-0"
|
||||||
>
|
>
|
||||||
|
|
@ -178,7 +182,7 @@ defmodule MicrowavepropWeb.MapLive do
|
||||||
<%!-- Links --%>
|
<%!-- Links --%>
|
||||||
<div class="flex flex-col gap-1 border-t border-base-300 pt-2">
|
<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">
|
<.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>
|
||||||
<.link navigate="/submit" class="btn btn-xs btn-ghost justify-start gap-1.5">
|
<.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
|
<.icon name="hero-arrow-up-tray" class="size-3.5" /> Submit a QSO
|
||||||
|
|
|
||||||
|
|
@ -35,9 +35,9 @@ defmodule MicrowavepropWeb.MapLiveTest do
|
||||||
assert html =~ ~s(phx-click="toggle_grid")
|
assert html =~ ~s(phx-click="toggle_grid")
|
||||||
end
|
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")
|
{:ok, _lv, html} = live(conn, ~p"/map")
|
||||||
assert html =~ "How this works"
|
assert html =~ "Scoring Algorithm"
|
||||||
assert html =~ ~s(/algo)
|
assert html =~ ~s(/algo)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue