diff --git a/lib/towerops_web/live/org/integrations_live.ex b/lib/towerops_web/live/org/integrations_live.ex index 71b754e3..382585f9 100644 --- a/lib/towerops_web/live/org/integrations_live.ex +++ b/lib/towerops_web/live/org/integrations_live.ex @@ -364,6 +364,19 @@ defmodule ToweropsWeb.Org.IntegrationsLive do max(0, div(diff, 60)) end + defp humanize_interval(minutes) when minutes >= 60 do + hours = div(minutes, 60) + rem_min = rem(minutes, 60) + + if rem_min == 0 do + "#{hours}h" + else + "#{hours}h #{rem_min}min" + end + end + + defp humanize_interval(minutes), do: "#{minutes}min" + defp normalize_params(provider, params, existing_integration) do sync_interval = Map.get(params, "sync_interval_minutes") diff --git a/lib/towerops_web/live/org/integrations_live.html.heex b/lib/towerops_web/live/org/integrations_live.html.heex index 5acfa4c1..e975ba49 100644 --- a/lib/towerops_web/live/org/integrations_live.html.heex +++ b/lib/towerops_web/live/org/integrations_live.html.heex @@ -102,14 +102,15 @@ <% end %> - <%= if integration.last_synced_at do %> - - · Next sync in ~{next_sync_minutes( + + · Syncs every {humanize_interval(integration.sync_interval_minutes)} + <%= if integration.last_synced_at do %> + · Next in ~{next_sync_minutes( integration.last_synced_at, integration.sync_interval_minutes )}m - - <% end %> + <% end %> + <%= if active_billing.id == "gaiia" do %> <.link @@ -554,14 +555,15 @@ <% end %> - <%= if integration.last_synced_at do %> - - · Next sync in ~{next_sync_minutes( + + · Syncs every {humanize_interval(integration.sync_interval_minutes)} + <%= if integration.last_synced_at do %> + · Next in ~{next_sync_minutes( integration.last_synced_at, integration.sync_interval_minutes )}m - - <% end %> + <% end %> + <%= if provider.id == "preseem" do %> <.link