hey nyo i may or may not have fixed beatmap difficulties
This commit is contained in:
		| @@ -6,6 +6,13 @@ import ( | ||||
| 	"git.zxq.co/ripple/rippleapi/common" | ||||
| ) | ||||
|  | ||||
| type difficulty struct { | ||||
| 	STD   float64 `json:"std"` | ||||
| 	Taiko float64 `json:"taiko"` | ||||
| 	CTB   float64 `json:"ctb"` | ||||
| 	Mania float64 `json:"mania"` | ||||
| } | ||||
|  | ||||
| type beatmap struct { | ||||
| 	BeatmapID          int                  `json:"beatmap_id"` | ||||
| 	BeatmapsetID       int                  `json:"beatmapset_id"` | ||||
| @@ -14,6 +21,7 @@ type beatmap struct { | ||||
| 	AR                 float32              `json:"ar"` | ||||
| 	OD                 float32              `json:"od"` | ||||
| 	Difficulty         float64              `json:"difficulty"` | ||||
| 	Diff2              difficulty           `json:"difficulty2"` // fuck nyo | ||||
| 	MaxCombo           int                  `json:"max_combo"` | ||||
| 	HitLength          int                  `json:"hit_length"` | ||||
| 	Ranked             int                  `json:"ranked"` | ||||
| @@ -21,41 +29,6 @@ type beatmap struct { | ||||
| 	LatestUpdate       common.UnixTimestamp `json:"latest_update"` | ||||
| } | ||||
|  | ||||
| type beatmapMayOrMayNotExist struct { | ||||
| 	BeatmapID          *int | ||||
| 	BeatmapsetID       *int | ||||
| 	BeatmapMD5         *string | ||||
| 	SongName           *string | ||||
| 	AR                 *float32 | ||||
| 	OD                 *float32 | ||||
| 	Difficulty         *float64 | ||||
| 	MaxCombo           *int | ||||
| 	HitLength          *int | ||||
| 	Ranked             *int | ||||
| 	RankedStatusFrozen *int | ||||
| 	LatestUpdate       *common.UnixTimestamp | ||||
| } | ||||
|  | ||||
| func (b *beatmapMayOrMayNotExist) toBeatmap() *beatmap { | ||||
| 	if b == nil || b.BeatmapID == nil { | ||||
| 		return nil | ||||
| 	} | ||||
| 	return &beatmap{ | ||||
| 		BeatmapID:          *b.BeatmapID, | ||||
| 		BeatmapsetID:       *b.BeatmapsetID, | ||||
| 		BeatmapMD5:         *b.BeatmapMD5, | ||||
| 		SongName:           *b.SongName, | ||||
| 		AR:                 *b.AR, | ||||
| 		OD:                 *b.OD, | ||||
| 		Difficulty:         *b.Difficulty, | ||||
| 		MaxCombo:           *b.MaxCombo, | ||||
| 		HitLength:          *b.HitLength, | ||||
| 		Ranked:             *b.Ranked, | ||||
| 		RankedStatusFrozen: *b.RankedStatusFrozen, | ||||
| 		LatestUpdate:       *b.LatestUpdate, | ||||
| 	} | ||||
| } | ||||
|  | ||||
| type beatmapResponse struct { | ||||
| 	common.ResponseBase | ||||
| 	beatmap | ||||
| @@ -131,7 +104,8 @@ func BeatmapGET(md common.MethodData) common.CodeMessager { | ||||
| const baseBeatmapSelect = ` | ||||
| SELECT | ||||
| 	beatmap_id, beatmapset_id, beatmap_md5, | ||||
| 	song_name, ar, od, difficulty, max_combo, | ||||
| 	song_name, ar, od, difficulty_std, difficulty_taiko, | ||||
| 	difficulty_ctb, difficulty_mania, max_combo, | ||||
| 	hit_length, ranked, ranked_status_freezed, | ||||
| 	latest_update | ||||
| FROM beatmaps | ||||
| @@ -148,10 +122,12 @@ func getSet(md common.MethodData, setID int) common.CodeMessager { | ||||
| 		var b beatmap | ||||
| 		err = rows.Scan( | ||||
| 			&b.BeatmapID, &b.BeatmapsetID, &b.BeatmapMD5, | ||||
| 			&b.SongName, &b.AR, &b.OD, &b.Difficulty, &b.MaxCombo, | ||||
| 			&b.SongName, &b.AR, &b.OD, &b.Diff2.STD, &b.Diff2.Taiko, | ||||
| 			&b.Diff2.CTB, &b.Diff2.Mania, &b.MaxCombo, | ||||
| 			&b.HitLength, &b.Ranked, &b.RankedStatusFrozen, | ||||
| 			&b.LatestUpdate, | ||||
| 		) | ||||
| 		b.Difficulty = b.Diff2.STD | ||||
| 		if err != nil { | ||||
| 			md.Err(err) | ||||
| 			continue | ||||
| @@ -166,10 +142,12 @@ func getBeatmap(md common.MethodData, beatmapID int) common.CodeMessager { | ||||
| 	var b beatmap | ||||
| 	err := md.DB.QueryRow(baseBeatmapSelect+"WHERE beatmap_id = ? LIMIT 1", beatmapID).Scan( | ||||
| 		&b.BeatmapID, &b.BeatmapsetID, &b.BeatmapMD5, | ||||
| 		&b.SongName, &b.AR, &b.OD, &b.Difficulty, &b.MaxCombo, | ||||
| 		&b.SongName, &b.AR, &b.OD, &b.Diff2.STD, &b.Diff2.Taiko, | ||||
| 		&b.Diff2.CTB, &b.Diff2.Mania, &b.MaxCombo, | ||||
| 		&b.HitLength, &b.Ranked, &b.RankedStatusFrozen, | ||||
| 		&b.LatestUpdate, | ||||
| 	) | ||||
| 	b.Difficulty = b.Diff2.STD | ||||
| 	switch { | ||||
| 	case err == sql.ErrNoRows: | ||||
| 		return common.SimpleResponse(404, "That beatmap could not be found!") | ||||
|   | ||||
| @@ -30,7 +30,7 @@ type score struct { | ||||
|  | ||||
| type userScore struct { | ||||
| 	score | ||||
| 	Beatmap *beatmap `json:"beatmap"` | ||||
| 	Beatmap beatmap `json:"beatmap"` | ||||
| } | ||||
|  | ||||
| type userScoresResponse struct { | ||||
| @@ -48,7 +48,8 @@ SELECT | ||||
| 	scores.completed, | ||||
|  | ||||
| 	beatmaps.beatmap_id, beatmaps.beatmapset_id, beatmaps.beatmap_md5, | ||||
| 	beatmaps.song_name, beatmaps.ar, beatmaps.od, beatmaps.difficulty, | ||||
| 	beatmaps.song_name, beatmaps.ar, beatmaps.od, beatmaps.difficulty_std, | ||||
| 	beatmaps.difficulty_taiko, beatmaps.difficulty_ctb, beatmaps.difficulty_mania, | ||||
| 	beatmaps.max_combo, beatmaps.hit_length, beatmaps.ranked, | ||||
| 	beatmaps.ranked_status_freezed, beatmaps.latest_update | ||||
| FROM scores | ||||
| @@ -130,7 +131,7 @@ func scoresPuts(md common.MethodData, whereClause string, params ...interface{}) | ||||
| 		var ( | ||||
| 			us userScore | ||||
| 			t  string | ||||
| 			b  beatmapMayOrMayNotExist | ||||
| 			b  beatmap | ||||
| 		) | ||||
| 		err = rows.Scan( | ||||
| 			&us.ID, &us.BeatmapMD5, &us.Score, | ||||
| @@ -141,10 +142,12 @@ func scoresPuts(md common.MethodData, whereClause string, params ...interface{}) | ||||
| 			&us.Completed, | ||||
|  | ||||
| 			&b.BeatmapID, &b.BeatmapsetID, &b.BeatmapMD5, | ||||
| 			&b.SongName, &b.AR, &b.OD, &b.Difficulty, | ||||
| 			&b.SongName, &b.AR, &b.OD, &b.Diff2.STD, | ||||
| 			&b.Diff2.Taiko, &b.Diff2.CTB, &b.Diff2.Mania, | ||||
| 			&b.MaxCombo, &b.HitLength, &b.Ranked, | ||||
| 			&b.RankedStatusFrozen, &b.LatestUpdate, | ||||
| 		) | ||||
| 		b.Difficulty = b.Diff2.STD | ||||
| 		if err != nil { | ||||
| 			md.Err(err) | ||||
| 			return Err500 | ||||
| @@ -155,7 +158,7 @@ func scoresPuts(md common.MethodData, whereClause string, params ...interface{}) | ||||
| 			md.Err(err) | ||||
| 			return Err500 | ||||
| 		} | ||||
| 		us.Beatmap = b.toBeatmap() | ||||
| 		us.Beatmap = b | ||||
| 		scores = append(scores, us) | ||||
| 	} | ||||
| 	r := userScoresResponse{} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user