Skip to content

Commit

Permalink
Allow user to retrieve/edit leaderboard size setting (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsunyoku authored Sep 10, 2024
1 parent 6b3f42c commit be75a77
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/v1/self.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ type userSettingsData struct {
} `json:"custom_badge"`
PlayStyle *int `json:"play_style"`
VanillaPPLeaderboards *bool `json:"vanilla_pp_leaderboards"`
LeaderboardSize *int `json:"leaderboard_size"`
}

// UsersSelfSettingsPOST allows to modify information about the current user.
Expand Down Expand Up @@ -88,7 +89,8 @@ func UsersSelfSettingsPOST(md common.MethodData) common.CodeMessager {
Add("custom_badge_icon", d.CustomBadge.Icon).
Add("show_custom_badge", d.CustomBadge.Show).
Add("play_style", d.PlayStyle).
Add("vanilla_pp_leaderboards", d.VanillaPPLeaderboards)
Add("vanilla_pp_leaderboards", d.VanillaPPLeaderboards).
Add("leaderboard_size", d.LeaderboardSize)
_, err := md.DB.Exec("UPDATE users SET "+q.Fields()+" WHERE id = ?", append(q.Parameters, md.ID())...)
if err != nil {
md.Err(err)
Expand Down Expand Up @@ -116,14 +118,16 @@ SELECT
email, username_aka, favourite_mode,
show_custom_badge, custom_badge_icon,
custom_badge_name, can_custom_badge,
play_style, vanilla_pp_leaderboards
play_style, vanilla_pp_leaderboards,
leaderboard_size
FROM users
WHERE id = ?`, md.ID()).Scan(
&r.ID, &r.Username,
&r.Email, &r.UsernameAKA, &r.FavouriteMode,
&r.CustomBadge.Show, &r.CustomBadge.Icon,
&r.CustomBadge.Name, &ccb,
&r.PlayStyle, &r.VanillaPPLeaderboards,
&r.LeaderboardSize,
)
if err != nil {
md.Err(err)
Expand Down

0 comments on commit be75a77

Please sign in to comment.