Skip to content

Commit

Permalink
Modify ranklist URL
Browse files Browse the repository at this point in the history
  • Loading branch information
mraron committed Jun 23, 2024
1 parent 4f3bd45 commit 7359cf7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions internal/web/handlers/problemset/problemset.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion internal/web/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion internal/web/templates/layout.templ
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ templ pageNavbar() {
@navbarItem("/task_archive", "Archive", "<i class=\"bi bi-book-fill\"></i> ")
@navbarItem("/problemset/status/", "Submissions", "<i class=\"bi bi-list\"></i> ")
@navbarItem("/problemset/main/", "Problems", "<i class=\"bi bi-pencil-fill\"></i> ")
@navbarItem("/problemset/main/ranklist/", "Ranklist", "<i class=\"bi bi-bar-chart-fill\"></i> ")
@navbarItem("/ranklist/", "Ranklist", "<i class=\"bi bi-bar-chart-fill\"></i> ")
@templ.Raw(partial(ctx, CustomMenuPartial))
</ul>
<ul class="navbar-nav ml-auto">
Expand Down
2 changes: 1 addition & 1 deletion internal/web/templates/layout_templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7359cf7

Please sign in to comment.