@@ -64,12 +64,15 @@ func (s *Supercheck) Calculate(input string, band core.Band, mode core.Mode) []c
6464}
6565
6666func  (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