Skip to content

Commit

Permalink
Write to new users columns in parallel (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmyui authored Apr 21, 2024
1 parent 4f185d0 commit 50ba544
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions app/v1/self.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,18 @@ func UsersSelfSettingsPOST(md common.MethodData) common.CodeMessager {
d.FavouriteMode = intPtrIn(0, d.FavouriteMode, 3)

q := new(common.UpdateQuery).
Add("s.username_aka", d.UsernameAKA).
Add("s.favourite_mode", d.FavouriteMode).
Add("s.custom_badge_name", d.CustomBadge.Name).
Add("s.custom_badge_icon", d.CustomBadge.Icon).
Add("s.show_custom_badge", d.CustomBadge.Show).
Add("s.play_style", d.PlayStyle)
_, err := md.DB.Exec("UPDATE users u, users_stats s SET "+q.Fields()+" WHERE s.id = u.id AND u.id = ?", append(q.Parameters, md.ID())...)
Add("username_aka", d.UsernameAKA).
Add("favourite_mode", d.FavouriteMode).
Add("custom_badge_name", d.CustomBadge.Name).
Add("custom_badge_icon", d.CustomBadge.Icon).
Add("show_custom_badge", d.CustomBadge.Show).
Add("play_style", d.PlayStyle)
_, err := md.DB.Exec("UPDATE users_stats SET "+q.Fields()+" WHERE id = ?", append(q.Parameters, md.ID())...)
if err != nil {
md.Err(err)
return Err500
}
_, err = md.DB.Exec("UPDATE users SET "+q.Fields()+"Where id = ?", append(q.Parameters, md.ID())...)
if err != nil {
md.Err(err)
return Err500
Expand Down

0 comments on commit 50ba544

Please sign in to comment.