From 72b272cf5c8fc5c5143dc6924f6945754ad72526 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Sat, 4 Apr 2026 11:15:18 -0500 Subject: [PATCH] Add enrichment status badge column to contacts table --- .../live/contact_live/index.ex | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/microwaveprop_web/live/contact_live/index.ex b/lib/microwaveprop_web/live/contact_live/index.ex index 66ff050e..410ca22d 100644 --- a/lib/microwaveprop_web/live/contact_live/index.ex +++ b/lib/microwaveprop_web/live/contact_live/index.ex @@ -72,6 +72,29 @@ defmodule MicrowavepropWeb.ContactLive.Index do defp validate_sort_order(order) when order in ~w(asc desc), do: order defp validate_sort_order(_), do: @default_sort_order + @enrichment_fields [:hrrr_status, :weather_status, :terrain_status, :iemre_status] + @done_statuses [:complete, :unavailable] + + defp enrichment_badge(contact) do + statuses = Enum.map(@enrichment_fields, &Map.get(contact, &1)) + done = Enum.count(statuses, &(&1 in @done_statuses)) + failed = Enum.count(statuses, &(&1 == :failed)) + + {label, class} = + cond do + done == 4 -> {"Complete", "badge-success"} + failed > 0 -> {"Failed", "badge-error"} + done > 0 -> {"Partial", "badge-warning"} + true -> {"Pending", "badge-ghost"} + end + + assigns = %{label: label, class: class} + + ~H""" + {@label} + """ + end + @impl true def render(assigns) do ~H""" @@ -111,6 +134,7 @@ defmodule MicrowavepropWeb.ContactLive.Index do Band Mode Distance (km) + Enriched Submitted Timestamp (UTC) Added (UTC) @@ -119,7 +143,7 @@ defmodule MicrowavepropWeb.ContactLive.Index do <%= for {primary, reciprocals} <- @grouped_contacts do %> - + {primary.mode} {primary.distance_km} {if primary.user_submitted, do: "Yes", else: "—"} + {enrichment_badge(primary)} {Calendar.strftime(primary.qso_timestamp, "%Y-%m-%d %H:%M")} {Calendar.strftime(primary.inserted_at, "%Y-%m-%d %H:%M")} @@ -162,6 +187,7 @@ defmodule MicrowavepropWeb.ContactLive.Index do {recip.mode} {recip.distance_km} {if recip.user_submitted, do: "Yes", else: "—"} + {enrichment_badge(recip)} {Calendar.strftime(recip.qso_timestamp, "%Y-%m-%d %H:%M")} {Calendar.strftime(recip.inserted_at, "%Y-%m-%d %H:%M")}