diff --git a/app/v1/score.go b/app/v1/score.go index a711afb..e6a506d 100644 --- a/app/v1/score.go +++ b/app/v1/score.go @@ -267,3 +267,25 @@ func genModeClause(md common.MethodData) string { } return modeClause } + +func genModeClauseRx(md common.MethodData) string { + var modeClause string + if md.Query("mode") != "" { + m, err := strconv.Atoi(md.Query("mode")) + if err == nil && m >= 0 && m <= 3 { + modeClause = fmt.Sprintf("AND scores_relac.play_mode = '%d'", m) + } + } + return modeClause +} + +func genModeClauseAp(md common.MethodData) string { + var modeClause string + if md.Query("mode") != "" { + m, err := strconv.Atoi(md.Query("mode")) + if err == nil && m >= 0 && m <= 3 { + modeClause = fmt.Sprintf("AND scores_auto.play_mode = '%d'", m) + } + } + return modeClause +} \ No newline at end of file diff --git a/app/v1/user_scores_ap.go b/app/v1/user_scores_ap.go index b0d6c61..2669588 100644 --- a/app/v1/user_scores_ap.go +++ b/app/v1/user_scores_ap.go @@ -45,7 +45,7 @@ func UserScoresBestAPGET(md common.MethodData) common.CodeMessager { if cm != nil { return *cm } - mc := genModeClause(md) + mc := genModeClauseAp(md) // For all modes that have PP, we leave out 0 PP scores_auto. if getMode(md.Query("mode")) != "ctb" { mc += " AND scores_auto.pp > 0" @@ -73,7 +73,7 @@ func UserScoresRecentAPGET(md common.MethodData) common.CodeMessager { %s AND `+md.User.OnlyUserPublic(true)+` ORDER BY scores_auto.id DESC %s`, - wc, genModeClause(md), common.Paginate(md.Query("p"), md.Query("l"), 100), + wc, genModeClauseAp(md), common.Paginate(md.Query("p"), md.Query("l"), 100), ), param) } diff --git a/app/v1/user_scores_relax.go b/app/v1/user_scores_relax.go index edceb07..f524223 100644 --- a/app/v1/user_scores_relax.go +++ b/app/v1/user_scores_relax.go @@ -45,7 +45,7 @@ func UserScoresBestRelaxGET(md common.MethodData) common.CodeMessager { if cm != nil { return *cm } - mc := genModeClause(md) + mc := genModeClauseRx(md) // For all modes that have PP, we leave out 0 PP scores_relax. if getMode(md.Query("mode")) != "ctb" { mc += " AND scores_relax.pp > 0" @@ -73,7 +73,7 @@ func UserScoresRecentRelaxGET(md common.MethodData) common.CodeMessager { %s AND `+md.User.OnlyUserPublic(true)+` ORDER BY scores_relax.id DESC %s`, - wc, genModeClause(md), common.Paginate(md.Query("p"), md.Query("l"), 100), + wc, genModeClauseRx(md), common.Paginate(md.Query("p"), md.Query("l"), 100), ), param) }