Add reset for global stats and fix wpm for stats

This commit is contained in:
qowevisa 2025-02-17 13:47:54 +02:00
parent a4e2062383
commit c8d4b9ef81
2 changed files with 9 additions and 1 deletions

View File

@ -24,7 +24,7 @@ func finish(start time.Time, stat *db.Stat, finished bool) {
stat.Words = globalStat.Words
stat.Finished = finished
stat.CPM = float64(globalStat.Correct) / past.Minutes()
stat.WPM = float64(globalStat.Words+1) / past.Minutes()
stat.WPM = float64(globalStat.Words) / past.Minutes()
stat.TimeTaken = past.Milliseconds()
fmt.Printf("\r\n%s", colorizer.Colors.Reset())
fmt.Print(past)
@ -176,5 +176,6 @@ outer:
log.Printf("ERROR: dbc.Create: %v", err)
}
}
globalStat.Reset()
}
}

View File

@ -8,3 +8,10 @@ type Stat struct {
}
var globalStat Stat
func (s *Stat) Reset() {
s.Skipped = 0
s.Correct = 0
s.False = 0
s.Words = 0
}