From e858ed94bc5386613c2fc67bc2f2cc94be706324 Mon Sep 17 00:00:00 2001 From: Howl Date: Sat, 17 Sep 2016 23:27:20 +0200 Subject: [PATCH] Schiavo is like a son with a down syndrome. You love him, like every child you have, but you have to accept the fact that he's fucking down, and so he's completely retarded and makes everything the wrong way. Also, in this commit: set_status is now no more fucking retarded, as in it actually returns the beatmap it was requested, and some minor things. --- app/v1/beatmap.go | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/app/v1/beatmap.go b/app/v1/beatmap.go index 5c4e1c5..1cc1c8c 100644 --- a/app/v1/beatmap.go +++ b/app/v1/beatmap.go @@ -2,6 +2,8 @@ package v1 import ( "database/sql" + "fmt" + "net/url" "git.zxq.co/ripple/rippleapi/common" ) @@ -82,9 +84,32 @@ func BeatmapSetStatusPOST(md common.MethodData) common.CodeMessager { SET ranked = ?, ranked_status_freezed = ? WHERE beatmapset_id = ?`, req.RankedStatus, req.Frozen, param) + var x = make(map[string]interface{}, 1) + if req.BeatmapID != 0 { + x["bb"] = req.BeatmapID + } else { + x["s"] = req.BeatmapsetID + } + md.C.Request.URL = genURL(x) return getMultipleBeatmaps(md) } +func genURL(d map[string]interface{}) *url.URL { + var s string + for k, v := range d { + if s != "" { + s += "&" + } + s += k + "=" + url.QueryEscape(fmt.Sprintf("%v", v)) + } + u := new(url.URL) + if len(d) == 0 { + return u + } + u.RawQuery = s + return u +} + // BeatmapGET retrieves a beatmap. func BeatmapGET(md common.MethodData) common.CodeMessager { beatmapID := common.Int(md.Query("b")) @@ -124,7 +149,9 @@ func getMultipleBeatmaps(md common.MethodData) common.CodeMessager { Default: "id DESC", Table: "beatmaps", }) - where := common.Where("beatmapset_id = ?", md.Query("s")). + where := common. + Where("beatmap_id = ?", md.Query("bb")). + Where("beatmapset_id = ?", md.Query("s")). Where("song_name = ?", md.Query("song_name")). Where("ranked_status_freezed = ?", md.Query("ranked_status_frozen"), "0", "1")