Fix get_users returning no results if user doesn't have a leaderboard position

This commit is contained in:
Howl
2016-09-09 18:55:26 +02:00
parent 7249d9136b
commit 4be5948d97
2 changed files with 8 additions and 4 deletions

View File

@@ -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})