diff --git a/app/start.go b/app/start.go index 7283283..49e908e 100644 --- a/app/start.go +++ b/app/start.go @@ -52,6 +52,7 @@ func Start(conf common.Conf, dbO *sql.DB) *gin.Engine { // Admin: beatmap gv1.POST("/beatmaps/set_status", Method(v1.BeatmapSetStatusPOST, common.PrivilegeBeatmap)) + gv1.GET("/beatmaps/ranked_frozen_full", Method(v1.BeatmapRankedFrozenFullGET, common.PrivilegeBeatmap)) // Admin: user managing gv1.POST("/users/manage/set_allowed", Method(v1.UserManageSetAllowedPOST, common.PrivilegeManageUser)) diff --git a/app/v1/beatmap.go b/app/v1/beatmap.go index 704b64a..1bcceac 100644 --- a/app/v1/beatmap.go +++ b/app/v1/beatmap.go @@ -192,3 +192,42 @@ func getBeatmap(md common.MethodData, beatmapID int) common.CodeMessager { r.beatmap = b 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 +}