chore: release v0.25.9
This commit is contained in:
@@ -2691,6 +2691,51 @@ func (r *Repo) DedupeKeyIDs(ctx context.Context) (map[string]int64, error) {
|
||||
return out, rows.Err()
|
||||
}
|
||||
|
||||
// DedupeClassKey is DedupeKey with the mode collapsed to its CLASS (Phone / CW /
|
||||
// Digital).
|
||||
//
|
||||
// For matching a downloaded confirmation whose mode is not the one you logged.
|
||||
// LoTW does not hand back the submode it was given: a contact uploaded as FT4,
|
||||
// FT8 or anything else digital comes back as the mode GROUP, "DATA". Matched on
|
||||
// the exact string that is simply never equal, and the operator is told their
|
||||
// own QSO is not in their log — which is how a confirmed contact goes unrecorded.
|
||||
func DedupeClassKey(callsign, qsoDateMinute, band, mode string) string {
|
||||
return strings.ToUpper(callsign) + "|" + qsoDateMinute + "|" + strings.ToLower(band) + "|" + modeClass(mode)
|
||||
}
|
||||
|
||||
// DedupeClassKeyIDs is DedupeKeyIDs at mode-CLASS granularity, for the second
|
||||
// pass when the exact key misses.
|
||||
//
|
||||
// A key shared by more than one QSO maps to 0 — AMBIGUOUS, not "pick one". Two
|
||||
// contacts with the same station, on the same band, in the same minute, in two
|
||||
// digital modes is barely physical; but if it ever happens, stamping the
|
||||
// confirmation on whichever row the map happened to keep would be a silent
|
||||
// error in someone's award credit. Better to report it unmatched.
|
||||
func (r *Repo) DedupeClassKeyIDs(ctx context.Context) (map[string]int64, error) {
|
||||
rows, err := r.db.QueryContext(ctx, `
|
||||
SELECT id, callsign, substr(qso_date, 1, 16), band, mode
|
||||
FROM qso`)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
out := make(map[string]int64, 1024)
|
||||
for rows.Next() {
|
||||
var id int64
|
||||
var call, when, band, mode string
|
||||
if err := rows.Scan(&id, &call, &when, &band, &mode); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
k := DedupeClassKey(call, when, band, mode)
|
||||
if prev, seen := out[k]; seen && prev != id {
|
||||
out[k] = 0
|
||||
continue
|
||||
}
|
||||
out[k] = id
|
||||
}
|
||||
return out, rows.Err()
|
||||
}
|
||||
|
||||
// matchRef is one local QSO's time + id, for time-window confirmation matching.
|
||||
type matchRef struct {
|
||||
when time.Time
|
||||
|
||||
Reference in New Issue
Block a user