diff --git a/lib/towerops/alerts.ex b/lib/towerops/alerts.ex index db9343b0..e25ecf3c 100644 --- a/lib/towerops/alerts.ex +++ b/lib/towerops/alerts.ex @@ -80,7 +80,7 @@ defmodule Towerops.Alerts do def acknowledge_alert(alert, user_id) do alert |> Alert.changeset(%{ - acknowledged_at: DateTime.utc_now(), + acknowledged_at: DateTime.truncate(DateTime.utc_now(), :second), acknowledged_by_id: user_id }) |> Repo.update() @@ -91,7 +91,7 @@ defmodule Towerops.Alerts do """ def resolve_alert(alert) do alert - |> Alert.changeset(%{resolved_at: DateTime.utc_now()}) + |> Alert.changeset(%{resolved_at: DateTime.truncate(DateTime.utc_now(), :second)}) |> Repo.update() end @@ -104,7 +104,7 @@ defmodule Towerops.Alerts do {:ok, _results} = AlertNotifier.deliver_alert_notification(alert) alert - |> Alert.changeset(%{email_sent_at: DateTime.utc_now()}) + |> Alert.changeset(%{email_sent_at: DateTime.truncate(DateTime.utc_now(), :second)}) |> Repo.update() end diff --git a/lib/towerops/monitoring/equipment_monitor.ex b/lib/towerops/monitoring/equipment_monitor.ex index b9c1eccb..0002fcd9 100644 --- a/lib/towerops/monitoring/equipment_monitor.ex +++ b/lib/towerops/monitoring/equipment_monitor.ex @@ -14,6 +14,9 @@ defmodule Towerops.Monitoring.EquipmentMonitor do @ping_module Application.compile_env(:towerops, :ping_module, Towerops.Monitoring.Ping) @poller_module Application.compile_env(:towerops, :poller_module, Towerops.Snmp.Poller) + # Suppress warnings for Mox modules that are defined at runtime during tests + @compile {:no_warn_undefined, [Towerops.Monitoring.PingMock, Towerops.Snmp.PollerMock]} + # Client API @doc """ @@ -79,7 +82,7 @@ defmodule Towerops.Monitoring.EquipmentMonitor do @ping_module.ping(equipment.ip_address) end - now = DateTime.utc_now() + now = DateTime.truncate(DateTime.utc_now(), :second) {status, response_time} = case check_result do @@ -122,7 +125,7 @@ defmodule Towerops.Monitoring.EquipmentMonitor do end defp handle_status_change(equipment, old_status, new_status) do - now = DateTime.utc_now() + now = DateTime.truncate(DateTime.utc_now(), :second) case {old_status, new_status} do {_, :down} -> diff --git a/lib/towerops/snmp/discovery.ex b/lib/towerops/snmp/discovery.ex index cc0a3d86..5a1284af 100644 --- a/lib/towerops/snmp/discovery.ex +++ b/lib/towerops/snmp/discovery.ex @@ -299,7 +299,7 @@ defmodule Towerops.Snmp.Discovery do {:ok, Equipment.t()} | {:error, Ecto.Changeset.t()} defp update_equipment_discovery_time(equipment) do equipment - |> Ecto.Changeset.change(last_discovery_at: DateTime.utc_now()) + |> Ecto.Changeset.change(last_discovery_at: DateTime.truncate(DateTime.utc_now(), :second)) |> Repo.update() end end