Add custom badge in users/full
This commit is contained in:
parent
e6c77e64a8
commit
e80e557f10
|
@ -7,7 +7,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type singleBadge struct {
|
type singleBadge struct {
|
||||||
ID int `json:"id"`
|
ID int `json:"id,omitempty"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Icon string `json:"icon"`
|
Icon string `json:"icon"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,6 +110,7 @@ type userFullResponse struct {
|
||||||
PlayStyle int `json:"play_style"`
|
PlayStyle int `json:"play_style"`
|
||||||
FavouriteMode int `json:"favourite_mode"`
|
FavouriteMode int `json:"favourite_mode"`
|
||||||
Badges []singleBadge `json:"badges"`
|
Badges []singleBadge `json:"badges"`
|
||||||
|
CustomBadge *singleBadge `json:"custom_badge"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserFullGET gets all of an user's information, with one exception: their userpage.
|
// UserFullGET gets all of an user's information, with one exception: their userpage.
|
||||||
|
@ -126,6 +127,9 @@ SELECT
|
||||||
|
|
||||||
users_stats.username_aka, users_stats.country, users_stats.play_style, users_stats.favourite_mode,
|
users_stats.username_aka, users_stats.country, users_stats.play_style, users_stats.favourite_mode,
|
||||||
|
|
||||||
|
users_stats.custom_badge_icon, users_stats.custom_badge_name, users_stats.can_custom_badge,
|
||||||
|
users_stats.show_custom_badge,
|
||||||
|
|
||||||
users_stats.ranked_score_std, users_stats.total_score_std, users_stats.playcount_std,
|
users_stats.ranked_score_std, users_stats.total_score_std, users_stats.playcount_std,
|
||||||
users_stats.replays_watched_std, users_stats.total_hits_std,
|
users_stats.replays_watched_std, users_stats.total_hits_std,
|
||||||
users_stats.avg_accuracy_std, users_stats.pp_std, leaderboard_std.position as std_position,
|
users_stats.avg_accuracy_std, users_stats.pp_std, leaderboard_std.position as std_position,
|
||||||
|
@ -158,12 +162,19 @@ LIMIT 1
|
||||||
`
|
`
|
||||||
// Fuck.
|
// Fuck.
|
||||||
r := userFullResponse{}
|
r := userFullResponse{}
|
||||||
|
var (
|
||||||
|
b singleBadge
|
||||||
|
can bool
|
||||||
|
show bool
|
||||||
|
)
|
||||||
err := md.DB.QueryRow(query, param).Scan(
|
err := md.DB.QueryRow(query, param).Scan(
|
||||||
&r.ID, &r.Username, &r.RegisteredOn, &r.Privileges, &r.LatestActivity,
|
&r.ID, &r.Username, &r.RegisteredOn, &r.Privileges, &r.LatestActivity,
|
||||||
|
|
||||||
&r.UsernameAKA, &r.Country,
|
&r.UsernameAKA, &r.Country,
|
||||||
&r.PlayStyle, &r.FavouriteMode,
|
&r.PlayStyle, &r.FavouriteMode,
|
||||||
|
|
||||||
|
&b.Icon, &b.Name, &can, &show,
|
||||||
|
|
||||||
&r.STD.RankedScore, &r.STD.TotalScore, &r.STD.PlayCount,
|
&r.STD.RankedScore, &r.STD.TotalScore, &r.STD.PlayCount,
|
||||||
&r.STD.ReplaysWatched, &r.STD.TotalHits,
|
&r.STD.ReplaysWatched, &r.STD.TotalHits,
|
||||||
&r.STD.Accuracy, &r.STD.PP, &r.STD.GlobalLeaderboardRank,
|
&r.STD.Accuracy, &r.STD.PP, &r.STD.GlobalLeaderboardRank,
|
||||||
|
@ -188,6 +199,10 @@ LIMIT 1
|
||||||
return Err500
|
return Err500
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if can && show && (b.Name != "" || b.Icon != "") {
|
||||||
|
r.CustomBadge = &b
|
||||||
|
}
|
||||||
|
|
||||||
for _, m := range []*modeData{&r.STD, &r.Taiko, &r.CTB, &r.Mania} {
|
for _, m := range []*modeData{&r.STD, &r.Taiko, &r.CTB, &r.Mania} {
|
||||||
m.Level = ocl.GetLevelPrecise(int64(m.TotalScore))
|
m.Level = ocl.GetLevelPrecise(int64(m.TotalScore))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user