From 7359cf7c3901723994bfe3ffef2c14bb95e01bc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ron=20Nosz=C3=A1ly?= Date: Sun, 23 Jun 2024 15:58:58 +0200 Subject: [PATCH] Modify ranklist URL --- internal/web/handlers/problemset/problemset.go | 8 ++++++-- internal/web/routes.go | 2 +- internal/web/templates/layout.templ | 2 +- internal/web/templates/layout_templ.go | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/internal/web/handlers/problemset/problemset.go b/internal/web/handlers/problemset/problemset.go index 896400a..075ed76 100644 --- a/internal/web/handlers/problemset/problemset.go +++ b/internal/web/handlers/problemset/problemset.go @@ -353,18 +353,22 @@ func PostSubmit(submissions njudge.Submissions, subService *njudge.SubmitService func GetRanklist(rs njudge.ProblemsetRanklistService) echo.HandlerFunc { type request struct { - Page int `query:"page"` + Problemset string `query:"problemset"` + Page int `query:"page"` } return func(c echo.Context) error { req := request{} if err := c.Bind(&req); err != nil { return err } + if req.Problemset == "" { + req.Problemset = "main" + } if req.Page <= 0 { req.Page = 1 } res, err := rs.GetRanklist(c.Request().Context(), njudge.ProblemsetRanklistRequest{ - Name: c.Param("name"), + Name: req.Problemset, Page: req.Page, PerPage: 50, FilterAdmin: true, diff --git a/internal/web/routes.go b/internal/web/routes.go index ef77198..261567f 100644 --- a/internal/web/routes.go +++ b/internal/web/routes.go @@ -61,10 +61,10 @@ func (s *Server) routes(e *echo.Echo) { e.GET("/submission/:id", handlers.GetSubmission(s.Submissions, s.Problems, s.Problemsets, s.SolvedStatusQuery)).Name = "getSubmission" e.GET("/submission/rejudge/:id", handlers.RejudgeSubmission(s.Submissions), user.RequireLoginMiddleware()).Name = "rejudgeSubmission" e.GET("/task_archive", handlers.GetTaskArchive(s.TaskArchiveService)) + e.GET("/ranklist/", problemset.GetRanklist(s.ProblemsetRanklistService)) ps := e.Group("/problemset", problemset.SetMiddleware(s.Problemsets)) ps.GET("/:name/", problemset.GetProblemList(s.ProblemStore, s.Problems, s.Categories, s.ProblemListQuery, s.ProblemInfoQuery, s.Tags)) - ps.GET("/:name/ranklist/", problemset.GetRanklist(s.ProblemsetRanklistService)) ps.POST("/:name/submit", problemset.PostSubmit(s.Submissions, s.SubmitService), user.RequireLoginMiddleware()) e.GET("/problemset/status/", problemset.GetStatus(s.SubmissionListQuery)).Name = "getProblemsetStatus" diff --git a/internal/web/templates/layout.templ b/internal/web/templates/layout.templ index ad925d1..db788ce 100644 --- a/internal/web/templates/layout.templ +++ b/internal/web/templates/layout.templ @@ -88,7 +88,7 @@ templ pageNavbar() { @navbarItem("/task_archive", "Archive", " ") @navbarItem("/problemset/status/", "Submissions", " ") @navbarItem("/problemset/main/", "Problems", " ") - @navbarItem("/problemset/main/ranklist/", "Ranklist", " ") + @navbarItem("/ranklist/", "Ranklist", " ") @templ.Raw(partial(ctx, CustomMenuPartial))