- accounts.ex: replace validate_user_password (if-based) with with-chain;
drop unnecessary try/rescue around Repo.get_by. Extract transaction_unwrap
helper to eliminate 3 copies of the Multi result-unwrap case block.
- packets.ex: deduplicate store_bad_packet by extracting raw_packet_string,
extract_error_type, and extract_error_message into composable helpers.
Normalize find_coordinate_value — collapse 12 clauses into a generic
deep_get/direct_get that handles atom/string keys and nested maps uniformly.
- data_builder.ex: split build_simple_popup into separate data-construction
(build_simple_popup_data) and rendering (render_popup) phases, eliminating
duplicated PopupComponent/Safe/IO pipelines.
- param_utils.ex: unify parse_float_in_range and parse_int_in_range via a
shared parse_in_range that accepts Float.parse/Integer.parse as a function
parameter — functions-as-values pattern.
Remove redundant in-memory sort (DB already orders), shortcut get_packet_field when field found at top level, use pre-computed has_weather boolean instead of field-by-field scan
Ultraworked with Sisyphus
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
- consolidate Haversine: CoordinateUtils delegates to GeoUtils;
InfoLive.haversine/4 reuses it (m -> km)
- AprsSymbol: collapse 3 sprite-info builders onto build_sprite_info/2
and add a sprite_info @type
- DataBuilder: 3 weather unit converters share convert_unit/4 with
explicit clauses for "N/A", numeric, and binary inputs
- mobile_channel: do_callsign_match/2 uses pattern-match clauses for
wildcard handling instead of nested if
- info_live: replace nested case in position_changed? with multi-clause
coords_changed?/1; format_timestamp_for_display pipelines into a
guarded build_timestamp_display/1
- api_docs_live: collapse chained single-key assigns into keyword-list
assign/2 calls
- add strict @spec coverage on all touched helpers; tighten new specs to
match dialyzer success typing (no contract_supertype warnings)
- get_coordinates_from_mic_e: replace two inline `if direction == ...`
rebinds with a reusable apply_hemisphere_sign/3 helper; the final
range check becomes maybe_return_coords/2 with a guarded clause that
yields {lat, lon} or {nil, nil}.
- has_position_data?: the boolean short-circuit collapses from an
explicit if/else to a single `or` expression.
All 37 CoordinateUtils tests (4 properties) still pass.
- CoordinateUtils.normalize_longitude / normalize_latitude: recursion
and clamping move into the function head via numeric guards.
- Shared.PacketUtils.map_label: dispatch on data_type + fallback via
multi-clause helpers (map_label_for/2, prefer_name/2) instead of a
three-branch cond with inner `if`s.
- MapLive.DataBuilder.get_received_at: pattern-match the atom- and
string-key packet shapes in the function head.
No behavior change; all 1567 tests and 27 property checks still pass,
dialyzer remains clean.
- SharedPacketHandler.handle_packet_update: dispatch on filter-result,
and use maybe_enrich/2 dispatched on the enrich? boolean instead of
an inner `if`. lookup_device_info/1 is now a trio of function heads.
- Cluster.Topology.child_spec: build_spec/3 dispatches on
(cluster_enabled?, topologies) tuples — no more nested `if`.
- Cluster.PacketDistributor.distribute_packet: maybe_broadcast/2
dispatches on the leader-and-enabled check; the non-leader / disabled
paths return :ok explicitly instead of relying on an `if` expression's
implicit nil.
Adds tests for SharedPacketHandler (filter/enrich/match paths,
callsign_filter + callsign_and_weather_filter factories) and extends
Cluster.Topology tests to cover the nil-topology and opts-merge cases.
Coverage 66.41 → 66.81%.
Turned on :error_handling, :underspecs, and :unmatched_returns in
mix.exs dialyzer config. The 97 warnings this surfaced were fixed in
place rather than suppressed:
- unmatched_return (79): explicit discard with `_ = ...` for
fire-and-forget side effects (Process.cancel_timer, :ets.new,
send/2), and pattern-matched `:ok = ...` for control-plane
Phoenix.PubSub subscribe/unsubscribe/broadcast calls so a future
return-shape change fails loud.
- contract_supertype (18): tightened @spec arg and return types on
data_builder, historical_loader, url_params, packet_utils,
encoding_utils, aprs_symbol, weather_controller, packet_replay to
match each function's actual success typing.
No behavioural change. mix compile clean, 1008 tests pass, dialyzer
count is now 0.
Added proper latitude/longitude normalization to prevent invalid coordinates:
- Longitude now wraps to -180 to 180 range (e.g., 199.0 -> -161.0)
- Latitude now clamps to -90 to 90 range
- Applied normalization before creating geometry in Packet module
Fixed 7 existing packets with invalid coordinates:
- WB6WWJ-N: 199.0 -> -161.0
- BI7MCK-1: 320.3 -> -39.7
This prevents map display issues and ensures PostGIS spatial queries
work correctly.
Objects and items now display with their own names on the map instead of
the originating station's callsign. This prevents confusion where stations
creating objects (like repeaters) appear at multiple locations.
For example, CALGRY creates repeater objects (147.06-WC, 146.85-NH) which
were appearing on the map labeled as "CALGRY" at the repeater locations
instead of showing the actual object names.
Changes:
- Updated map_label() to return object_name for object packets
- Updated map_label() to return item_name for item packets
- Position packets continue to show the sender callsign
- Updated tests to expect object/item names instead of sender
This matches APRS.fi behavior where objects are displayed separately
from their originating station.
- Strip Mic-E telemetry from comments before database storage
- Show sender callsign on map labels instead of object names for clarity
- Object names still used for grouping to maintain trail organization
- Add comprehensive tests for new encoding utilities
Fixes display issues where weather balloon "X3234025" was shown
instead of station "WA0YMH", and Mic-E telemetry bytes like "!w>`!"
were appearing in comments.
Drop 10 dead parser-compat columns (srccallsign, dstcallsign,
origpacket, body, header, alive, posambiguity, symboltable,
symbolcode, messaging) and move 14 display-only columns into a
single `data` JSONB column (PHG, telemetry, radiorange,
information_field, format, posresolution, position_ambiguity,
luminosity, rain_midnight).
Reduces row width from ~70 to ~48 columns. Table is ephemeral
so migration uses DROP/recreate. Also fixes snow_24h -> snow bug
in weather check query and adds null byte stripping for JSONB
string sanitization.
APRS object packets (e.g. DAPNET transmitters) were showing the
sender's callsign on the map instead of the object name. For example,
DB0SDA (Germany) sending an object for P-K5SGD (Texas) would display
as "DB0SDA" at the Texas coordinates.
- Add display_name/1 to PacketUtils that returns object_name for
objects, item_name for items, falling back to sender
- Update DataBuilder to use display_name in all callsign display paths
- Fix object/item detection order in packet_consumer to prevent
objects from being incorrectly flagged as items
- Add DataBuilder tests for object/item display name behavior
- Fix flaky PacketPipelineSupervisor test (ensure module loaded)
Replace case/cond/if blocks with multi-clause function dispatch
and pattern matching in function heads across 9 modules:
- WeatherUnits: case to multi-clause unit_system/1, unit_labels via do_unit_labels/1
- PacketUtils: if to pattern match on %{"id" => id}, multi-clause threshold/callsign
- SetLocale: case to multi-clause extract_locale/1
- IPGeolocation: if/cond to pattern match on conn, binary prefix matching for private_ip?
- DeviceIdentification: cond to extracted pattern_matches?/2
- MobileChannel: cond to multi-clause do_callsign_match/2
- PacketProcessor: cond to dispatch_visibility/6 on {in_bounds, has_marker} tuple
- PacketManager: destructure packet_state in heads, multi-clause maybe_cleanup/3
- AprsSymbol: case/if to multi-clause get_table_id/1, normalize_symbol_code/1
- Handle both DateTime and NaiveDateTime structs from database
- Convert NaiveDateTime to UTC DateTime before formatting
- Add fallback for string timestamps
- Fixes FunctionClauseError when processing packets