fix(awards): stale statistics, and the Challenge said out loud

Two things from one screenshot, and the second is arithmetic rather than a
bug.

Editing an award refreshed the grid and not the statistics matrix, so
changing which confirmations count left the table showing the old rule's
numbers with nothing to mark them stale. That is how a setting comes to
look as though it does nothing.

And OpsLog's 3229 against LoTW's 3004: the Challenge counts confirmed
band-slots on ten bands, and 60 m is not one of them. 3229 less the 224 in
the 60 m column is 3005. So the number was right and the QUESTION was
different — the panel now answers the Challenge one too, under the table
where the comparison is made.

The two totals also say what they are on hover. 'Total' and 'Général' side
by side tell nobody which counts entities and which counts band-slots, and
3309 read as entities is an impossible number — which is exactly how it
was read.
This commit is contained in:
2026-08-26 21:45:11 +02:00
parent 9c7983b13e
commit 4a28b51ade
3 changed files with 50 additions and 7 deletions
+42 -3
View File
@@ -40,6 +40,15 @@ type AwardStats = { code: string; bands: string[]; rows: AwardStatRow[] };
// two are kept apart because they answer different questions (that one sorts an
// award's own band counts, this one lays out columns), but a band added to one
// belongs in the other.
// The DXCC Challenge counts one point per CONFIRMED entity per band, over ten
// bands — and 60 m is NOT one of them. That is the whole of the gap an operator
// notices between OpsLog and LoTW: 3229 here against 3004 there, and 224 of the
// difference is the 60 m column.
//
// Worked out from the confirmed row rather than asked of the backend, because
// that row IS the answer: the Challenge is its sum over these ten bands.
const CHALLENGE_BANDS = ['160m', '80m', '40m', '30m', '20m', '17m', '15m', '12m', '10m', '6m'];
const ALL_BANDS = ['2190m','630m','160m','80m','60m','40m','30m','20m','17m','15m','12m','10m',
'6m','4m','2m','1.25m','70cm','33cm','23cm','13cm','9cm','6cm','3cm','1.25cm','6mm','4mm','2.5mm','2mm','1mm'];
@@ -225,6 +234,17 @@ export function AwardsPanel({ onEditQSO, onAwardsChanged, onPaperQSL }: {
return filtered.length ? filtered : GRID_BANDS;
}, [awardBands]);
const challenge = useMemo(() => {
if (!stats || selected.toUpperCase() !== 'DXCC') return null;
const row = stats.rows.find((r) => r.label === 'CONFIRMED');
if (!row) return null;
let total = 0;
stats.bands.forEach((b, i) => {
if (CHALLENGE_BANDS.includes(String(b).toLowerCase())) total += Number(row.cells[i]) || 0;
});
return total;
}, [stats, selected]);
// Stats rows to show: drop the mode-category rows (CW / DIGITAL / PHONE) the
// award doesn't cover. The "ALL" rows (no suffix) always show; a category row
// shows only when the award has no emission restriction or lists that emission.
@@ -344,7 +364,13 @@ export function AwardsPanel({ onEditQSO, onAwardsChanged, onPaperQSL }: {
{t('awp.rescan')}
</Button>
</div>
<AwardEditor open={editing} onClose={() => setEditing(false)} onSaved={() => { setByCode({}); loadList(); onAwardsChanged?.(); }} />
{/* setRescanTick as well as setByCode. The grid was refreshed on save
and the statistics matrix was not, so changing which confirmations
count — LoTW only, LoTW plus cards — left the whole table showing
the previous rule's numbers with nothing to say they were stale.
That is how a setting comes to look as though it does nothing. */}
<AwardEditor open={editing} onClose={() => setEditing(false)}
onSaved={() => { setByCode({}); setRescanTick((t) => t + 1); loadList(); onAwardsChanged?.(); }} />
{/* Quick selector — scales when there are many awards. */}
{awardList.length > 0 && (
<div className="px-2 py-2 border-b border-border/40">
@@ -498,8 +524,8 @@ export function AwardsPanel({ onEditQSO, onAwardsChanged, onPaperQSL }: {
<tr className="bg-card">
<th className="sticky left-0 z-20 bg-card text-left py-1.5 pr-3 font-medium border-b border-border">{t('awp.statistic')}</th>
{statsBandIdx.map((i) => <th key={stats.bands[i]} className="py-1.5 px-1 font-mono font-medium border-b border-border text-center w-11">{stats.bands[i]}</th>)}
<th className="py-1.5 px-2 font-medium border-b border-border text-center">{t('awp.total')}</th>
<th className="py-1.5 px-2 font-medium border-b border-border text-center">{t('awp.grand')}</th>
<th className="py-1.5 px-2 font-medium border-b border-border text-center" title={t('awp.totalHint')}>{t('awp.total')}</th>
<th className="py-1.5 px-2 font-medium border-b border-border text-center" title={t('awp.grandHint')}>{t('awp.grand')}</th>
</tr>
</thead>
<tbody>
@@ -518,6 +544,19 @@ export function AwardsPanel({ onEditQSO, onAwardsChanged, onPaperQSL }: {
);
})}
</tbody>
{challenge !== null && (
<tfoot>
<tr>
<td className="sticky left-0 bg-card py-1.5 pr-3 font-semibold whitespace-nowrap" title={t('awp.challengeHint')}>
{t('awp.challenge')}
</td>
<td colSpan={statsBandIdx.length} className="py-1.5 text-[11px] text-muted-foreground">
{t('awp.challengeBands')}
</td>
<td className="text-center py-1.5 px-2 font-mono font-bold text-success" colSpan={2}>{challenge}</td>
</tr>
</tfoot>
)}
</table>
)}
</div>