diff options
Diffstat (limited to 'backend/admin')
| -rw-r--r-- | backend/admin/handler.go | 38 | ||||
| -rw-r--r-- | backend/admin/templates/dashboard.html | 3 |
2 files changed, 41 insertions, 0 deletions
diff --git a/backend/admin/handler.go b/backend/admin/handler.go index 123e6f4..eaea208 100644 --- a/backend/admin/handler.go +++ b/backend/admin/handler.go @@ -64,6 +64,7 @@ func (h *Handler) RegisterHandlers(g *echo.Group) { g.POST("/games/:gameID", h.postGameEdit) g.POST("/games/:gameID/start", h.postGameStart) g.GET("/online-qualifying-ranking", h.getOnlineQualifyingRanking) + g.POST("/fix", h.postFix) } func (h *Handler) getDashboard(c echo.Context) error { @@ -428,3 +429,40 @@ func (h *Handler) getOnlineQualifyingRanking(c echo.Context) error { "Entries": entries, }) } + +func (h *Handler) postFix(c echo.Context) error { + rows, err := h.q.ListSubmissionIDs(c.Request().Context()) + if err != nil { + return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) + } + for _, submissionID := range rows { + as, err := h.q.AggregateTestcaseResults(c.Request().Context(), submissionID) + if err != nil { + return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) + } + err = h.q.UpdateSubmissionStatus(c.Request().Context(), db.UpdateSubmissionStatusParams{ + SubmissionID: submissionID, + Status: as, + }) + if err != nil { + return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) + } + } + + rows2, err := h.q.ListGameStateIDs(c.Request().Context()) + if err != nil { + return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) + } + for _, r := range rows2 { + gameID := r.GameID + userID := r.UserID + err := h.q.SyncGameStateBestScoreSubmission(c.Request().Context(), db.SyncGameStateBestScoreSubmissionParams{ + GameID: gameID, + UserID: userID, + }) + if err != nil { + return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) + } + } + return c.Redirect(http.StatusSeeOther, basePath+"/admin") +} diff --git a/backend/admin/templates/dashboard.html b/backend/admin/templates/dashboard.html index 2d030ef..17a0d6a 100644 --- a/backend/admin/templates/dashboard.html +++ b/backend/admin/templates/dashboard.html @@ -10,6 +10,9 @@ <p> <a href="{{ .BasePath }}/admin/online-qualifying-ranking?game_1=7&game_2=8">Online Qualifying Ranking</a> </p> +<form method="post" action="{{ .BasePath }}/fix"> + <button type="submit">fix</button> +</form> <form method="post" action="{{ .BasePath }}/logout"> <button type="submit">Logout</button> </form> |
