fixed match win/loss/ties
This commit is contained in:
22
main.go
22
main.go
@@ -50,10 +50,10 @@ type PlayerResponse struct {
|
||||
Tracked bool `json:"tracked"`
|
||||
VanityURL string `json:"vanity_url,omitempty"`
|
||||
MatchStats struct {
|
||||
Win int
|
||||
Tie int
|
||||
Loss int
|
||||
} `json:"match_stats"`
|
||||
Win int `json:"win,omitempty"`
|
||||
Tie int `json:"tie,omitempty"`
|
||||
Loss int `json:"loss,omitempty"`
|
||||
} `json:"match_stats,omitempty"`
|
||||
Matches []*MatchResponse `json:"matches,omitempty"`
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ func getPlayer(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
response := PlayerResponse{
|
||||
SteamID64: tPlayer.Steamid,
|
||||
SteamID64: tPlayer.ID,
|
||||
Name: tPlayer.Name,
|
||||
Avatar: tPlayer.AvatarURL,
|
||||
VAC: tPlayer.Vac,
|
||||
@@ -185,7 +185,7 @@ func getPlayer(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
for _, iMatch := range tMatches {
|
||||
mResponse := &MatchResponse{
|
||||
MatchId: iMatch.MatchID,
|
||||
MatchId: iMatch.ID,
|
||||
ShareCode: iMatch.ShareCode,
|
||||
Map: iMatch.Map,
|
||||
Date: iMatch.Date,
|
||||
@@ -198,7 +198,7 @@ func getPlayer(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
db.Lock.RLock()
|
||||
tStats, err := iMatch.QueryStats().Where(stats.HasPlayersWith(player.Steamid(tPlayer.Steamid))).WithPlayers().All(context.Background())
|
||||
tStats, err := iMatch.QueryStats().Where(stats.HasPlayersWith(player.ID(tPlayer.ID))).WithPlayers().All(context.Background())
|
||||
db.Lock.RUnlock()
|
||||
if err != nil {
|
||||
response.Matches = append(response.Matches, mResponse)
|
||||
@@ -312,7 +312,7 @@ func getMatch(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
db.Lock.RLock()
|
||||
tMatch, err := db.Client.Match.Query().Where(match.MatchID(matchId)).Only(context.Background())
|
||||
tMatch, err := db.Client.Match.Query().Where(match.ID(matchId)).Only(context.Background())
|
||||
db.Lock.RUnlock()
|
||||
if err != nil {
|
||||
log.Warningf("[GM] match %d not found: %+v", matchId, err)
|
||||
@@ -320,7 +320,7 @@ func getMatch(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
mResponse := &MatchResponse{
|
||||
MatchId: tMatch.MatchID,
|
||||
MatchId: tMatch.ID,
|
||||
ShareCode: tMatch.ShareCode,
|
||||
Map: tMatch.Map,
|
||||
Date: tMatch.Date,
|
||||
@@ -336,13 +336,13 @@ func getMatch(w http.ResponseWriter, r *http.Request) {
|
||||
tStats, err := tMatch.QueryStats().WithPlayers().All(context.Background())
|
||||
db.Lock.RUnlock()
|
||||
if err != nil {
|
||||
log.Errorf("[GM] can't find stats for match %d: %v", tMatch.MatchID, err)
|
||||
log.Errorf("[GM] can't find stats for match %d: %v", tMatch.ID, err)
|
||||
}
|
||||
|
||||
for _, iStats := range tStats {
|
||||
sResponse := &StatsResponse{
|
||||
Player: PlayerResponse{
|
||||
SteamID64: iStats.Edges.Players.Steamid,
|
||||
SteamID64: iStats.Edges.Players.ID,
|
||||
Name: iStats.Edges.Players.Name,
|
||||
Avatar: iStats.Edges.Players.AvatarURL,
|
||||
VAC: iStats.Edges.Players.Vac,
|
||||
|
Reference in New Issue
Block a user