Normalise floats (don't use Inf in JSON)

This commit is contained in:
Howl
2016-05-18 17:48:19 +02:00
parent 2afc557ef8
commit 330757ec78
2 changed files with 20 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ package v1
import (
"database/sql"
"math"
"strconv"
"strings"
"time"
@@ -129,6 +130,17 @@ type modeData struct {
PP int `json:"pp"`
GlobalLeaderboardRank int `json:"global_leaderboard_rank"`
}
func (m modeData) Normalise() modeData {
if math.IsInf(m.Level, 0) {
m.Level = 0
}
if math.IsInf(m.Accuracy, 0) {
m.Accuracy = 0
}
return m
}
type userFullResponse struct {
common.ResponseBase
userData