Skip to content

Commit

Permalink
Tidy code
Browse files Browse the repository at this point in the history
  • Loading branch information
slhmy committed Aug 2, 2024
1 parent 8910b52 commit 810cbf3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
9 changes: 2 additions & 7 deletions cmd/web_server/handler/problem.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,13 @@ func SetupProblemRouter(baseRoute *gin.RouterGroup) {
func getProblem(ginCtx *gin.Context) {
slug := ginCtx.Param("slug")

problemInfo, err := problem_service.GetProblem(ginCtx, slug)
problem, err := problem_service.GetProblem(ginCtx, slug)
if err != nil {
_ = ginCtx.Error(err)
return
}

ginCtx.JSON(200, gin.H{
"slug": problemInfo.Slug,
"title": problemInfo.Title,
"description": problemInfo.Description,
"tags": problem_model.GetTagsList(*problemInfo),
})
ginCtx.JSON(200, problem)
}

// putProblem
Expand Down
4 changes: 1 addition & 3 deletions models/judge/judge_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ func buildGetJudgeTXByOptions(
tx *gorm.DB, options GetJudgeOptions, isCount bool,
) *gorm.DB {
tx = tx.Model(&Judge{}).
Preload(clause.Associations)
// See more in: https://gorm.io/docs/preload.html
// Preload("User.Roles").Preload("Problem.Tags").Preload(clause.Associations)
Preload(clause.Associations) // See more in: https://gorm.io/docs/preload.html
if len(options.Selection) > 0 {
tx = tx.Select(options.Selection)
}
Expand Down

0 comments on commit 810cbf3

Please sign in to comment.