how do we not have querying by score id???
This commit is contained in:
parent
4470ca2e63
commit
21e3939b36
|
@ -49,14 +49,16 @@ type scoresResponse struct {
|
||||||
// ScoresGET retrieves the top scores for a certain beatmap.
|
// ScoresGET retrieves the top scores for a certain beatmap.
|
||||||
func ScoresGET(md common.MethodData) common.CodeMessager {
|
func ScoresGET(md common.MethodData) common.CodeMessager {
|
||||||
var (
|
var (
|
||||||
beatmapMD5 string
|
where = new(common.WhereClause)
|
||||||
r scoresResponse
|
r scoresResponse
|
||||||
)
|
)
|
||||||
|
pm := md.Ctx.Request.URI().QueryArgs().PeekMulti
|
||||||
switch {
|
switch {
|
||||||
case md.Query("md5") != "":
|
case md.Query("md5") != "":
|
||||||
beatmapMD5 = md.Query("md5")
|
where.In("beatmap_md5", pm("md5")...)
|
||||||
case md.Query("b") != "":
|
case md.Query("b") != "":
|
||||||
err := md.DB.Get(&beatmapMD5, "SELECT beatmap_md5 FROM beatmaps WHERE beatmap_id = ? LIMIT 1", md.Query("b"))
|
var md5 string
|
||||||
|
err := md.DB.Get(&md5, "SELECT beatmap_md5 FROM beatmaps WHERE beatmap_id = ? LIMIT 1", md.Query("b"))
|
||||||
switch {
|
switch {
|
||||||
case err == sql.ErrNoRows:
|
case err == sql.ErrNoRows:
|
||||||
r.Code = 200
|
r.Code = 200
|
||||||
|
@ -65,9 +67,9 @@ func ScoresGET(md common.MethodData) common.CodeMessager {
|
||||||
md.Err(err)
|
md.Err(err)
|
||||||
return Err500
|
return Err500
|
||||||
}
|
}
|
||||||
default:
|
where.Where("beatmap_md5 = ?", md5)
|
||||||
return ErrMissingField("md5|b")
|
|
||||||
}
|
}
|
||||||
|
where.In("scores.id", pm("id")...)
|
||||||
|
|
||||||
sort := common.Sort(md, common.SortConfiguration{
|
sort := common.Sort(md, common.SortConfiguration{
|
||||||
Default: "scores.pp DESC, scores.score DESC",
|
Default: "scores.pp DESC, scores.score DESC",
|
||||||
|
@ -75,6 +77,10 @@ func ScoresGET(md common.MethodData) common.CodeMessager {
|
||||||
Allowed: []string{"pp", "score", "accuracy", "id"},
|
Allowed: []string{"pp", "score", "accuracy", "id"},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
where.Where(` scores.completed = '3' AND `+md.User.OnlyUserPublic(false)+` `+
|
||||||
|
genModeClause(md)+` `+sort+common.Paginate(md.Query("p"), md.Query("l"), 100), "")
|
||||||
|
where.Params = where.Params[:len(where.Params)-1]
|
||||||
|
|
||||||
rows, err := md.DB.Query(`
|
rows, err := md.DB.Query(`
|
||||||
SELECT
|
SELECT
|
||||||
scores.id, scores.beatmap_md5, scores.score,
|
scores.id, scores.beatmap_md5, scores.score,
|
||||||
|
@ -89,9 +95,7 @@ SELECT
|
||||||
FROM scores
|
FROM scores
|
||||||
INNER JOIN users ON users.id = scores.userid
|
INNER JOIN users ON users.id = scores.userid
|
||||||
INNER JOIN users_stats ON users_stats.id = scores.userid
|
INNER JOIN users_stats ON users_stats.id = scores.userid
|
||||||
WHERE scores.beatmap_md5 = ? AND scores.completed = '3' AND `+md.User.OnlyUserPublic(false)+
|
`+where.Clause, where.Params...)
|
||||||
` `+genModeClause(md)+`
|
|
||||||
`+sort+common.Paginate(md.Query("p"), md.Query("l"), 100), beatmapMD5)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
md.Err(err)
|
md.Err(err)
|
||||||
return Err500
|
return Err500
|
||||||
|
|
Loading…
Reference in New Issue
Block a user