aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-09-06 01:35:27 +0900
committernsfisis <nsfisis@gmail.com>2025-09-06 01:35:27 +0900
commit9dbca8dde5b5c37f7bf54df49bb29413ded88cc8 (patch)
tree5d0fd0c7993a31efdf273c5dbf5fd3a34f419d80
parent8d739b386f2b555292fd8082c9de2199228737c9 (diff)
downloadiosdc-japan-2025-albatross-9dbca8dde5b5c37f7bf54df49bb29413ded88cc8.tar.gz
iosdc-japan-2025-albatross-9dbca8dde5b5c37f7bf54df49bb29413ded88cc8.tar.zst
iosdc-japan-2025-albatross-9dbca8dde5b5c37f7bf54df49bb29413ded88cc8.zip
feat(backend): restore /admin/fix
-rw-r--r--backend/admin/handler.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/backend/admin/handler.go b/backend/admin/handler.go
index 86ee3f7..c045b7d 100644
--- a/backend/admin/handler.go
+++ b/backend/admin/handler.go
@@ -55,6 +55,7 @@ func (h *Handler) RegisterHandlers(g *echo.Group) {
g.GET("/dashboard", h.getDashboard)
g.GET("/online-qualifying-ranking", h.getOnlineQualifyingRanking)
+ g.POST("/fix", h.postFix)
g.GET("/users", h.getUsers)
g.GET("/users/:userID", h.getUserEdit)
@@ -126,6 +127,43 @@ func (h *Handler) getOnlineQualifyingRanking(c echo.Context) error {
})
}
+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, h.conf.BasePath+"admin/dashboard")
+}
+
func (h *Handler) getUsers(c echo.Context) error {
rows, err := h.q.ListUsers(c.Request().Context())
if err != nil {