fix: stats By Continent donut totals now match the QSO count (bucket blank/unknown continents as 'Unknown' instead of dropping them; keep the Continents metric counting real continents only)
This commit is contained in:
@@ -392,8 +392,13 @@ func (r *Repo) Stats(ctx context.Context, from, to time.Time, contestID string,
|
|||||||
if st := strings.ToUpper(strings.TrimSpace(station.String)); st != "" {
|
if st := strings.ToUpper(strings.TrimSpace(station.String)); st != "" {
|
||||||
stationC[st]++
|
stationC[st]++
|
||||||
}
|
}
|
||||||
|
// Bucket a blank/unknown continent under "Unknown" rather than dropping it,
|
||||||
|
// so the continent breakdown totals the same as the QSO count (a handful of
|
||||||
|
// QSOs with no resolved continent made the donut read a few short).
|
||||||
if c := strings.ToUpper(strings.TrimSpace(cont.String)); c != "" {
|
if c := strings.ToUpper(strings.TrimSpace(cont.String)); c != "" {
|
||||||
contC[c]++
|
contC[c]++
|
||||||
|
} else {
|
||||||
|
contC["Unknown"]++
|
||||||
}
|
}
|
||||||
if c := strings.TrimSpace(country.String); c != "" {
|
if c := strings.TrimSpace(country.String); c != "" {
|
||||||
entityC[c]++
|
entityC[c]++
|
||||||
@@ -436,6 +441,9 @@ func (r *Repo) Stats(ctx context.Context, from, to time.Time, contestID string,
|
|||||||
s.UniqueCalls = len(calls)
|
s.UniqueCalls = len(calls)
|
||||||
s.Entities = len(entities)
|
s.Entities = len(entities)
|
||||||
s.Continents = len(contC)
|
s.Continents = len(contC)
|
||||||
|
if _, ok := contC["Unknown"]; ok {
|
||||||
|
s.Continents-- // "Unknown" is a catch-all bucket, not a real continent
|
||||||
|
}
|
||||||
if !first.IsZero() {
|
if !first.IsZero() {
|
||||||
s.FirstQSO = first.UTC().Format(time.RFC3339)
|
s.FirstQSO = first.UTC().Format(time.RFC3339)
|
||||||
s.LastQSO = last.UTC().Format(time.RFC3339)
|
s.LastQSO = last.UTC().Format(time.RFC3339)
|
||||||
|
|||||||
Reference in New Issue
Block a user