fix a few bits
This commit is contained in:
parent
8cbca259fc
commit
7772ff9a4a
3 changed files with 9 additions and 6 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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} ->
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue