1
0
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:
Ferdinand Mütsch 2021-04-26 21:26:23 +02:00
parent 0a07ac1dd4
commit 4ab657ebd5

View File

@ -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,