commit 36251b685a423e903f0b38371595ae2174c07ae1
parent cc66b8d11ae93375981bf2dc711d11a59a6ef715
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Sat, 17 Jun 2023 13:41:48 -0700
fix typo
Diffstat:
3 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/pkg/web/handlers/chess.go b/pkg/web/handlers/chess.go
@@ -117,7 +117,7 @@ func ChessHandler(c echo.Context) error {
return c.Render(http.StatusOK, "chess", data)
}
-func ChessGameAnalyseHandler(c echo.Context) error {
+func ChessGameAnalyzeHandler(c echo.Context) error {
key := c.Param("key")
db := c.Get("database").(*database.DkfDB)
g, err := interceptors.ChessInstance.GetGame(key)
@@ -130,7 +130,7 @@ func ChessGameAnalyseHandler(c echo.Context) error {
}
t := utils.ParseInt64OrDefault(c.QueryParam("t"), 15)
t = utils.Clamp(t, 1, 60)
- res, err := interceptors.AnalyseGame(game.String(), t)
+ res, err := interceptors.AnalyzeGame(game.String(), t)
if err != nil {
return c.String(http.StatusOK, err.Error())
}
@@ -218,11 +218,7 @@ func ChessGameStatsHandler(c echo.Context) error {
</form>`
data := map[string]any{
- "Key": key,
- "IsAnalysed": g.DbChessGame.AccuracyWhite != 0 && g.DbChessGame.AccuracyBlack != 0,
- "WhiteAccuracy": g.DbChessGame.AccuracyWhite,
- "BlackAccuracy": g.DbChessGame.AccuracyBlack,
- "CSRF": csrf,
+ "CSRF": csrf,
}
fns := template.FuncMap{
@@ -271,7 +267,7 @@ func ChessGameStatsHandler(c echo.Context) error {
moveIdx := currMoveIdx
const graphWidth = 800
- var stats *interceptors.AnalyseResult
+ var stats *interceptors.AnalyzeResult
_ = json.Unmarshal(g.DbChessGame.Stats, &stats)
if c.Request().Method == http.MethodPost {
diff --git a/pkg/web/handlers/interceptors/chess.go b/pkg/web/handlers/interceptors/chess.go
@@ -485,7 +485,7 @@ func (g *ChessGame) drawPlayerCard(moveIdx int, key string, isBlack, isSpectator
<td colspan="2">
<div style="color: #eee; display: inline-block;">Outcome: <span id="outcome"></span></div>
{{ if and .GameOver .IsAdmin }}
- <a style="color: #eee;" href="/chess/{{ .Key }}/analyse">Analyse</a>
+ <a style="color: #eee;" href="/chess/{{ .Key }}/analyze">Analyze</a>
{{ end }}
</td>
</tr>
@@ -494,7 +494,7 @@ func (g *ChessGame) drawPlayerCard(moveIdx int, key string, isBlack, isSpectator
<tr>
<td colspan="2">
<iframe name="iframeStats" src="/chess/{{ .Key }}/stats" style="width: 100%; height: 240px; margin: 10px 0; border: 3px solid black;"></iframe>
- {{ if .IsAnalysed }}
+ {{ if .IsAnalyzed }}
<div style="color: #eee;">White accuracy: <span id="white-accuracy">{{ .WhiteAccuracy | pct }}</span></div>
<div style="color: #eee;">Black accuracy: <span id="black-accuracy">{{ .BlackAccuracy | pct }}</span></div>
{{ end }}
@@ -516,7 +516,7 @@ func (g *ChessGame) drawPlayerCard(moveIdx int, key string, isBlack, isSpectator
const graphWidth = 800
var columnWidth = 1
- var stats *AnalyseResult
+ var stats *AnalyzeResult
_ = json.Unmarshal(g.DbChessGame.Stats, &stats)
var bestMove *chess.Move
if stats != nil {
@@ -551,7 +551,7 @@ func (g *ChessGame) drawPlayerCard(moveIdx int, key string, isBlack, isSpectator
"WhiteScore": whiteScore,
"BlackAdvantage": blackAdvantage,
"BlackScore": blackScore,
- "IsAnalysed": g.DbChessGame.AccuracyWhite != 0 && g.DbChessGame.AccuracyBlack != 0,
+ "IsAnalyzed": g.DbChessGame.AccuracyWhite != 0 && g.DbChessGame.AccuracyBlack != 0,
"WhiteAccuracy": g.DbChessGame.AccuracyWhite,
"BlackAccuracy": g.DbChessGame.AccuracyBlack,
"Stats": stats,
@@ -913,13 +913,13 @@ type Score struct {
Mate int
}
-type AnalyseResult struct {
+type AnalyzeResult struct {
WhiteAccuracy float64
BlackAccuracy float64
Scores []Score
}
-func AnalyseGame(pgn string, t int64) (out AnalyseResult, err error) {
+func AnalyzeGame(pgn string, t int64) (out AnalyzeResult, err error) {
// https://github.com/lichess-org/lila/blob/9204a337492c1be4b7b8dabd68941d8934439cbc/modules/analyse/src/main/AccuracyPercent.scala#L71
// sbt 'testOnly lila.analyse.AccuracyPercentTest'
// lichess: 86% 97% (game against stockfish)
@@ -1001,7 +1001,7 @@ func AnalyseGame(pgn string, t int64) (out AnalyseResult, err error) {
//fmt.Println(strings.Join(s, ", "))
wa, ba := gameAccuracy(cps)
- return AnalyseResult{
+ return AnalyzeResult{
Scores: scores,
WhiteAccuracy: wa,
BlackAccuracy: ba,
diff --git a/pkg/web/web.go b/pkg/web/web.go
@@ -100,7 +100,7 @@ func getMainServer(db *database.DkfDB, i18nBundle *i18n.Bundle, renderer *tmp.Te
authGroup.POST("/chess", handlers.ChessHandler)
authGroup.GET("/chess/:key", handlers.ChessGameHandler)
authGroup.POST("/chess/:key", handlers.ChessGameHandler)
- authGroup.GET("/chess/:key/analyse", handlers.ChessGameAnalyseHandler, middlewares.IsAdminMiddleware)
+ authGroup.GET("/chess/:key/analyze", handlers.ChessGameAnalyzeHandler, middlewares.IsAdminMiddleware)
authGroup.GET("/chess/:key/form", handlers.ChessGameFormHandler)
authGroup.POST("/chess/:key/form", handlers.ChessGameFormHandler)
authGroup.GET("/chess/:key/stats", handlers.ChessGameStatsHandler)