fixed responses

This commit is contained in:
2021-10-13 16:15:58 +02:00
parent 4b7851da83
commit c35df3a8b5
2 changed files with 36 additions and 3 deletions

View File

@@ -159,6 +159,13 @@ func (p *DemoParser) parseWorker() {
return
}
tAttacker := p.getMatchPlayerBySteamID(tStats, e.Attacker.SteamID64)
if e.Attacker.Team == e.Player.Team {
tAttacker.DmgTeam += uint(e.HealthDamageTaken)
} else {
tAttacker.DmgEnemy += uint(e.HealthDamageTaken)
}
if _, ok := eqMap[e.Attacker.SteamID64]; !ok {
eqMap[e.Attacker.SteamID64] = make([]*struct {
Eq int
@@ -311,6 +318,22 @@ func (p *DemoParser) parseWorker() {
SetUdFlash(tMatchPlayer.UdFlash).
SetUdSmoke(tMatchPlayer.UdSmoke).
SetUdFlames(tMatchPlayer.UdFlames).
SetMk2(tMatchPlayer.Mk2).
SetMk3(tMatchPlayer.Mk3).
SetMk4(tMatchPlayer.Mk4).
SetMk5(tMatchPlayer.Mk5).
SetRankOld(tMatchPlayer.RankOld).
SetRankNew(tMatchPlayer.RankNew).
SetColor(tMatchPlayer.Color).
SetCrosshair(tMatchPlayer.Crosshair).
SetFlashDurationTeam(tMatchPlayer.FlashDurationTeam).
SetFlashDurationSelf(tMatchPlayer.FlashDurationSelf).
SetFlashDurationEnemy(tMatchPlayer.FlashDurationEnemy).
SetFlashTotalEnemy(tMatchPlayer.FlashTotalEnemy).
SetFlashTotalSelf(tMatchPlayer.FlashTotalSelf).
SetFlashTotalTeam(tMatchPlayer.FlashTotalTeam).
SetDmgTeam(tMatchPlayer.DmgTeam).
SetDmgEnemy(tMatchPlayer.DmgEnemy).
Save(context.Background())
p.lock.Unlock()
if err != nil {

16
main.go
View File

@@ -121,7 +121,7 @@ type StatsResponse struct {
Enemy uint `json:"enemy,omitempty"`
Self uint `json:"self,omitempty"`
} `json:"total,omitempty"`
} `json:"extended,omitempty"`
} `json:"flash,omitempty"`
Crosshair string `json:"crosshair,omitempty"`
Color string `json:"color,omitempty"`
KAST int `json:"kast,omitempty"`
@@ -221,12 +221,15 @@ func getPlayer(w http.ResponseWriter, r *http.Request) {
Name: tPlayer.Name,
Avatar: tPlayer.AvatarURL,
VAC: tPlayer.Vac,
VACDate: tPlayer.VacDate,
VanityURL: tPlayer.VanityURLReal,
Tracked: tPlayer.AuthCode != "",
Matches: []*MatchResponse{},
}
if !tPlayer.VacDate.IsZero() {
response.VACDate = tPlayer.VacDate
}
db.Lock.RLock()
tMatches, err := tPlayer.QueryMatches().Order(ent.Desc(match.FieldDate)).Limit(10).All(context.Background())
db.Lock.RUnlock()
@@ -289,7 +292,7 @@ func getPlayer(w http.ResponseWriter, r *http.Request) {
tStats, err := iMatch.QueryStats().Modify(func(s *sql.Selector) {
s.Select(stats.FieldTeamID, stats.FieldKills, stats.FieldDeaths, stats.FieldAssists, stats.FieldHeadshot,
stats.FieldMvp, stats.FieldScore, stats.FieldMk2, stats.FieldMk3, stats.FieldMk4, stats.FieldMk5,
stats.FieldRankOld, stats.FieldRankNew)
stats.FieldRankOld, stats.FieldRankNew, stats.FieldDmgTeam, stats.FieldDmgEnemy)
s.Where(sql.EQ(s.C(stats.PlayersColumn), tPlayer.ID))
}).Only(context.Background())
db.Lock.RUnlock()
@@ -316,6 +319,9 @@ func getPlayer(w http.ResponseWriter, r *http.Request) {
sResponse.Rank.Old = tStats.RankOld
sResponse.Rank.New = tStats.RankNew
sResponse.Dmg.Enemy = tStats.DmgEnemy
sResponse.Dmg.Team = tStats.DmgTeam
mResponse.Stats = sResponse
response.Matches = append(response.Matches, mResponse)
}
@@ -497,6 +503,10 @@ func getMatch(w http.ResponseWriter, r *http.Request) {
sResponse.Flash.Duration.Enemy = iStats.FlashDurationEnemy
sResponse.Flash.Duration.Team = iStats.FlashDurationTeam
sResponse.Flash.Duration.Self = iStats.FlashDurationSelf
sResponse.MultiKills.Duo = iStats.Mk2
sResponse.MultiKills.Triple = iStats.Mk3
sResponse.MultiKills.Quad = iStats.Mk4
sResponse.MultiKills.Pent = iStats.Mk5
if !iStats.Edges.Players.VacDate.IsZero() {
switch s := sResponse.Player.(type) {