Add BeatmapsRankedFrozenFullGET, an endpoint to get all beatmaps having a frozen ranked status
This commit is contained in:
parent
9b821e3230
commit
b1fc609706
|
@ -52,6 +52,7 @@ func Start(conf common.Conf, dbO *sql.DB) *gin.Engine {
|
||||||
|
|
||||||
// Admin: beatmap
|
// Admin: beatmap
|
||||||
gv1.POST("/beatmaps/set_status", Method(v1.BeatmapSetStatusPOST, common.PrivilegeBeatmap))
|
gv1.POST("/beatmaps/set_status", Method(v1.BeatmapSetStatusPOST, common.PrivilegeBeatmap))
|
||||||
|
gv1.GET("/beatmaps/ranked_frozen_full", Method(v1.BeatmapRankedFrozenFullGET, common.PrivilegeBeatmap))
|
||||||
|
|
||||||
// Admin: user managing
|
// Admin: user managing
|
||||||
gv1.POST("/users/manage/set_allowed", Method(v1.UserManageSetAllowedPOST, common.PrivilegeManageUser))
|
gv1.POST("/users/manage/set_allowed", Method(v1.UserManageSetAllowedPOST, common.PrivilegeManageUser))
|
||||||
|
|
|
@ -192,3 +192,42 @@ func getBeatmap(md common.MethodData, beatmapID int) common.CodeMessager {
|
||||||
r.beatmap = b
|
r.beatmap = b
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type beatmapReduced struct {
|
||||||
|
BeatmapID int `json:"beatmap_id"`
|
||||||
|
BeatmapsetID int `json:"beatmapset_id"`
|
||||||
|
BeatmapMD5 string `json:"beatmap_md5"`
|
||||||
|
Ranked int `json:"ranked"`
|
||||||
|
RankedStatusFrozen int `json:"ranked_status_frozen"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type beatmapRankedFrozenFullResponse struct {
|
||||||
|
common.ResponseBase
|
||||||
|
Beatmaps []beatmapReduced `json:"beatmaps"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// BeatmapRankedFrozenFullGET retrieves all beatmaps with a certain
|
||||||
|
// ranked_status_freezed
|
||||||
|
func BeatmapRankedFrozenFullGET(md common.MethodData) common.CodeMessager {
|
||||||
|
rows, err := md.DB.Query(`
|
||||||
|
SELECT beatmap_id, beatmapset_id, beatmap_md5, ranked, ranked_status_freezed
|
||||||
|
FROM beatmaps
|
||||||
|
WHERE ranked_status_freezed = '1'
|
||||||
|
`)
|
||||||
|
if err != nil {
|
||||||
|
md.Err(err)
|
||||||
|
return Err500
|
||||||
|
}
|
||||||
|
var r beatmapRankedFrozenFullResponse
|
||||||
|
for rows.Next() {
|
||||||
|
var b beatmapReduced
|
||||||
|
err = rows.Scan(&b.BeatmapID, &b.BeatmapsetID, &b.BeatmapMD5, &b.Ranked, &b.RankedStatusFrozen)
|
||||||
|
if err != nil {
|
||||||
|
md.Err(err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
r.Beatmaps = append(r.Beatmaps, b)
|
||||||
|
}
|
||||||
|
r.Code = 200
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user