adjust status page

This commit is contained in:
Graham McIntire 2025-06-15 19:10:22 -05:00
parent b8f61a9a06
commit 0fe175f342
No known key found for this signature in database
2 changed files with 16 additions and 16 deletions

View file

@ -33,9 +33,9 @@ defmodule Aprs.Is do
packet_stats = %{ packet_stats = %{
total_packets: 0, total_packets: 0,
last_packet_at: nil, last_packet_at: nil,
packets_per_minute: 0, packets_per_second: 0,
last_minute_count: 0, last_second_count: 0,
last_minute_timestamp: System.system_time(:second) last_second_timestamp: System.system_time(:second)
} }
# Set up ets tables # Set up ets tables
@ -355,24 +355,24 @@ defmodule Aprs.Is do
defp update_packet_stats(stats, current_time) do defp update_packet_stats(stats, current_time) do
new_total = stats.total_packets + 1 new_total = stats.total_packets + 1
# Check if we need to reset the per-minute counter # Check if we need to reset the per-second counter
if current_time - stats.last_minute_timestamp >= 60 do if current_time - stats.last_second_timestamp >= 1 do
%{ %{
total_packets: new_total, total_packets: new_total,
last_packet_at: DateTime.utc_now(), last_packet_at: DateTime.utc_now(),
packets_per_minute: 1, packets_per_second: 1,
last_minute_count: 1, last_second_count: 1,
last_minute_timestamp: current_time last_second_timestamp: current_time
} }
else else
new_minute_count = stats.last_minute_count + 1 new_second_count = stats.last_second_count + 1
%{ %{
stats stats
| total_packets: new_total, | total_packets: new_total,
last_packet_at: DateTime.utc_now(), last_packet_at: DateTime.utc_now(),
packets_per_minute: new_minute_count, packets_per_second: new_second_count,
last_minute_count: new_minute_count last_second_count: new_second_count
} }
end end
end end
@ -385,9 +385,9 @@ defmodule Aprs.Is do
%{ %{
total_packets: 0, total_packets: 0,
last_packet_at: nil, last_packet_at: nil,
packets_per_minute: 0, packets_per_second: 0,
last_minute_count: 0, last_second_count: 0,
last_minute_timestamp: System.system_time(:second) last_second_timestamp: System.system_time(:second)
} }
end end
end end

View file

@ -181,9 +181,9 @@ defmodule AprsWeb.StatusLive.Index do
</div> </div>
<div class="flex items-center"> <div class="flex items-center">
<span class="text-sm font-medium text-gray-500 mr-2">Packets/Min:</span> <span class="text-sm font-medium text-gray-500 mr-2">Packets/Sec:</span>
<span class="text-sm text-gray-900 font-mono"> <span class="text-sm text-gray-900 font-mono">
{@aprs_status.packet_stats.packets_per_minute} {@aprs_status.packet_stats.packets_per_second}
</span> </span>
</div> </div>