This commit is contained in:
Howl 2016-08-15 21:51:51 +02:00
parent cab63a94ac
commit 4f7ef9c071

View File

@ -34,6 +34,15 @@ func GetScores(c *gin.Context, db *sqlx.DB) {
if rankable(c.Query("m")) { if rankable(c.Query("m")) {
sb = "scores.pp" sb = "scores.pp"
} }
var (
extraWhere string
extraParams []interface{}
)
if c.Query("u") != "" {
w, p := genUser(c, db)
extraWhere = "AND " + w
extraParams = append(extraParams, p)
}
rows, err := db.Query(` rows, err := db.Query(`
SELECT SELECT
scores.id, scores.score, users.username, scores.300_count, scores.100_count, scores.id, scores.score, users.username, scores.300_count, scores.100_count,
@ -46,8 +55,9 @@ WHERE scores.completed = '3'
AND users.privileges & 1 > 0 AND users.privileges & 1 > 0
AND scores.beatmap_md5 = ? AND scores.beatmap_md5 = ?
AND scores.play_mode = ? AND scores.play_mode = ?
`+extraWhere+`
ORDER BY `+sb+` DESC LIMIT `+strconv.Itoa(common.InString(1, c.Query("limit"), 100, 50)), ORDER BY `+sb+` DESC LIMIT `+strconv.Itoa(common.InString(1, c.Query("limit"), 100, 50)),
beatmapMD5, genmodei(c.Query("m"))) append([]interface{}{beatmapMD5, genmodei(c.Query("m"))}, extraParams...)...)
if err != nil { if err != nil {
c.Error(err) c.Error(err)
c.JSON(200, defaultResponse) c.JSON(200, defaultResponse)