Skip to content

Commit

Permalink
Merge pull request #1020 from osmanhadzic/fix-object-datastream
Browse files Browse the repository at this point in the history
Refactor: streamline state handling in populatedb
  • Loading branch information
Annopaolo authored Nov 28, 2024
2 parents f177914 + bdcd096 commit 67fd1cb
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions tools/astarte_import/lib/astarte/import/populatedb.ex
Original file line number Diff line number Diff line change
Expand Up @@ -330,15 +330,17 @@ defmodule Astarte.Import.PopulateDB do
got_end_of_object_fun = fn state, object ->
%Import.State{
reception_timestamp: reception_timestamp,
data: %State{
mappings: mappings,
prepared_params: prepared_params,
prepared_query: prepared_query,
value_columns: value_columns,
value_type: expected_types
}
data: data
} = state

%State{
mappings: mappings,
prepared_params: prepared_params,
prepared_query: prepared_query,
value_columns: value_columns,
value_type: expected_types
} = data

reception_submillis = rem(DateTime.to_unix(reception_timestamp, :microsecond), 100)
{:ok, native_value} = to_native_type(object, expected_types)

Expand All @@ -360,7 +362,10 @@ defmodule Astarte.Import.PopulateDB do

{:ok, %Xandra.Void{}} = Xandra.execute(xandra_conn, prepared_query, params)

state
%Import.State{
state
| data: %State{data | last_seen_reception_timestamp: reception_timestamp}
}
end

got_end_of_property_fun = fn state, chars ->
Expand Down

0 comments on commit 67fd1cb

Please sign in to comment.