dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit 5cadb3274c68acc4f3aeec933669ac89cd12fb6f
parent 491df5e2ebcee425110fee9b04dfbb47c2338367
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Wed, 14 Jun 2023 06:08:54 -0700

fix possible division by 0

Diffstat:
Mpkg/web/handlers/interceptors/chess.go | 6++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/pkg/web/handlers/interceptors/chess.go b/pkg/web/handlers/interceptors/chess.go @@ -456,11 +456,13 @@ func (g *ChessGame) drawPlayerCard(key string, isBlack, isSpectator, isYourTurn, whiteAdvantage, whiteScore, blackAdvantage, blackScore := CalcAdvantage(game.Position()) const graphWidth = 800 - var columnWidth = 0 + var columnWidth = 1 var stats *AnalyseResult _ = json.Unmarshal(g.DbChessGame.Stats, &stats) if stats != nil { - columnWidth = graphWidth / len(stats.Scores) + if len(stats.Scores) > 0 { + columnWidth = utils.MinInt(graphWidth/len(stats.Scores), 1) + } } data := map[string]any{