diff --git a/apps/astarte_data_updater_plant/lib/astarte_data_updater_plant/data_updater/impl.ex b/apps/astarte_data_updater_plant/lib/astarte_data_updater_plant/data_updater/impl.ex index 8c36ad287a..301c07b2d9 100644 --- a/apps/astarte_data_updater_plant/lib/astarte_data_updater_plant/data_updater/impl.ex +++ b/apps/astarte_data_updater_plant/lib/astarte_data_updater_plant/data_updater/impl.ex @@ -130,7 +130,7 @@ defmodule Astarte.DataUpdaterPlant.DataUpdater.Impl do Queries.set_device_connected!( new_state.realm, new_state.device_id, - DateTime.from_unix!(timestamp_ms, :microsecond), + DateTime.from_unix!(timestamp_ms, :millisecond), ip_address ) @@ -2244,7 +2244,7 @@ defmodule Astarte.DataUpdaterPlant.DataUpdater.Impl do Queries.set_device_disconnected!( state.realm, state.device_id, - DateTime.from_unix!(timestamp_ms, :microsecond), + DateTime.from_unix!(timestamp_ms, :millisecond), state.total_received_msgs, state.total_received_bytes, state.interface_exchanged_msgs, diff --git a/apps/astarte_data_updater_plant/lib/astarte_data_updater_plant/data_updater/queries.ex b/apps/astarte_data_updater_plant/lib/astarte_data_updater_plant/data_updater/queries.ex index 6006ac3efa..f2bd6169ea 100644 --- a/apps/astarte_data_updater_plant/lib/astarte_data_updater_plant/data_updater/queries.ex +++ b/apps/astarte_data_updater_plant/lib/astarte_data_updater_plant/data_updater/queries.ex @@ -457,6 +457,7 @@ defmodule Astarte.DataUpdaterPlant.DataUpdater.Queries do defp set_connection_info!(realm, device_id, timestamp, ip_address) do keyspace_name = Realm.keyspace_name(realm) + timestamp = Ecto.Type.cast!(:utc_datetime_usec, timestamp) %Device{device_id: device_id} |> Ecto.Changeset.change( @@ -515,6 +516,7 @@ defmodule Astarte.DataUpdaterPlant.DataUpdater.Queries do interface_exchanged_bytes ) do keyspace_name = Realm.keyspace_name(realm) + timestamp_ms = Ecto.Type.cast!(:utc_datetime_usec, timestamp_ms) %Device{device_id: device_id} |> Ecto.Changeset.change(