add clan info to api

This commit is contained in:
Alicia 2019-02-24 14:37:51 +00:00
parent e5b83bb11c
commit 950340a04d
2 changed files with 47 additions and 9 deletions

View File

@ -233,9 +233,6 @@ func TotalClanStatsGET(md common.MethodData) common.CodeMessager {
} }
//RETARD CODE HAHAAAA //RETARD CODE HAHAAAA
m, brr := strconv.ParseInt(string(md.Query("m")[11]), 10, 64) m, brr := strconv.ParseInt(string(md.Query("m")[11]), 10, 64)
if brr != nil {
fmt.Println(brr)
}
n := "std" n := "std"
if m == 1 { if m == 1 {
@ -247,8 +244,6 @@ func TotalClanStatsGET(md common.MethodData) common.CodeMessager {
} else { } else {
n = "std" n = "std"
} }
fmt.Println(n)
for i := 0; i < len(r.Clans); i++ { for i := 0; i < len(r.Clans); i++ {
var members clanMembersData var members clanMembersData
@ -271,10 +266,6 @@ func TotalClanStatsGET(md common.MethodData) common.CodeMessager {
WHERE clan = ? AND privileges & 1 = 1 WHERE clan = ? AND privileges & 1 = 1
`, rid) `, rid)
if err != nil {
fmt.Println(err)
}
members.Code = 200 members.Code = 200
if n == "std" { if n == "std" {

View File

@ -234,6 +234,7 @@ type userFullResponse struct {
PlayStyle int `json:"play_style"` PlayStyle int `json:"play_style"`
FavouriteMode int `json:"favourite_mode"` FavouriteMode int `json:"favourite_mode"`
Badges []singleBadge `json:"badges"` Badges []singleBadge `json:"badges"`
Clan singleClan `json:"clan"`
CustomBadge *singleBadge `json:"custom_badge"` CustomBadge *singleBadge `json:"custom_badge"`
SilenceInfo silenceInfo `json:"silence_info"` SilenceInfo silenceInfo `json:"silence_info"`
CMNotes *string `json:"cm_notes,omitempty"` CMNotes *string `json:"cm_notes,omitempty"`
@ -367,6 +368,22 @@ LIMIT 1
r.BanDate = nil r.BanDate = nil
r.Email = "" r.Email = ""
} }
rows, err = md.DB.Query("SELECT c.id, c.name, c.description, c.tag, c.icon FROM user_clans uc "+
"LEFT JOIN clans c ON uc.clan = c.id WHERE user = ?", r.ID)
if err != nil {
md.Err(err)
}
for rows.Next() {
var clan singleClan
err = rows.Scan(&clan.ID, &clan.Name, &clan.Description, &clan.Tag, &clan.Icon)
if err != nil {
md.Err(err)
continue
}
r.Clan = clan
}
r.Code = 200 r.Code = 200
return r return r
@ -491,6 +508,21 @@ LIMIT 1
r.BanDate = nil r.BanDate = nil
r.Email = "" r.Email = ""
} }
rows, err = md.DB.Query("SELECT c.id, c.name, c.description, c.tag, c.icon FROM user_clans uc "+
"LEFT JOIN clans c ON uc.clan = c.id WHERE user = ?", r.ID)
if err != nil {
md.Err(err)
}
for rows.Next() {
var clan singleClan
err = rows.Scan(&clan.ID, &clan.Name, &clan.Description, &clan.Tag, &clan.Icon)
if err != nil {
md.Err(err)
continue
}
r.Clan = clan
}
r.Code = 200 r.Code = 200
return r return r
@ -615,6 +647,21 @@ LIMIT 1
r.BanDate = nil r.BanDate = nil
r.Email = "" r.Email = ""
} }
rows, err = md.DB.Query("SELECT c.id, c.name, c.description, c.tag, c.icon FROM user_clans uc "+
"LEFT JOIN clans c ON uc.clan = c.id WHERE user = ?", r.ID)
if err != nil {
md.Err(err)
}
for rows.Next() {
var clan singleClan
err = rows.Scan(&clan.ID, &clan.Name, &clan.Description, &clan.Tag, &clan.Icon)
if err != nil {
md.Err(err)
continue
}
r.Clan = clan
}
r.Code = 200 r.Code = 200
return r return r