Badges are useless on most requests.
This commit is contained in:
parent
98c8206946
commit
62969581bf
|
@ -4,7 +4,6 @@ import (
|
|||
"database/sql"
|
||||
"encoding/json"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/osuripple/api/common"
|
||||
|
@ -44,7 +43,7 @@ func FriendsGET(md common.MethodData) (r common.Response) {
|
|||
SELECT
|
||||
users.id, users.username, users.register_datetime, users.rank, users.latest_activity,
|
||||
|
||||
users_stats.username_aka, users_stats.badges_shown,
|
||||
users_stats.username_aka,
|
||||
users_stats.country, users_stats.show_country
|
||||
FROM users_relationships
|
||||
LEFT JOIN users
|
||||
|
@ -88,9 +87,8 @@ func friendPuts(md common.MethodData, row *sql.Rows) (user friendData) {
|
|||
|
||||
registeredOn := int64(0)
|
||||
latestActivity := int64(0)
|
||||
var badges string
|
||||
var showcountry bool
|
||||
err = row.Scan(&user.ID, &user.Username, ®isteredOn, &user.Rank, &latestActivity, &user.UsernameAKA, &badges, &user.Country, &showcountry)
|
||||
err = row.Scan(&user.ID, &user.Username, ®isteredOn, &user.Rank, &latestActivity, &user.UsernameAKA, &user.Country, &showcountry)
|
||||
if err != nil {
|
||||
md.Err(err)
|
||||
return
|
||||
|
@ -99,18 +97,6 @@ func friendPuts(md common.MethodData, row *sql.Rows) (user friendData) {
|
|||
user.RegisteredOn = time.Unix(registeredOn, 0)
|
||||
user.LatestActivity = time.Unix(latestActivity, 0)
|
||||
|
||||
badgesSl := strings.Split(badges, ",")
|
||||
for _, badge := range badgesSl {
|
||||
if badge != "" && badge != "0" {
|
||||
// We are ignoring errors because who really gives a shit if something's gone wrong on our end in this
|
||||
// particular thing, we can just silently ignore this.
|
||||
nb, err := strconv.Atoi(badge)
|
||||
if err == nil && nb != 0 {
|
||||
user.Badges = append(user.Badges, nb)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If the user wants to stay anonymous, don't show their country.
|
||||
// This can be overriden if we have the ReadConfidential privilege and the user we are accessing is the token owner.
|
||||
if !(showcountry || (md.User.Privileges.HasPrivilegeReadConfidential() && user.ID == md.ID())) {
|
||||
|
|
|
@ -20,7 +20,6 @@ type userData struct {
|
|||
Rank int `json:"rank"`
|
||||
LatestActivity time.Time `json:"latest_activity"`
|
||||
Country string `json:"country"`
|
||||
Badges []int `json:"badges"`
|
||||
}
|
||||
|
||||
// UserByIDGET is the API handler for GET /users/id/:id
|
||||
|
@ -58,7 +57,7 @@ func UserByNameGET(md common.MethodData) (r common.Response) {
|
|||
|
||||
query := `
|
||||
SELECT users.id, users.username, register_datetime, rank,
|
||||
latest_activity, users_stats.username_aka, users_stats.badges_shown,
|
||||
latest_activity, users_stats.username_aka,
|
||||
users_stats.country, users_stats.show_country
|
||||
FROM users
|
||||
LEFT JOIN users_stats
|
||||
|
@ -76,10 +75,9 @@ func userPuts(md common.MethodData, row *sql.Row) (r common.Response) {
|
|||
var (
|
||||
registeredOn int64
|
||||
latestActivity int64
|
||||
badges string
|
||||
showCountry bool
|
||||
)
|
||||
err = row.Scan(&user.ID, &user.Username, ®isteredOn, &user.Rank, &latestActivity, &user.UsernameAKA, &badges, &user.Country, &showCountry)
|
||||
err = row.Scan(&user.ID, &user.Username, ®isteredOn, &user.Rank, &latestActivity, &user.UsernameAKA, &user.Country, &showCountry)
|
||||
switch {
|
||||
case err == sql.ErrNoRows:
|
||||
r.Code = 404
|
||||
|
@ -94,8 +92,6 @@ func userPuts(md common.MethodData, row *sql.Row) (r common.Response) {
|
|||
user.RegisteredOn = time.Unix(registeredOn, 0)
|
||||
user.LatestActivity = time.Unix(latestActivity, 0)
|
||||
|
||||
user.Badges = badgesToArray(badges)
|
||||
|
||||
user.Country = genCountry(md, user.ID, showCountry, user.Country)
|
||||
|
||||
r.Code = 200
|
||||
|
@ -174,6 +170,7 @@ type userFullData struct {
|
|||
Mania modeData `json:"mania"`
|
||||
PlayStyle int `json:"play_style"`
|
||||
FavouriteMode int `json:"favourite_mode"`
|
||||
Badges []int `json:"badges"`
|
||||
}
|
||||
|
||||
// UserFullGET gets all of an user's information, with one exception: their userpage.
|
||||
|
|
Loading…
Reference in New Issue
Block a user