diff --git a/lib/microwaveprop_web/live/map_live.ex b/lib/microwaveprop_web/live/map_live.ex index 40f645b7..9f807d8c 100644 --- a/lib/microwaveprop_web/live/map_live.ex +++ b/lib/microwaveprop_web/live/map_live.ex @@ -71,6 +71,8 @@ defmodule MicrowavepropWeb.MapLive do # wrong viewport and forecast-hour clicks show a small square of # coverage instead of the full map. + build_ts = Microwaveprop.Application.build_timestamp() + {:ok, assign(socket, page_title: "Propagation Prediction Map", @@ -85,10 +87,26 @@ defmodule MicrowavepropWeb.MapLive do outside_conus: outside_conus?(visitor), grid_visible: false, radar_visible: false, - antenna_height_ft: 33 + antenna_height_ft: 33, + deploy_iso: Calendar.strftime(build_ts, "%Y-%m-%d %H:%M UTC"), + deploy_ago: format_deploy_ago(build_ts) )} end + # Compact relative-time rendering of the build timestamp. Matches the + # format used by Layouts.deploy_stamp/1 so the nav and the map + # sidebar stay consistent. + defp format_deploy_ago(%DateTime{} = dt) do + diff = max(DateTime.diff(DateTime.utc_now(), dt, :second), 0) + + cond do + diff < 60 -> "just now" + diff < 3600 -> "#{div(diff, 60)}m ago" + diff < 86_400 -> "#{div(diff, 3600)}h ago" + true -> "#{div(diff, 86_400)}d ago" + end + end + # Prefer the visitor's Cloudflare geolocation when present; fall back to DFW. defp initial_center(%{"cf_lat" => lat, "cf_lon" => lon}) when is_float(lat) and is_float(lon) do %{lat: lat, lon: lon} @@ -879,6 +897,13 @@ defmodule MicrowavepropWeb.MapLive do status={@pipeline_status} progress={@pipeline_progress} /> + +
+ Deployed {@deploy_ago} +