Update clan.go

This commit is contained in:
Alicia 2019-02-24 14:29:19 +00:00
parent 2b02e0eaea
commit e5b83bb11c

View File

@ -86,8 +86,8 @@ func AllClanStatsGET(md common.MethodData) common.CodeMessager {
rows *sql.Rows rows *sql.Rows
err error err error
) )
rows, err = md.DB.Query("SELECT id, name, description, icon FROM clans") rows, err = md.DB.Query("SELECT id, name, description, tag, icon FROM clans")
if err != nil { if err != nil {
md.Err(err) md.Err(err)
return Err500 return Err500
@ -95,7 +95,9 @@ func AllClanStatsGET(md common.MethodData) common.CodeMessager {
defer rows.Close() defer rows.Close()
for rows.Next() { for rows.Next() {
nc := clanLbSingle{} nc := clanLbSingle{}
err = rows.Scan(&nc.ID, &nc.Name, &nc.Description, &nc.Icon) err = rows.Scan(&nc.ID, &nc.Name, &nc.Description, &nc.Tag, &nc.Icon)
fmt.Println(rows)
fmt.Println(&nc.Tag)
if err != nil { if err != nil {
md.Err(err) md.Err(err)
} }
@ -108,7 +110,7 @@ func AllClanStatsGET(md common.MethodData) common.CodeMessager {
r.ResponseBase.Code = 200 r.ResponseBase.Code = 200
// anyone who ever looks into this, yes, i need to kill myself. ~Flame // anyone who ever looks into this, yes, i need to kill myself. ~Flame
m, brr := strconv.ParseInt(string(md.Query("m")[19]), 10, 64) m, brr := strconv.ParseInt(string(md.Query("m")[19]), 10, 64)
if brr != nil { if brr != nil {
fmt.Println(brr) fmt.Println(brr)
m = 0 m = 0
@ -124,13 +126,12 @@ func AllClanStatsGET(md common.MethodData) common.CodeMessager {
n = "std" n = "std"
} }
fmt.Println(n) 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
rid := r.Clans[i].ID rid := r.Clans[i].ID
err := md.DB.Select(&members.Members, `SELECT users.id, users.username, users.register_datetime, users.privileges, err := md.DB.Select(&members.Members, `SELECT users.id, users.username, users.register_datetime, users.privileges,
latest_activity, users_stats.username_aka, latest_activity, users_stats.username_aka,
@ -152,7 +153,7 @@ func AllClanStatsGET(md common.MethodData) common.CodeMessager {
} }
members.Code = 200 members.Code = 200
if n == "std" { if n == "std" {
for u := 0; u < len(members.Members); u++ { for u := 0; u < len(members.Members); u++ {
r.Clans[i].ChosenMode.PP = r.Clans[i].ChosenMode.PP + members.Members[u].PpStd r.Clans[i].ChosenMode.PP = r.Clans[i].ChosenMode.PP + members.Members[u].PpStd
@ -184,20 +185,21 @@ func AllClanStatsGET(md common.MethodData) common.CodeMessager {
} }
r.Clans[i].ChosenMode.PP = (r.Clans[i].ChosenMode.PP / (len(members.Members) + 1)) r.Clans[i].ChosenMode.PP = (r.Clans[i].ChosenMode.PP / (len(members.Members) + 1))
} }
sort.Slice(r.Clans, func(i, j int) bool { sort.Slice(r.Clans, func(i, j int) bool {
return r.Clans[i].ChosenMode.PP > r.Clans[j].ChosenMode.PP return r.Clans[i].ChosenMode.PP > r.Clans[j].ChosenMode.PP
}) })
for i := 0; i < len(r.Clans); i++ { for i := 0; i < len(r.Clans); i++ {
r.Clans[i].Rank = i+1 r.Clans[i].Rank = i + 1
} }
return r return r
} }
func TotalClanStatsGET(md common.MethodData) common.CodeMessager { func TotalClanStatsGET(md common.MethodData) common.CodeMessager {
var ( var (
r megaStats r megaStats