added avg ping recording

This commit is contained in:
2022-12-29 18:47:37 +01:00
parent f6f73096e0
commit 0060e82aff
11 changed files with 334 additions and 20 deletions

View File

@@ -81,6 +81,8 @@ type MatchPlayer struct {
PlayerStats uint64 `json:"player_stats,omitempty"`
// FlashAssists holds the value of the "flash_assists" field.
FlashAssists int `json:"flash_assists,omitempty"`
// AvgPing holds the value of the "avg_ping" field.
AvgPing float64 `json:"avg_ping,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the MatchPlayerQuery when eager-loading is set.
Edges MatchPlayerEdges `json:"edges"`
@@ -172,7 +174,7 @@ func (*MatchPlayer) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case matchplayer.FieldFlashDurationSelf, matchplayer.FieldFlashDurationTeam, matchplayer.FieldFlashDurationEnemy:
case matchplayer.FieldFlashDurationSelf, matchplayer.FieldFlashDurationTeam, matchplayer.FieldFlashDurationEnemy, matchplayer.FieldAvgPing:
values[i] = new(sql.NullFloat64)
case matchplayer.FieldID, matchplayer.FieldTeamID, matchplayer.FieldKills, matchplayer.FieldDeaths, matchplayer.FieldAssists, matchplayer.FieldHeadshot, matchplayer.FieldMvp, matchplayer.FieldScore, matchplayer.FieldRankNew, matchplayer.FieldRankOld, matchplayer.FieldMk2, matchplayer.FieldMk3, matchplayer.FieldMk4, matchplayer.FieldMk5, matchplayer.FieldDmgEnemy, matchplayer.FieldDmgTeam, matchplayer.FieldUdHe, matchplayer.FieldUdFlames, matchplayer.FieldUdFlash, matchplayer.FieldUdDecoy, matchplayer.FieldUdSmoke, matchplayer.FieldKast, matchplayer.FieldFlashTotalSelf, matchplayer.FieldFlashTotalTeam, matchplayer.FieldFlashTotalEnemy, matchplayer.FieldMatchStats, matchplayer.FieldPlayerStats, matchplayer.FieldFlashAssists:
values[i] = new(sql.NullInt64)
@@ -391,6 +393,12 @@ func (mp *MatchPlayer) assignValues(columns []string, values []any) error {
} else if value.Valid {
mp.FlashAssists = int(value.Int64)
}
case matchplayer.FieldAvgPing:
if value, ok := values[i].(*sql.NullFloat64); !ok {
return fmt.Errorf("unexpected type %T for field avg_ping", values[i])
} else if value.Valid {
mp.AvgPing = value.Float64
}
}
}
return nil
@@ -544,6 +552,9 @@ func (mp *MatchPlayer) String() string {
builder.WriteString(", ")
builder.WriteString("flash_assists=")
builder.WriteString(fmt.Sprintf("%v", mp.FlashAssists))
builder.WriteString(", ")
builder.WriteString("avg_ping=")
builder.WriteString(fmt.Sprintf("%v", mp.AvgPing))
builder.WriteByte(')')
return builder.String()
}