Skip to content

Commit 9fd869c

Browse files
committed
use the new Find method of QSOList to include worked callsigns into the
supercheck
1 parent dff2c14 commit 9fd869c

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

core/callinfo/callinfo.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ type CallHistoryFinder interface {
2929
}
3030

3131
// DupeChecker can be used to find out if the given callsign was already worked, according to the contest rules.
32+
// It can also find worked callsigns that are similar to a given string, e.g. for supercheck.
3233
type DupeChecker interface {
3334
FindWorkedQSOs(callsign.Callsign, core.Band, core.Mode) ([]core.QSO, bool)
35+
Find(string) ([]core.AnnotatedCallsign, error)
3436
}
3537

3638
// Valuer provides the points and multis of a QSO based on the given information.

core/callinfo/supercheck.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,15 @@ func (s *Supercheck) Calculate(input string, band core.Band, mode core.Mode) []c
6464
}
6565

6666
func (s *Supercheck) findMatchingCallsigns(input string) map[callsign.Callsign]core.AnnotatedCallsign {
67-
// TODO: include the worked QSOs in the search?
68-
if s.callsigns == nil || s.history == nil {
67+
if s.dupes == nil || s.callsigns == nil || s.history == nil {
6968
return map[callsign.Callsign]core.AnnotatedCallsign{}
7069
}
7170

7271
normalizedInput := normalizeInput(input)
72+
dupeMatches, err := s.dupes.Find(normalizedInput)
73+
if err != nil {
74+
dupeMatches = []core.AnnotatedCallsign{}
75+
}
7376
scpMatches, err := s.callsigns.Find(normalizedInput)
7477
if err != nil {
7578
scpMatches = []core.AnnotatedCallsign{}
@@ -79,10 +82,20 @@ func (s *Supercheck) findMatchingCallsigns(input string) map[callsign.Callsign]c
7982
historicMatches = []core.AnnotatedCallsign{}
8083
}
8184

82-
result := make(map[callsign.Callsign]core.AnnotatedCallsign, len(scpMatches)+len(historicMatches))
83-
for _, match := range scpMatches {
85+
result := make(map[callsign.Callsign]core.AnnotatedCallsign, len(dupeMatches)+len(scpMatches)+len(historicMatches))
86+
for _, match := range dupeMatches {
8487
result[match.Callsign] = match
8588
}
89+
for _, match := range scpMatches {
90+
var annotatedCallsign core.AnnotatedCallsign
91+
storedCallsign, found := result[match.Callsign]
92+
if found {
93+
annotatedCallsign = storedCallsign
94+
} else {
95+
annotatedCallsign = match
96+
}
97+
result[annotatedCallsign.Callsign] = annotatedCallsign
98+
}
8699
for _, match := range historicMatches {
87100
var annotatedCallsign core.AnnotatedCallsign
88101
storedCallsign, found := result[match.Callsign]

0 commit comments

Comments
 (0)