mirror of
https://github.com/muety/wakapi.git
synced 2023-08-10 21:12:56 +03:00
fix: fix divide by zero (resolve #189)
This commit is contained in:
parent
0a07ac1dd4
commit
4ab657ebd5
@ -2,6 +2,7 @@ package v1
|
||||
|
||||
import (
|
||||
"github.com/muety/wakapi/models"
|
||||
"math"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -30,6 +31,9 @@ type StatsData struct {
|
||||
func NewStatsFrom(summary *models.Summary, filters *models.Filters) *StatsViewModel {
|
||||
totalTime := summary.TotalTime()
|
||||
numDays := int(summary.ToTime.T().Sub(summary.FromTime.T()).Hours() / 24)
|
||||
if math.IsInf(float64(numDays), 0) {
|
||||
numDays = 0
|
||||
}
|
||||
|
||||
data := &StatsData{
|
||||
Username: summary.UserID,
|
||||
|
Loading…
Reference in New Issue
Block a user