Commit graph

495 commits

Author SHA1 Message Date
ae14b120fa
Remove Redis/Cachex dependency, use pure ETS for caching
- Replace Cachex with native ETS (Erlang Term Storage) in Cache module
- Remove Redis-based caching logic from application.ex
- Always initialize ETS tables for device_cache, query_cache, symbol_cache
- Update StatusLive to use Aprsme.Cache instead of Cachex directly
- Fix crash on startup when REDIS_URL was set but Redis not used

This fixes the no_cache error that was causing pods to crash.
2025-10-24 17:12:38 -05:00
18d95b9a1f
fix: add timeout for cluster formation to ensure APRS-IS connection
Previously, when clustering was enabled, the leader election process
would wait indefinitely for the cluster to form. If cluster formation
failed or took too long, no leader would be elected and the APRS-IS
connection would never start, leaving the system disconnected.

Changes:
- Add 30-second timeout for cluster formation
- Force leader election after timeout, even in single-node mode
- Add election_forced flag to prevent duplicate election attempts
- Improve logging to distinguish between cluster and single-node modes

This ensures that at least one node will always connect to APRS-IS,
even if clustering fails completely.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 15:00:43 -05:00
537057ee9a
more redis cleanup 2025-10-22 16:30:04 -05:00
26d93e36c7
fix: remove Exq dependency and Redis job queue
- Remove Exq dependency from mix.exs and application config
- Remove all Exq configuration from config files (config.exs, dev.exs, runtime.exs, test.exs)
- Update CleanupScheduler to run cleanup tasks directly using Task.start instead of queuing jobs
- Update PacketCleanupWorker documentation to remove Exq references
- Cleanup functionality preserved but now runs in supervised Tasks instead of job queue

This resolves the Redis connection error on startup by eliminating the dependency on external job queues.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-22 16:24:59 -05:00
cc4578653f
cleanup and remove redis 2025-10-22 16:19:17 -05:00
6acc007360
refactor: remove Redis dependency for PubSub, use distributed Erlang
- Remove phoenix_pubsub_redis dependency from mix.exs
- Update PubSub configuration to use Phoenix's native distributed capabilities
- Simplify clustering logic - no longer requires Redis URL for PubSub
- Phoenix PubSub automatically distributes messages across connected Erlang nodes
- Benefits: lower latency, automatic failure handling, simpler deployment
- Redis still available for caching and job processing when needed
- Maintains backward compatibility for both clustered and non-clustered modes

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-22 15:48:00 -05:00
5e3f0bc5cf
fix coord bug 2025-10-19 09:06:58 -05:00
1b638cf739
chore: add contributor guide and harden cache/csrf helpers 2025-10-15 11:53:21 -05:00
751b8a5f1b
improve dialyzer 2025-10-13 10:02:15 -05:00
d75896597e
fix: resolve test failures and improve error handling
- Fix duplicate bad packet storage in store_packet function
  - Changed insert_packet to return specific error tuples
  - Handle validation_error and storage_exception separately
  - Prevent double storage of bad packets

- Add try/catch wrapper around insert_packet for exception handling
  - Properly catch and return storage_exception errors
  - Test now correctly expects :storage_exception

- Add helper function for LiveView tests with duplicate IDs
  - Added live_with_warn/2 to ConnCase
  - Suppress duplicate ID warnings in integration tests

- Fix unused variable warning in insert_packet

All packet tests now pass without failures.
2025-10-13 09:26:40 -05:00
62ada761cd
refactor: improve code quality and fix potential issues
- Remove duplicate time formatting function in components.ex
  - Use existing time_ago_in_words from TimeHelpers instead of custom format_time_ago
- Remove unnecessary Float multiplication in format_coordinates
  - Changed Float.round(lat * 1.0, 4) to Float.round(lat, 4)
- Fix TypeScript type safety issues
  - Add pendingMarkers to LiveViewHookContext interface
  - Add initializationTimeout property for proper cleanup
- Add cleanup for map initialization retry timeout
  - Prevent memory leak by clearing timeout in destroyed() method
- Format code with mix format

All changes maintain backward compatibility while improving code quality.
2025-10-12 14:02:27 -05:00
06a881d63f
fix: pass required map data attributes to map component
The map component requires data-center and data-zoom attributes
for proper initialization.
2025-10-12 12:36:36 -05:00
ff636f6e5e
fix: use correct APRSMap hook name in map component 2025-10-12 12:17:11 -05:00
5491bafc31
fix: remove invalid empty state from stream container
The phx-update="stream" directive requires all direct children to have IDs.
Removed the conditional empty state message that was causing client-side errors.
2025-10-12 12:16:27 -05:00
1a92b89ca8
fix: correct toggle_button class attribute syntax
Fixed incorrect class attribute syntax in toggle_button that was using tuple notation (hidden: @slideover_open) instead of proper conditional.
2025-10-12 12:09:43 -05:00
533061c261
fix: correct remaining class attribute syntax errors
Fixed another incorrect class attribute syntax in connection_indicator component that was causing Protocol.UndefinedError.
2025-10-12 12:04:39 -05:00
1905c6b41a
fix: correct class attribute syntax in components
Fixed incorrect class attribute syntax that was using tuple notation instead of proper conditional class lists. This was causing Protocol.UndefinedError for String.Chars.
2025-10-12 11:58:16 -05:00
5b874185e9
fix: change streams.packets to packets in template
The template was trying to access @streams.packets but LiveView streams were not implemented. Changed to use @packets which is the correct assign.
2025-10-12 11:51:35 -05:00
72eab2aa91
fix: add missing assigns for LiveView components
The recent refactor removed loading and connection_status assigns which were required by the slideover_panel component, causing the app to crash on startup. This adds back the missing assigns with default values.
2025-10-12 11:47:05 -05:00
070b8870df
refactor 2025-10-12 10:56:49 -05:00
265c58b9ff
Fix aprs-is variables 2025-10-12 10:32:12 -05:00
5dfd682142
fix: exclude APRS-IS paths from RF path visualization
Previously, packets sent via APRS-IS (Internet) would incorrectly show
RF path lines to the uploader's callsign. This fix filters out paths
containing TCPIP, NOGATE, or qA* indicators, which indicate Internet-only
transmission rather than actual RF digipeating.

For example, AE5PL-S packets posted by AE5PL via Internet will no longer
show a misleading RF path line between them.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-07 16:57:21 -05:00
93e19ff517
Remove all external dependencies and Sentry integration
- Remove external Leaflet CDN links from info page (now uses vendor bundles)
- Remove all Sentry error tracking integration:
  - Remove sentry dependency from mix.exs
  - Remove Sentry plugs from endpoint.ex
  - Remove Sentry logger handler from application.ex
  - Remove Sentry configs from dev.exs and prod.exs
  - Remove Sentry domains from runtime.exs check_origin
  - Remove Sentry JavaScript initialization
  - Delete sentry_filter.ex module
  - Remove Sentry loader script from root layout

The application now loads all assets locally with no external runtime dependencies.
2025-10-03 12:53:47 -05:00
5ca07bcbe0
Fix info page to show last known position when latest packet has no location data
For stations that send both position and status packets, the info page would show empty location data if the most recent packet was a status packet. This fix ensures the page displays the last known position from the most recent position packet while still showing the latest activity timestamp.
2025-10-03 12:37:45 -05:00
577d05b4ee
Fix posresolution type error by converting integers to floats
Add posresolution and rain_midnight to the list of float fields in
normalize_numeric_types to ensure integer values are converted to floats
before database insertion. This fixes the Ecto.ChangeError that was
preventing many APRS packets from being stored in the database.
2025-09-08 09:20:40 -05:00
c2fcf534dd
update and format 2025-08-13 09:39:39 -05:00
282948db98
fix: resolve Chart.js date adapter error for weather charts
- Combine Chart.js and date adapter into single bundle to ensure proper loading order
- Add validation to skip chart rendering when insufficient weather data (< 2 points)
- Update vendor loader to not load date adapter separately
- Prevents date adapter errors when weather stations have limited data
2025-08-09 17:20:27 -04:00
706721b06f
fix: resolve VARCHAR(255) database errors by migrating to TEXT fields
- Create migration to change string fields from VARCHAR(255) to TEXT type
- Add PacketSanitizer module for UTF-8 safe string truncation
- Update PacketConsumer to sanitize data before database insertion
- Prevents database errors from overly long packet data fields
2025-08-09 16:54:38 -04:00
01bfb11ab4
fix: Convert integer timestamps to strings for database insertion
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 <noreply@anthropic.com>
2025-08-04 11:43:15 -05:00
b56a988e52
fix: Implement comprehensive field whitelist to prevent unknown field errors
Instead of playing whack-a-mole with individual fields, this implements a
proper whitelist approach that only allows fields defined in the Packet schema.

- Created PacketFieldWhitelist module with all 78 valid packet fields
- Filters out ANY field not in the schema, preventing future errors
- Handles both atom and string keys
- Includes debug helpers to identify filtered fields

This definitively fixes packet insertion failures by ensuring only valid
database fields are passed to Repo.insert_all, regardless of what the
APRS parser sends.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-04 10:52:53 -05:00
49e647e609
fix: Handle additional parser fields causing insertion failures
The parser is sending fields with different names than our schema:
- aprs_messaging? (with question mark) -> convert to aprs_messaging
- raw_data -> remove (not in schema)

This should fix the remaining packet insertion failures in production.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-04 10:30:52 -05:00
cd79c3df7e
feat: Add database support for APRS items/objects and DAO extension
- Added item_name, object_name fields to store names
- Added is_item, is_object boolean flags for filtering
- Added dao field to store DAO extension data for extra position precision
- Automatic detection during packet processing to populate these fields
- Added database indexes for efficient queries
- Now preserving itemname as item_name and dao data instead of discarding

This enables future features like:
- Showing/hiding items and objects separately from stations
- Querying for specific objects (events, repeaters, etc.)
- Using DAO data for high-precision applications

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-04 10:19:34 -05:00
b63c3c547d
fix: Add missing field removals for dao, itemname, and coordinate conversion
Production logs showed additional fields causing insertion failures:
- dao: DAO extension data
- itemname: Item name field
- longitude/latitude: Parser uses these but our schema uses lon/lat

Added conversion step to map latitude->lat and longitude->lon before processing.
This ensures packets can be properly saved to the database.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-04 10:16:23 -05:00
584402274c
fix: Remove all non-schema fields from parsed packets to fix database insertion
The updated APRS parser (commit 69d0ab5) adds several fields that don't exist in our database schema:
- type, digipeaters, daodatumbyte, mbits, message (duplicate of message_text)
- phg (we store individual PHG fields), wx (weather object)
- resultcode, resultmsg, gpsfixstatus

Created a centralized helper function to remove all non-schema fields before database insertion.
Also enhanced error logging to capture sample packet data for easier debugging.

This fixes the production issue where packets were failing to save to the database.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-04 09:33:37 -05:00
cc5b3ec027
fix: Handle string timestamps in weather view DateTime comparison
The weather view was crashing with FunctionClauseError when comparing
string timestamps with DateTime structs. This happens when packets are
broadcast with string timestamps instead of DateTime objects.

Changes:
- Add cases to handle when one timestamp is a string and the other is DateTime
- Parse ISO8601 string timestamps before comparison
- Append 'Z' to timestamps that don't have timezone info
- Fallback safely when parsing fails

This prevents crashes when the weather view receives packets with
mixed timestamp formats from different parts of the system.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-03 15:49:46 -05:00
9b147101e1
fix: Handle both atom and string keys in weather view packet comparison
The weather view was crashing with KeyError when receiving packets with
string keys instead of atom keys. This was happening when packets were
broadcast from different parts of the system.

Changes:
- Updated should_update_weather? to handle both atom and string keys
- Added proper nil checking for received_at timestamps
- Handle string timestamp comparisons as well as DateTime comparisons

This prevents crashes when the weather view receives packets with
inconsistent key types from PubSub broadcasts.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-03 15:46:12 -05:00
e6d8894bf6
fix: Handle numeric weather values and hide N/A fields in weather view
The weather view was crashing with CaseClauseError when receiving numeric
values (like 83.0) from the database instead of strings. Also improved
the UI to only show weather fields that have valid data.

Changes:
- Added support for numeric values in format_weather_value function
- Added has_weather_field? helper to check for valid weather data
- Updated template to conditionally display weather fields
- Fields with nil, "N/A", or empty values are now hidden
- Wind field shows direction and speed independently if available

This prevents crashes and provides a cleaner UI by only showing available
weather data instead of displaying N/A values.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-03 15:33:09 -05:00
fd60467da8
fix: Remove gpsfixstatus field from packet insertion to prevent database errors
The recent APRS parser update added a gpsfixstatus field that doesn't exist
in our database schema. This was causing all packet insertions to fail in
production with ArgumentError, preventing any packets from being stored and
making historical packet loading impossible.

Changes:
- Added explicit removal of :gpsfixstatus field in packet_consumer.ex
- Added both atom and string key deletion for safety
- Placed removal alongside other field removals like raw_weather_data

This fixes the critical production issue where no packets were being stored,
which prevented historical packet loading from working.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-03 15:29:24 -05:00
9b207e0d67
updates with parser updates 2025-08-03 09:19:31 -05:00
1e7817646b
perf: Implement performance optimizations without caching
- Optimized list concatenation in PacketConsumer from O(n) to O(1) by prepending events
- Refactored coordinate rounding to avoid recreating anonymous functions on each call
- Added database indexes for case-insensitive searches on upper(sender) and upper(base_callsign)
- Implemented RegexCache to avoid recompiling regex patterns for wildcard device matching
- Added compound index on upper(sender) with received_at for efficient sorted queries

These changes improve performance in hot paths:
- Packet batching is now more efficient with better list operations
- Coordinate processing avoids function allocation overhead
- Database queries using UPPER() now use functional indexes
- Device wildcard matching no longer recompiles regex on every lookup

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-02 09:36:50 -05:00
ed96877384
fix: Historical packets now load on initial page load for all users
- Fixed issue where historical packets were only loaded when tracking a specific callsign
- Changed needs_initial_historical_load to always be true on mount
- Added comprehensive test suite for historical packet loading scenarios
- Tests verify loading with/without tracked callsign, custom time ranges, and zoom-based limits
- Ensures users see recent activity immediately when visiting the map

Also fixed JavaScript error about enabledFeatures being undefined - this was from a browser extension, not the application code.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-02 09:27:23 -05:00
a9ad057efc
feat: Update code to handle improved APRS parser features
- Added 20 new database fields for enhanced parser compatibility:
  - Standard parser fields: srccallsign, dstcallsign, body, origpacket, header, alive, posambiguity, symboltable, symbolcode, messaging
  - Radio range field: radiorange
  - Additional weather fields: rain_midnight, has_weather
- Enhanced weather data extraction with dedicated wx field support
- Updated PHG parsing to handle both string format ("1060") and legacy map structure
- Added extraction functions for standard parser compatibility fields
- Created comprehensive test suite for enhanced parser functionality
- Updated APRS parser to latest version with improved field extraction

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-01 18:16:44 -05:00
b5a39102a6
fix: Comprehensive packet processing and test optimization improvements
This commit includes several critical fixes and optimizations:

## Production Buffer Overflow Fix
- Fixed telemetry_vals data type conversion from strings to integers
- Enhanced put_telemetry_fields() with robust type conversion logic
- Handles mixed data types (string, integer, float) gracefully
- Prevents PacketConsumer GenServer crashes that caused buffer overflow
- Processes telemetry from both data_extended and top-level attrs

## Test Suite Performance Optimization
- Improved test execution speed by 48% (43.2s → 24.1s)
- Increased parallelization: max_cases from 16 to 48
- Optimized database connections and reduced timeouts
- Tagged slow tests and exclude them by default for fast development
- Fixed device seeding to only run when needed
- Enhanced log capture for packet consumer tests

## Code Quality Improvements
- Fixed handle_info clause grouping in LeaderElection
- Ensures mix compile --warnings-as-errors passes
- Added comprehensive telemetry conversion tests
- Improved test reliability and reduced flakiness

## Infrastructure Updates
- Added migration init container to StatefulSet for automatic schema updates
- Disabled AUTO_MIGRATE in main container (handled by init container)
- Created .test-commands with helpful test aliases

This resolves production stability issues and significantly improves development workflow.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-01 17:50:07 -05:00
21e395ec62
fix: Group handle_info clauses together in LeaderElection
Fixes compilation warning by moving the catch-all handle_info/2 clause
to be immediately after the specific handle_info/2 clauses.

In Elixir, all function clauses with the same name and arity must be
grouped together for pattern matching to work correctly.

This resolves the 'mix compile --warnings-as-errors' failure.
2025-08-01 17:49:04 -05:00
6bfea84b88
fix: Convert telemetry_vals strings to integers to prevent buffer overflow
Fixes production crashes where PacketConsumer GenServers were failing due to
attempting to insert string arrays like ['12.80', '0.00', ...] into an
integer array database field. This was causing buffer overflow as crashed
consumers couldn't process packets.

Changes:
- Enhanced put_telemetry_fields() to convert string/float telemetry values to integers
- Added robust handling for mixed data types (string, integer, float)
- Added graceful fallback for invalid values (converts to 0)
- Process telemetry from both data_extended and top-level attrs
- Added comprehensive tests for all conversion scenarios

This resolves the GenServer crashes and prevents packet processing buffer issues.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-01 17:47:31 -05:00
1690b0974e
test: Add comprehensive tests for cluster modules
- Add LeaderElection tests covering initialization, election, and leadership changes
- Add ConnectionManager tests covering APRS connection lifecycle management
- Fix LeaderElection to handle unknown messages gracefully
- Tests handle complex GenServer interactions and cleanup scenarios
- Increases test coverage for critical clustering functionality

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-01 17:29:20 -05:00
d06ec8b13d
test: Add comprehensive test suite for Aprsme.Packets module
- Add tests for store_packet/1 functionality including validation, MicE data, and error handling
- Add tests for store_bad_packet/2 with proper error type conversion
- Add tests for get_recent_packets/1 with time, bounds, and callsign filtering
- Add tests for get_nearby_stations/4 with distance ordering and exclusions
- Add tests for weather packet queries and cleanup functions
- Add tests for packet replay, streaming, and counting operations
- Fix MicE struct access to use Access behavior instead of dot notation
- Fix error_type conversion to string for BadPacket storage
- Ensure all tests are passing (437 tests, 0 failures)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-01 17:18:39 -05:00
179e2e407d
fix: Convert telemetry_seq string values to integers
The APRS parser returns telemetry sequence numbers as strings (e.g., "094"),
but the database schema expects integers. This was causing Ecto.ChangeError
in production when processing telemetry packets.

Changes:
- Updated put_telemetry_fields/2 to convert string seq values to integers
- Added comprehensive tests for telemetry_seq type conversion
- Handles nil, string, integer, and invalid seq values gracefully

Production deployment notes:
1. Check if migration 20250801215236 has run in production
2. If not, run pending migrations before deploying this fix

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-01 17:12:47 -05:00
5ddbb18a10
fix: Handle atom format field from APRS parser
The APRS parser sometimes returns :unknown as an atom for the format field,
but the database expects a string. This was causing Ecto.ChangeError when
inserting packets.

Added normalize_format_field/1 function to convert atom values to strings
before database insertion. This ensures compatibility between the parser
output and database schema requirements.

Fixes error: value `:unknown` for `Aprsme.Packet.format` in `insert_all`
does not match type :string

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-01 17:04:32 -05:00
86d3837075
feat: Add support for enhanced APRS parser features
- Added position resolution field (posresolution) showing accuracy in meters
  - 18.52m for uncompressed positions
  - 0.291m for compressed positions
- Added format field indicating "compressed" or "uncompressed" position type
- Added telemetry support with three new fields:
  - telemetry_seq: sequence number
  - telemetry_vals: array of telemetry values
  - telemetry_bits: binary telemetry bits
- Updated packet schema and database migration
- Enhanced packet extraction logic to handle new fields
- All tests pass successfully

These improvements provide better position accuracy information and
enable telemetry packet processing from APRS stations.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-01 16:57:28 -05:00