diff options
| -rw-r--r-- | backend/handlers/user.go | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/backend/handlers/user.go b/backend/handlers/user.go index 6b090a0..e05c85b 100644 --- a/backend/handlers/user.go +++ b/backend/handlers/user.go | |||
| @@ -441,6 +441,18 @@ func FetchUser(c *gin.Context) { | |||
| 441 | c.JSON(http.StatusOK, models.ErrorResponse("User not found.")) | 441 | c.JSON(http.StatusOK, models.ErrorResponse("User not found.")) |
| 442 | return | 442 | return |
| 443 | } | 443 | } |
| 444 | // Get titles | ||
| 445 | titles := []models.Title{} | ||
| 446 | rows, err := database.DB.Query(`SELECT t.title_name, t.title_color FROM titles t INNER JOIN user_titles ut ON t.id=ut.title_id WHERE ut.user_id = $1`, user.SteamID) | ||
| 447 | if err != nil { | ||
| 448 | c.JSON(http.StatusOK, models.ErrorResponse(err.Error())) | ||
| 449 | return | ||
| 450 | } | ||
| 451 | for rows.Next() { | ||
| 452 | var title models.Title | ||
| 453 | rows.Scan(&title.Name, &title.Color) | ||
| 454 | titles = append(titles, title) | ||
| 455 | } | ||
| 444 | // Get rankings (all maps done in one game) | 456 | // Get rankings (all maps done in one game) |
| 445 | rankings := ProfileRankings{ | 457 | rankings := ProfileRankings{ |
| 446 | Overall: ProfileRankingsDetails{}, | 458 | Overall: ProfileRankingsDetails{}, |
| @@ -469,7 +481,7 @@ func FetchUser(c *gin.Context) { | |||
| 469 | FROM public.map_routes mr WHERE mr.category_id = 1 GROUP BY mr.map_id | 481 | FROM public.map_routes mr WHERE mr.category_id = 1 GROUP BY mr.map_id |
| 470 | ) AS subquery_mp ON rm.map_id = subquery_mp.map_id AND rm.score_count = subquery_mp.min_score_count | 482 | ) AS subquery_mp ON rm.map_id = subquery_mp.map_id AND rm.score_count = subquery_mp.min_score_count |
| 471 | WHERE rm.host_id = $1 OR rm.partner_id = $1;` | 483 | WHERE rm.host_id = $1 OR rm.partner_id = $1;` |
| 472 | rows, err := database.DB.Query(sql, user.SteamID) | 484 | rows, err = database.DB.Query(sql, user.SteamID) |
| 473 | if err != nil { | 485 | if err != nil { |
| 474 | c.JSON(http.StatusOK, models.ErrorResponse(err.Error())) | 486 | c.JSON(http.StatusOK, models.ErrorResponse(err.Error())) |
| 475 | return | 487 | return |
| @@ -762,7 +774,7 @@ func FetchUser(c *gin.Context) { | |||
| 762 | UserName: user.UserName, | 774 | UserName: user.UserName, |
| 763 | AvatarLink: user.AvatarLink, | 775 | AvatarLink: user.AvatarLink, |
| 764 | CountryCode: user.CountryCode, | 776 | CountryCode: user.CountryCode, |
| 765 | Titles: user.Titles, | 777 | Titles: titles, |
| 766 | Links: links, | 778 | Links: links, |
| 767 | Rankings: rankings, | 779 | Rankings: rankings, |
| 768 | Records: records, | 780 | Records: records, |