feat(details): NEW badge on a county never worked
The cluster already answers this question for a spot; the entry panel did
not answer it for the station actually being worked. A county hunter
needs to know before the QSO ends — by the time the county shows up in
the awards table the station is long gone.
qso.CountyWorked asks about one county instead of loading the whole
worked set, narrowed to the state so it stays a few dozen rows on a
remote MySQL. It compares through award.USCountyKey on both sides rather
than in SQL, because logged spellings vary ("Los Angeles" against
"LOS ANGELES, CA") and that key function is what resolves it everywhere
else.
An empty or non-US county is not "new" but unknown, and shows nothing: a
badge on a guess is worse than no badge.
This commit is contained in:
@@ -2061,6 +2061,41 @@ func (r *Repo) WorkedCountyKeys(ctx context.Context, keyFn func(state, cnty stri
|
||||
return out, rows.Err()
|
||||
}
|
||||
|
||||
// CountyWorked reports whether one US county has already been worked.
|
||||
//
|
||||
// It exists so the entry panel can flag a new county without loading the whole
|
||||
// worked-county set on every keystroke — the county arrives from a QRZ lookup,
|
||||
// which is exactly when the operator is deciding whether the contact is worth
|
||||
// chasing. The comparison goes through keyFn on both sides (rather than a SQL
|
||||
// equality) because logged county spellings vary — "Los Angeles" against
|
||||
// "LOS ANGELES, CA" — and the key function is what already resolves that
|
||||
// everywhere else.
|
||||
func (r *Repo) CountyWorked(ctx context.Context, state, cnty string, keyFn func(state, cnty string) string) (bool, error) {
|
||||
want := keyFn(state, cnty)
|
||||
if want == "" {
|
||||
return false, nil
|
||||
}
|
||||
// Narrowed to the one state: a few dozen rows, not the whole logbook.
|
||||
rows, err := r.db.QueryContext(ctx,
|
||||
`SELECT DISTINCT COALESCE(state,''), COALESCE(cnty,'') FROM qso
|
||||
WHERE dxcc IN (291,110,6) AND cnty IS NOT NULL AND cnty != ''
|
||||
AND upper(COALESCE(state,'')) = upper(?)`, strings.TrimSpace(state))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
defer rows.Close()
|
||||
for rows.Next() {
|
||||
var st, cn string
|
||||
if err := rows.Scan(&st, &cn); err != nil {
|
||||
return false, err
|
||||
}
|
||||
if keyFn(st, cn) == want {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
return false, rows.Err()
|
||||
}
|
||||
|
||||
// WorkedCallBandModeKeys returns the set of every worked "CALL|BAND|MODE" key
|
||||
// (all upper-cased), loaded in one pass. It backs the in-memory worked-index the
|
||||
// alert engine checks per cluster spot — a DB query per spot cannot keep up with
|
||||
|
||||
Reference in New Issue
Block a user