Add a "Best DX" card to the logbook Stats tab (furthest station worked)#673
Merged
Merged
Conversation
Show operators the furthest station they've worked, measured great-circle from their configured Maidenhead grid, as a highlight card on the Logbook > Stats tab (callsign + distance in the user's preferred unit + grid). Every logged QSO already carries a grid, so this needs no new data — just a reduction over the log. The selection logic is a pure, JVM-only helper (computeBestDx) that takes an injected grid->distance function, so it's unit-tested without Robolectric. It skips records with a blank callsign/grid, an unparseable grid, or a non-positive/NaN distance (the last mirrors MaidenheadGrid's 0-km result for two stations sharing a grid — a floor, never a best DX), and the card only renders once there's a measurable contact (operator grid set + at least one parseable logged grid). Follows the existing extract-pure-helper pattern (gridSquaresWorked / workedGridFields) and reuses MaidenheadGrid.getDist/formatDist for unit-aware display. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #673 +/- ##
============================================
+ Coverage 36.73% 36.76% +0.03%
- Complexity 197 211 +14
============================================
Files 216 219 +3
Lines 26882 27102 +220
Branches 3284 3332 +48
============================================
+ Hits 9876 9965 +89
- Misses 16781 16901 +120
- Partials 225 236 +11
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Adds a Best DX highlight card to Logbook → Stats, showing the furthest station the operator has worked — callsign, distance (in their preferred mi/km), and grid — measured great-circle from their configured Maidenhead grid.
Seeing "what's the furthest I've ever worked?" is one of the first things an FT8/DX operator wants from a logbook, and it's a natural brag stat next to Total QSOs / DXCC / Zones. Every logged QSO already stores a grid, so this surfaces information the app already has — no new data, no schema change, no extra DB query (it reduces over the records already loaded for the Stats tab).
How it looks
The card sits right below the four big stat cards (Total QSOs / DXCC / CQ / ITU), before the band distribution donut:
It only appears once there's something measurable — i.e. the operator's own grid is configured and at least one logged QSO has a parseable grid. No grid set → the section is hidden (no empty header).
Implementation
computeBestDx(records, distanceKm)— a pure, top-levelinternalreducer that takes an injected grid→distance function and returns the furthestBestDx(callsign, grid, distanceKm). It skips records with a blank callsign/grid, an unparseable grid, or a non-positive/NaNdistance (the last mirrorsMaidenheadGrid's 0-km result for two stations sharing a grid — a distance floor, never a "best DX").BestDxCardis a thin wrapper; the screen passes aMaidenheadGrid.getDist(myGrid, …)-backed lambda and renders the distance withMaidenheadGrid.formatDist(unit-aware).gridSquaresWorked/workedGridFields, so the decision logic is unit-testable without Robolectric.Tests
New
BestDxTest(7 plain-JVM cases): furthest wins, empty log → null, unparseable/blank grids skipped, blank callsign skipped, nothing-measurable → null, 0 km andNaNdistances skipped, callsign/grid trimmed.Verification
./gradlew :app:testDebugUnitTest --tests 'radio.ks3ckc.ft8af.ui.logbook.*'— green (BestDxTest 7/7, no regressions in the logbook suite)../gradlew :app:assembleDebug— BUILD SUCCESSFUL (full native + APK).Scope / compatibility
Display-only addition to the Stats tab. No change to decoding, transmit, CAT, or the FT8 protocol path. One new string (
log_section_best_dx); other locales fall back to the default, consistent with recent stats additions.🤖 Generated with Claude Code