From 01bfb11ab46400f584fe325b308d09f3d73943f8 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Mon, 4 Aug 2025 11:43:15 -0500 Subject: [PATCH] fix: Convert integer timestamps to strings for database insertion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The APRS parser is sending timestamp as integer (Unix timestamp) but our schema expects a string. This was causing Ecto.ChangeError in production preventing packet insertion. Convert integer timestamps to strings in the field conversion pipeline. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- lib/aprsme/packet_consumer.ex | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/aprsme/packet_consumer.ex b/lib/aprsme/packet_consumer.ex index 6e7a733..98b9acf 100644 --- a/lib/aprsme/packet_consumer.ex +++ b/lib/aprsme/packet_consumer.ex @@ -450,7 +450,8 @@ defmodule Aprsme.PacketConsumer do # Convert field names that don't match our schema defp convert_field_names(attrs) do - then(attrs, fn a -> + attrs + |> then(fn a -> # Convert aprs_messaging? to aprs_messaging case Map.get(a, :aprs_messaging?) || Map.get(a, "aprs_messaging?") do nil -> @@ -463,6 +464,16 @@ defmodule Aprsme.PacketConsumer do |> Map.delete("aprs_messaging?") end end) + |> then(fn a -> + # Convert timestamp from integer to string if needed + case Map.get(a, :timestamp) do + timestamp when is_integer(timestamp) -> + Map.put(a, :timestamp, Integer.to_string(timestamp)) + + _ -> + a + end + end) end # Convert latitude/longitude to lat/lon if present at top level