feat: New badges in cluster view for new Counties and new POTA
This commit is contained in:
@@ -2396,6 +2396,22 @@ func (a *App) migrateAwardDefs() {
|
||||
a.setSettingGlobal(keyAwardEditsSeeded, "1")
|
||||
}
|
||||
|
||||
// One-time: the US Counties award was briefly carried under the code
|
||||
// "USCOUNTIES" before being renamed to the official "USA-CA". Drop the orphan
|
||||
// (def + references) so the operator isn't left with a stale, empty duplicate.
|
||||
// It never shipped beyond development, so this is unconditional.
|
||||
for i := 0; i < len(migrated); i++ {
|
||||
if strings.EqualFold(strings.TrimSpace(migrated[i].Code), "USCOUNTIES") {
|
||||
migrated = append(migrated[:i], migrated[i+1:]...)
|
||||
i--
|
||||
changed = true
|
||||
if a.awardRefs != nil {
|
||||
_, _ = a.awardRefs.ReplaceAll(a.ctx, "USCOUNTIES", nil)
|
||||
}
|
||||
applog.Printf("awards: removed legacy USCOUNTIES award (renamed to USA-CA)")
|
||||
}
|
||||
}
|
||||
|
||||
// Reconcile with the catalog: awards ADDED since this operator last saved, and
|
||||
// shipped awards whose definition we have since FIXED (a higher Version). Both
|
||||
// must be written back, or the editor would keep showing the old set.
|
||||
@@ -4255,7 +4271,7 @@ func freeAwardCode(code string, taken map[string]int) string {
|
||||
// builtinRefsVersion is bumped whenever the built-in reference data changes
|
||||
// (e.g. the West Malaysia 155→299 fix) so existing installs re-seed the
|
||||
// derived lists. Bump this after correcting BuiltinRefs / the DXCC name table.
|
||||
const builtinRefsVersion = "3"
|
||||
const builtinRefsVersion = "5"
|
||||
|
||||
// seedBuiltinReferences populates the reference lists of built-in awards.
|
||||
// - First run (no version stored), or already up to date: seed only awards that
|
||||
@@ -12027,9 +12043,10 @@ func (a *App) GetClusterStatus() []cluster.ServerStatus {
|
||||
|
||||
// SpotQuery is one (call, band, mode) tuple sent for status colouring.
|
||||
type SpotQuery struct {
|
||||
Call string `json:"call"`
|
||||
Band string `json:"band"`
|
||||
Mode string `json:"mode"`
|
||||
Call string `json:"call"`
|
||||
Band string `json:"band"`
|
||||
Mode string `json:"mode"`
|
||||
POTARef string `json:"pota_ref,omitempty"` // park id if the spot is a POTA activation
|
||||
}
|
||||
|
||||
// SpotStatus is the per-tuple result. Status is one of:
|
||||
@@ -12051,6 +12068,12 @@ type SpotStatus struct {
|
||||
// (any band, any mode). Drives the per-call text highlight, in
|
||||
// addition to the entity-level Status (NEW / NEW BAND / …).
|
||||
WorkedCall bool `json:"worked_call"`
|
||||
// NewCounty/NewPOTA are ORTHOGONAL to Status: a station already worked for
|
||||
// its DXCC entity can still be a never-worked US county or POTA park. County
|
||||
// is resolved from the callsign via the offline ULS store (US only, and only
|
||||
// when that database has been downloaded); POTA from the spot's tagged park.
|
||||
NewCounty bool `json:"new_county"`
|
||||
NewPOTA bool `json:"new_pota"`
|
||||
}
|
||||
|
||||
// ClusterSpotStatuses takes a batch of spots and returns slot status for
|
||||
@@ -12095,6 +12118,10 @@ func (a *App) ClusterSpotStatuses(spots []SpotQuery) []SpotStatus {
|
||||
// "I've already QSO'd this exact station" even when the band/mode
|
||||
// makes the entity check say "new-band" or "new-slot".
|
||||
workedCalls, _ := a.qso.WorkedCallsigns(a.ctx)
|
||||
// Orthogonal dimensions: worked US counties (for the ULS callsign→county
|
||||
// lookup) and worked POTA parks. Both built once per batch.
|
||||
workedCounties, _ := a.qso.WorkedCountyKeys(a.ctx, award.USCountyKey)
|
||||
workedPOTA, _ := a.qso.WorkedPOTARefs(a.ctx)
|
||||
for i, q := range spots {
|
||||
out[i] = SpotStatus{
|
||||
Call: q.Call,
|
||||
@@ -12104,6 +12131,23 @@ func (a *App) ClusterSpotStatuses(spots []SpotQuery) []SpotStatus {
|
||||
if _, ok := workedCalls[strings.ToUpper(q.Call)]; ok {
|
||||
out[i].WorkedCall = true
|
||||
}
|
||||
// NEW POTA: the spot's tagged park, never worked before.
|
||||
if ref := strings.ToUpper(strings.TrimSpace(q.POTARef)); ref != "" {
|
||||
if _, done := workedPOTA[ref]; !done {
|
||||
out[i].NewPOTA = true
|
||||
}
|
||||
}
|
||||
// NEW COUNTY: resolve the callsign's home county from the offline ULS
|
||||
// store (US only; inert until downloaded) and flag if never worked.
|
||||
if a.uls != nil {
|
||||
if loc, ok := a.uls.Resolve(q.Call); ok {
|
||||
if key := award.USCountyKey(loc.State, loc.County); key != "" {
|
||||
if _, done := workedCounties[key]; !done {
|
||||
out[i].NewCounty = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if a.dxcc == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user