Fix get_users returning no results if user doesn't have a leaderboard position
This commit is contained in:
@@ -23,6 +23,7 @@ func GetUser(c *gin.Context, db *sqlx.DB) {
|
||||
|
||||
mode := genmode(c.Query("m"))
|
||||
|
||||
var lbpos *int
|
||||
err := db.QueryRow(fmt.Sprintf(
|
||||
`SELECT
|
||||
users.id, users.username,
|
||||
@@ -38,7 +39,7 @@ func GetUser(c *gin.Context, db *sqlx.DB) {
|
||||
), p).Scan(
|
||||
&user.UserID, &user.Username,
|
||||
&user.Playcount, &user.RankedScore, &user.TotalScore,
|
||||
&user.Rank, &user.PP, &user.Accuracy,
|
||||
&lbpos, &user.PP, &user.Accuracy,
|
||||
&user.Country,
|
||||
)
|
||||
if err != nil {
|
||||
@@ -48,6 +49,9 @@ func GetUser(c *gin.Context, db *sqlx.DB) {
|
||||
}
|
||||
return
|
||||
}
|
||||
if lbpos != nil {
|
||||
user.Rank = *lbpos
|
||||
}
|
||||
user.Level = ocl.GetLevelPrecise(user.TotalScore)
|
||||
|
||||
c.JSON(200, []osuapi.User{user})
|
||||
|
Reference in New Issue
Block a user