diff --git a/lib/live_beats_web/channels/presence.ex b/lib/live_beats_web/channels/presence.ex index 986a3ba..42f9c24 100644 --- a/lib/live_beats_web/channels/presence.ex +++ b/lib/live_beats_web/channels/presence.ex @@ -68,6 +68,30 @@ end defmodule LiveBeatsWeb.Presence.BadgeComponent do use LiveBeatsWeb, :live_component + # https://fly.io/docs/reference/regions/ + @region_names %{ + "ams" => "Amsterdam, Netherlands", + "atl" => "Atlanta, Georgia (US)", + "cdg" => "Paris, France", + "dfw" => "Dallas, Texas (US)", + "ewr" => "Parsippany, NJ (US)", + "fra" => "Frankfurt, Germany", + "gru" => "Sao Paulo, Brazil", + "hkg" => "Hong Kong", + "iad" => "Ashburn, Virginia (US)", + "lax" => "Los Angeles, California (US)", + "lhr" => "London, United Kingdom", + "maa" => "Chennai (Madras), India", + "nrt" => "Tokyo, Japan", + "ord" => "Chicago, Illinois (US)", + "scl" => "Santiago, Chile", + "sea" => "Seattle, Washington (US)", + "sin" => "Singapore", + "sjc" => "Sunnyvale, California (US)", + "syd" => "Sydney, Australia", + "yyz" => "Toronto, Canada" + } + def render(assigns) do ~H"""
  • @@ -78,7 +102,7 @@ defmodule LiveBeatsWeb.Presence.BadgeComponent do <%= @presence.username %> <%= if @ping do %>

    ping: <%= @ping %>ms

    - <%= if @region do %><% end %> + <%= if @region do %><% end %> <% end %> @@ -115,4 +139,6 @@ defmodule LiveBeatsWeb.Presence.BadgeComponent do end defp now_ms, do: System.system_time(:millisecond) + + defp region_name(region), do: Map.get(@region_names, region) end