From 83032822dabe2205dcb6e8490c462d08b29afffb Mon Sep 17 00:00:00 2001 From: Ivan Ivanov Date: Mon, 2 Dec 2024 17:03:57 +0200 Subject: [PATCH] Show missing metric registry fields. Add popover texts --- .../available_metrics_description.ex | 42 +++++++++++++++++++ .../metric_registry_show_live.ex | 28 +++++++++++++ 2 files changed, 70 insertions(+) diff --git a/lib/sanbase_web/live/available_metrics/available_metrics_description.ex b/lib/sanbase_web/live/available_metrics/available_metrics_description.ex index aca911dc3..953be5325 100644 --- a/lib/sanbase_web/live/available_metrics/available_metrics_description.ex +++ b/lib/sanbase_web/live/available_metrics/available_metrics_description.ex @@ -50,6 +50,17 @@ defmodule SanbaseWeb.AvailableMetricsDescription do """ end + def get_popover_text(%{key: "Human Readable Name"} = assigns) do + ~H""" +
+    The name of the metric formatted in a way that is suitable for showing
+    in Web UI and in texts shown to end clients. The name is capitalized, underscores
+    are replaced with spaces and other formatting is applied.
+    Example: The human readable name of 'price_usd' is 'USD Price'
+    
+ """ + end + def get_popover_text(%{key: "Clickhouse Table"} = assigns) do ~H"""
@@ -378,4 +389,35 @@ defmodule SanbaseWeb.AvailableMetricsDescription do
     
""" end + + def get_popover_text(%{key: "Verified Status"} = assigns) do + ~H""" +
+    After a change request is approved and its changes are applied to the databse
+    record, the metric is moved into a Unverified state. Someone will need to manually
+    verify the metric via the UI (after testing the changes).
+    Only verified metrics can be deployed from stage to prod.
+    
+ """ + end + + def get_popover_text(%{key: "Exposed Environments"} = assigns) do + ~H""" +
+    One of: none, all, stage, prod.
+    Controls on which deployment environment the metric is visible.
+    
+ """ + end + + def get_popover_text(%{key: "Sync Status"} = assigns) do + ~H""" +
+    Controls the deployment process of metrics. When a change request is approved
+    and applied, the metric is moved to 'not_synced' state indicating that the change
+    is not synced with the other environment.
+    Only metrics in not_synced state are deployed from stage to prod.
+    
+ """ + end end diff --git a/lib/sanbase_web/live/metric_registry/metric_registry_show_live.ex b/lib/sanbase_web/live/metric_registry/metric_registry_show_live.ex index e87d55a50..b2a1f1500 100644 --- a/lib/sanbase_web/live/metric_registry/metric_registry_show_live.ex +++ b/lib/sanbase_web/live/metric_registry/metric_registry_show_live.ex @@ -92,6 +92,24 @@ defmodule SanbaseWeb.MetricRegistryShowLive do popover_target: "popover-internal-name", popover_target_text: get_popover_text(%{key: "Internal Name"}) }, + %{ + key: "Human Readable Name", + value: metric_registry.human_readable_name, + popover_target: "popover-human-readable-name", + popover_target_text: get_popover_text(%{key: "Human Readable Name"}) + }, + %{ + key: "Verified Status", + value: to_verified_status(metric_registry.is_verified), + popover_target: "popover-verified-status", + popover_target_text: get_popover_text(%{key: "Verified Status"}) + }, + %{ + key: "Sync Status", + value: metric_registry.sync_status, + popover_target: "popover-sync-status", + popover_target_text: get_popover_text(%{key: "Sync Status"}) + }, %{ key: "Aliases", value: metric_registry.aliases |> Enum.map(& &1.name) |> Enum.join(", "), @@ -104,6 +122,12 @@ defmodule SanbaseWeb.MetricRegistryShowLive do popover_target: "popover-clickhouse-table", popover_target_text: get_popover_text(%{key: "Clickhouse Table"}) }, + %{ + key: "Exposed Environments", + value: metric_registry.exposed_environments, + popover_target: "popover-exposed-environments", + popover_target_text: get_popover_text(%{key: "Exposed Environments"}) + }, %{ key: "Min Interval", value: metric_registry.min_interval, @@ -220,4 +244,8 @@ defmodule SanbaseWeb.MetricRegistryShowLive do } ] end + + defp to_verified_status(is_verified) do + if is_verified, do: "VERIFIED", else: "UNVERIFIED" + end end