fix: bugs
This commit is contained in:
+28
-8
@@ -1993,6 +1993,13 @@ type SlotStats struct {
|
||||
SlotsConfirmed int `json:"slots_confirmed"` // distinct DXCC × band × class, confirmed
|
||||
DXCCWorked int `json:"dxcc_worked"` // distinct DXCC entities worked
|
||||
DXCCConfirmed int `json:"dxcc_confirmed"` // distinct DXCC entities confirmed
|
||||
// Per-class slot breakdown (Phone / CW / Digital) so the numbers are checkable.
|
||||
PHWorked int `json:"ph_worked"`
|
||||
PHConfirmed int `json:"ph_confirmed"`
|
||||
CWWorked int `json:"cw_worked"`
|
||||
CWConfirmed int `json:"cw_confirmed"`
|
||||
DIGWorked int `json:"dig_worked"`
|
||||
DIGConfirmed int `json:"dig_confirmed"`
|
||||
}
|
||||
|
||||
// GetSlotStats computes the worked/confirmed slot and DXCC tallies in one pass.
|
||||
@@ -2008,6 +2015,9 @@ func (r *Repo) GetSlotStats(ctx context.Context) (SlotStats, error) {
|
||||
defer rows.Close()
|
||||
dxccW, slotW := map[int]bool{}, map[string]bool{}
|
||||
dxccC, slotC := map[int]bool{}, map[string]bool{}
|
||||
// Per-class distinct slots (worked "w" / confirmed "c").
|
||||
clsW := map[string]map[string]bool{"PH": {}, "CW": {}, "DIG": {}}
|
||||
clsC := map[string]map[string]bool{"PH": {}, "CW": {}, "DIG": {}}
|
||||
for rows.Next() {
|
||||
var dxcc, conf int
|
||||
var band, mode string
|
||||
@@ -2017,19 +2027,29 @@ func (r *Repo) GetSlotStats(ctx context.Context) (SlotStats, error) {
|
||||
if dxcc == 0 {
|
||||
continue
|
||||
}
|
||||
key := SlotClassKey(dxcc, band, mode)
|
||||
dxccW[dxcc] = true
|
||||
if band != "" {
|
||||
slotW[key] = true
|
||||
}
|
||||
if conf == 1 {
|
||||
dxccC[dxcc] = true
|
||||
if band != "" {
|
||||
slotC[key] = true
|
||||
}
|
||||
}
|
||||
if band == "" {
|
||||
continue // no band → counts for DXCC but not for a slot
|
||||
}
|
||||
key := SlotClassKey(dxcc, band, mode)
|
||||
cl := modeClass(mode)
|
||||
slotW[key] = true
|
||||
clsW[cl][key] = true
|
||||
if conf == 1 {
|
||||
slotC[key] = true
|
||||
clsC[cl][key] = true
|
||||
}
|
||||
}
|
||||
return SlotStats{SlotsWorked: len(slotW), SlotsConfirmed: len(slotC), DXCCWorked: len(dxccW), DXCCConfirmed: len(dxccC)}, rows.Err()
|
||||
return SlotStats{
|
||||
SlotsWorked: len(slotW), SlotsConfirmed: len(slotC),
|
||||
DXCCWorked: len(dxccW), DXCCConfirmed: len(dxccC),
|
||||
PHWorked: len(clsW["PH"]), PHConfirmed: len(clsC["PH"]),
|
||||
CWWorked: len(clsW["CW"]), CWConfirmed: len(clsC["CW"]),
|
||||
DIGWorked: len(clsW["DIG"]), DIGConfirmed: len(clsC["DIG"]),
|
||||
}, rows.Err()
|
||||
}
|
||||
|
||||
// confirmedCols whitelists the received-status columns ConfirmedSlots may
|
||||
|
||||
Reference in New Issue
Block a user