Files
OpsLog/internal/qso/callmatch_test.go
T
rouggy 642ed358c2 feat(worked): fold portable callsigns into the worked-before history
Typing RK3DWA found nothing while RK3DWA/3 found 21 QSOs, so a station's
history was only visible if you happened to type the exact form it had been
logged under — and an operator who worked it as /0, /P or /MM saw none of it.
The other RDA tools and Log4OM fold these together; this does too.

The predicate strips the suffix from what was typed and matches "call = base OR
call LIKE base/%", so it works from either end: the base call finds the portable
QSOs and a portable call finds the plain ones. Deliberately not a bare prefix
LIKE 'RK3DWA%', which would also match RK3DWAB — a different station. The '/' is
what makes it the same operator.

Settings -> General to turn it off. Default ON, hence the inverted storage: an
existing install has no key, and reading that as OFF would leave everyone with
the behaviour we were asked to change.

Contest dupe checking is untouched — it runs through ContestDupe, a separate
binding, and stays an exact match as a contest requires.
2026-08-08 23:24:23 +02:00

35 lines
1.3 KiB
Go

package qso
import "testing"
// The predicate behind "Worked before". Exact when folding is off; with it on,
// a station's portable forms are one operator — and the fold has to work from
// either end, because you may type the base call or the portable one.
func TestCallMatch(t *testing.T) {
if pred, args := callMatch("RK3DWA", false); pred != "callsign = ?" || len(args) != 1 || args[0] != "RK3DWA" {
t.Errorf("exact: got %q %v", pred, args)
}
// Typing the base call: match it and everything suffixed off it.
pred, args := callMatch("RK3DWA", true)
if pred != "(callsign = ? OR callsign LIKE ?)" {
t.Errorf("variants predicate = %q", pred)
}
if len(args) != 2 || args[0] != "RK3DWA" || args[1] != "RK3DWA/%" {
t.Errorf("variants args = %v, want [RK3DWA RK3DWA/%%]", args)
}
// Typing a portable form must reach the plain call too — the suffix is
// stripped from the INPUT, not just matched in the column.
_, args = callMatch("RK3DWA/3", true)
if len(args) != 2 || args[0] != "RK3DWA" || args[1] != "RK3DWA/%" {
t.Errorf("portable input args = %v, want [RK3DWA RK3DWA/%%]", args)
}
// A leading slash is not a suffix marker — dropping to "" there would match
// the entire logbook.
if _, args := callMatch("/RK3DWA", true); args[0] != "/RK3DWA" {
t.Errorf("leading slash: args[0] = %v, want the call unchanged", args[0])
}
}