Playtime: average over the days recorded, full bars for leaders under an hour

Busiest hours and the heatmap averaged over 30 days (4 weeks) even when
recording began yesterday; they now use only the days since it began, and
say so. Bars capped their scale at 1, so a leader with 0.5 h got half a
bar. The hours tile keeps a decimal under 10, and K/D shows - with no
kills or deaths yet.
This commit is contained in:
Astra 2026-10-04 22:24:37 +01:00
parent f659859d66
commit c7fbff0e43
4 changed files with 57 additions and 14 deletions

View file

@ -170,8 +170,12 @@ func TestPlaytimeDB(t *testing.T) {
for _, h := range o.ByHour {
byHour += h
}
if byHour < 3.3/30 || byHour > 3.7/30 { // 3.5 h spread over 30 days, rounded per hour
t.Fatalf("byHour adds up to %.3f, want about %.3f", byHour, 3.5/30)
// Recording began with Bravo's session 10 days ago, so 3.5 h spread over those 11 days.
if o.ByHourDays != 11 || o.HeatDays != 11 {
t.Fatalf("averaged over %d days (heatmap %d), want 11", o.ByHourDays, o.HeatDays)
}
if want := 3.5 / 11; byHour < want-0.05 || byHour > want+0.05 {
t.Fatalf("byHour adds up to %.3f, want about %.3f", byHour, want)
}
// Alpha on one day, Bravo on two days ten days apart.
players := 0