dialyzer fixes
This commit is contained in:
parent
7f06d3200a
commit
4baf3cffe7
7 changed files with 96 additions and 16 deletions
|
|
@ -1 +1,5 @@
|
||||||
[]
|
[
|
||||||
|
# Ignore all guard_test warnings from these files (false positives)
|
||||||
|
{"lib/aprsme_web/live/info_live/show.html.heex", :guard_test},
|
||||||
|
{"lib/aprsme/packet_consumer.ex", :guard_test}
|
||||||
|
]
|
||||||
|
|
|
||||||
|
|
@ -304,8 +304,6 @@ defmodule Aprsme.Packet do
|
||||||
|> put_message_fields(combined_data)
|
|> put_message_fields(combined_data)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp extract_from_map(_), do: %{}
|
|
||||||
|
|
||||||
defp put_symbol_fields(map, data_extended) do
|
defp put_symbol_fields(map, data_extended) do
|
||||||
map
|
map
|
||||||
|> maybe_put(:symbol_code, data_extended[:symbol_code] || data_extended["symbol_code"])
|
|> maybe_put(:symbol_code, data_extended[:symbol_code] || data_extended["symbol_code"])
|
||||||
|
|
|
||||||
|
|
@ -308,9 +308,6 @@ defmodule Aprsme.PacketConsumer do
|
||||||
:error -> nil
|
:error -> nil
|
||||||
end
|
end
|
||||||
|
|
||||||
nil ->
|
|
||||||
nil
|
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -298,8 +298,6 @@ defmodule Aprsme.Packets do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp extract_position_from_mic_e_struct(_), do: {nil, nil}
|
|
||||||
|
|
||||||
defp extract_position_from_mic_e(data_extended) do
|
defp extract_position_from_mic_e(data_extended) do
|
||||||
if is_number(data_extended[:lat_degrees]) and is_number(data_extended[:lat_minutes]) and
|
if is_number(data_extended[:lat_degrees]) and is_number(data_extended[:lat_minutes]) and
|
||||||
is_number(data_extended[:lon_degrees]) and is_number(data_extended[:lon_minutes]) do
|
is_number(data_extended[:lon_degrees]) and is_number(data_extended[:lon_minutes]) do
|
||||||
|
|
|
||||||
|
|
@ -49,12 +49,12 @@
|
||||||
</h1>
|
</h1>
|
||||||
<%= if @packet do %>
|
<%= if @packet do %>
|
||||||
<div class="text-sm text-gray-500 mb-6">
|
<div class="text-sm text-gray-500 mb-6">
|
||||||
{@packet.comment}
|
{@packet.comment || ""}
|
||||||
</div>
|
</div>
|
||||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-8">
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-8">
|
||||||
<div>
|
<div>
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
<span class="font-semibold">Location:</span> {@packet.lat}, {@packet.lon}
|
<span class="font-semibold">Location:</span> {@packet.lat || ""}, {@packet.lon || ""}
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
<span class="font-semibold">Last position:</span> {AprsmeWeb.MapLive.PacketUtils.get_timestamp(
|
<span class="font-semibold">Last position:</span> {AprsmeWeb.MapLive.PacketUtils.get_timestamp(
|
||||||
|
|
@ -67,15 +67,16 @@
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
<span class="font-semibold">Device:</span> {@packet.manufacturer} {@packet.equipment_type}
|
<span class="font-semibold">Device:</span> {@packet.manufacturer || ""} {@packet.equipment_type ||
|
||||||
|
""}
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-2"><span class="font-semibold">Path:</span> {@packet.path}</div>
|
<div class="mb-2"><span class="font-semibold">Path:</span> {@packet.path || ""}</div>
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
<span class="font-semibold">Raw:</span>
|
<span class="font-semibold">Raw:</span>
|
||||||
<%= if is_binary(@packet.raw_packet) do %>
|
<%= if is_binary(@packet.raw_packet) do %>
|
||||||
{Aprsme.EncodingUtils.sanitize_string(@packet.raw_packet)}
|
{Aprsme.EncodingUtils.sanitize_string(@packet.raw_packet)}
|
||||||
<% else %>
|
<% else %>
|
||||||
{@packet.raw_packet}
|
{@packet.raw_packet || ""}
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -124,8 +125,8 @@
|
||||||
/>
|
/>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<td class="px-4 py-2">{neighbor.distance}</td>
|
<td class="px-4 py-2">{neighbor.distance || ""}</td>
|
||||||
<td class="px-4 py-2">{neighbor.last_heard}</td>
|
<td class="px-4 py-2">{neighbor.last_heard || ""}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
||||||
|
|
@ -1219,4 +1219,80 @@ defmodule AprsmeWeb.MapLive.Index do
|
||||||
round4.(Map.get(b1, key)) == round4.(Map.get(b2, key))
|
round4.(Map.get(b1, key)) == round4.(Map.get(b2, key))
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# --- Private bounds update helpers ---
|
||||||
|
@spec handle_bounds_update(map(), Socket.t()) :: {:noreply, Socket.t()}
|
||||||
|
defp handle_bounds_update(bounds, socket) do
|
||||||
|
# Update the map bounds from the client, converting to atom keys
|
||||||
|
map_bounds = %{
|
||||||
|
north: bounds["north"],
|
||||||
|
south: bounds["south"],
|
||||||
|
east: bounds["east"],
|
||||||
|
west: bounds["west"]
|
||||||
|
}
|
||||||
|
|
||||||
|
# Validate bounds to prevent invalid coordinates
|
||||||
|
if valid_bounds?(map_bounds) do
|
||||||
|
handle_valid_bounds_update(map_bounds, socket)
|
||||||
|
else
|
||||||
|
# Invalid bounds, skip update
|
||||||
|
{:noreply, socket}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
defp valid_bounds?(map_bounds) do
|
||||||
|
map_bounds.north <= 90 and map_bounds.south >= -90 and map_bounds.north > map_bounds.south
|
||||||
|
end
|
||||||
|
|
||||||
|
defp handle_valid_bounds_update(map_bounds, socket) do
|
||||||
|
# Only schedule a bounds update if the bounds have actually changed (with rounding)
|
||||||
|
if compare_bounds(map_bounds, socket.assigns.map_bounds) do
|
||||||
|
{:noreply, socket}
|
||||||
|
else
|
||||||
|
schedule_bounds_update(map_bounds, socket)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
defp schedule_bounds_update(map_bounds, socket) do
|
||||||
|
if socket.assigns[:bounds_update_timer] do
|
||||||
|
Process.cancel_timer(socket.assigns.bounds_update_timer)
|
||||||
|
end
|
||||||
|
|
||||||
|
timer_ref = Process.send_after(self(), {:process_bounds_update, map_bounds}, 250)
|
||||||
|
socket = assign(socket, bounds_update_timer: timer_ref, pending_bounds: map_bounds)
|
||||||
|
{:noreply, socket}
|
||||||
|
end
|
||||||
|
|
||||||
|
@spec process_bounds_update(map(), Socket.t()) :: Socket.t()
|
||||||
|
defp process_bounds_update(map_bounds, socket) do
|
||||||
|
# Remove out-of-bounds packets and markers immediately
|
||||||
|
new_visible_packets =
|
||||||
|
socket.assigns.visible_packets
|
||||||
|
|> Enum.filter(fn {_k, packet} -> within_bounds?(packet, map_bounds) end)
|
||||||
|
|> Map.new()
|
||||||
|
|
||||||
|
packets_to_remove =
|
||||||
|
socket.assigns.visible_packets
|
||||||
|
|> Enum.reject(fn {_k, packet} -> within_bounds?(packet, map_bounds) end)
|
||||||
|
|> Enum.map(fn {k, _} -> k end)
|
||||||
|
|
||||||
|
# Remove markers for out-of-bounds packets
|
||||||
|
socket =
|
||||||
|
if packets_to_remove == [] do
|
||||||
|
socket
|
||||||
|
else
|
||||||
|
Enum.reduce(packets_to_remove, socket, fn k, acc ->
|
||||||
|
push_event(acc, "remove_marker", %{id: k})
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Remove only out-of-bounds historical packets instead of clearing all
|
||||||
|
socket = push_event(socket, "filter_markers_by_bounds", %{bounds: map_bounds})
|
||||||
|
|
||||||
|
# Load additional historical packets for the new bounds if needed
|
||||||
|
socket = load_historical_packets_for_bounds(socket, map_bounds)
|
||||||
|
|
||||||
|
# Update map bounds and visible packets
|
||||||
|
assign(socket, map_bounds: map_bounds, visible_packets: new_visible_packets)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
8
mix.exs
8
mix.exs
|
|
@ -12,7 +12,13 @@ defmodule Aprsme.MixProject do
|
||||||
deps: deps(),
|
deps: deps(),
|
||||||
releases: releases(),
|
releases: releases(),
|
||||||
test_coverage: [tool: ExCoveralls],
|
test_coverage: [tool: ExCoveralls],
|
||||||
listeners: [Phoenix.CodeReloader]
|
listeners: [Phoenix.CodeReloader],
|
||||||
|
dialyzer: [
|
||||||
|
ignore_warnings: ".dialyzer_ignore.exs",
|
||||||
|
plt_file:
|
||||||
|
{:no_warn,
|
||||||
|
"_build/dev/dialyxir_erlang-#{:erlang.system_info(:otp_release)}_elixir-#{System.version()}_deps-dev.plt"}
|
||||||
|
]
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue