added avg ping recording
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
||||
"git.harting.dev/csgowtf/csgowtfd/utils"
|
||||
"github.com/aclements/go-moremath/stats"
|
||||
"github.com/golang/geo/r2"
|
||||
"github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs"
|
||||
"github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs/common"
|
||||
@@ -249,9 +250,10 @@ workloop:
|
||||
EqV int
|
||||
Bank int
|
||||
Spent int
|
||||
}, 0)
|
||||
})
|
||||
encounters := make([]*Encounter, 0)
|
||||
spays := make([]*Sprays, 0)
|
||||
pingMap := make(map[uint64][]float64)
|
||||
|
||||
cfg := demoinfocs.DefaultParserConfig
|
||||
if len(demo.DecryptionKey) == 16 { //nolint:gomnd
|
||||
@@ -374,6 +376,11 @@ workloop:
|
||||
Spent int
|
||||
}{Round: gs.TotalRoundsPlayed(), EqV: p.EquipmentValueCurrent(), Bank: p.Money(), Spent: p.MoneySpentThisRound()})
|
||||
}
|
||||
|
||||
// track ping
|
||||
for _, p := range gs.Participants().Playing() {
|
||||
pingMap[p.SteamID64] = append(pingMap[p.SteamID64], float64(p.Ping()))
|
||||
}
|
||||
})
|
||||
|
||||
// onPlayerFlashed
|
||||
@@ -474,6 +481,8 @@ workloop:
|
||||
tMatchPlayer.Color = matchplayer.ColorGrey
|
||||
}
|
||||
|
||||
avgPing := stats.GeoMean(pingMap[tMatchPlayer.PlayerStats])
|
||||
|
||||
nMatchPLayer, err := tMatchPlayer.Update().
|
||||
SetDmgTeam(tMatchPlayer.DmgTeam).
|
||||
SetDmgEnemy(tMatchPlayer.DmgEnemy).
|
||||
@@ -484,6 +493,7 @@ workloop:
|
||||
SetRankOld(tMatchPlayer.RankOld).
|
||||
SetRankNew(tMatchPlayer.RankNew).
|
||||
SetColor(tMatchPlayer.Color).
|
||||
SetAvgPing(avgPing).
|
||||
SetCrosshair(tMatchPlayer.Crosshair).
|
||||
SetFlashDurationTeam(tMatchPlayer.FlashDurationTeam).
|
||||
SetFlashDurationSelf(tMatchPlayer.FlashDurationSelf).
|
||||
|
@@ -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()
|
||||
}
|
||||
|
@@ -75,6 +75,8 @@ const (
|
||||
FieldPlayerStats = "player_stats"
|
||||
// FieldFlashAssists holds the string denoting the flash_assists field in the database.
|
||||
FieldFlashAssists = "flash_assists"
|
||||
// FieldAvgPing holds the string denoting the avg_ping field in the database.
|
||||
FieldAvgPing = "avg_ping"
|
||||
// EdgeMatches holds the string denoting the matches edge name in mutations.
|
||||
EdgeMatches = "matches"
|
||||
// EdgePlayers holds the string denoting the players edge name in mutations.
|
||||
@@ -168,6 +170,7 @@ var Columns = []string{
|
||||
FieldMatchStats,
|
||||
FieldPlayerStats,
|
||||
FieldFlashAssists,
|
||||
FieldAvgPing,
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
|
@@ -296,6 +296,13 @@ func FlashAssists(v int) predicate.MatchPlayer {
|
||||
})
|
||||
}
|
||||
|
||||
// AvgPing applies equality check predicate on the "avg_ping" field. It's identical to AvgPingEQ.
|
||||
func AvgPing(v float64) predicate.MatchPlayer {
|
||||
return predicate.MatchPlayer(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldAvgPing), v))
|
||||
})
|
||||
}
|
||||
|
||||
// TeamIDEQ applies the EQ predicate on the "team_id" field.
|
||||
func TeamIDEQ(v int) predicate.MatchPlayer {
|
||||
return predicate.MatchPlayer(func(s *sql.Selector) {
|
||||
@@ -2645,6 +2652,84 @@ func FlashAssistsNotNil() predicate.MatchPlayer {
|
||||
})
|
||||
}
|
||||
|
||||
// AvgPingEQ applies the EQ predicate on the "avg_ping" field.
|
||||
func AvgPingEQ(v float64) predicate.MatchPlayer {
|
||||
return predicate.MatchPlayer(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldAvgPing), v))
|
||||
})
|
||||
}
|
||||
|
||||
// AvgPingNEQ applies the NEQ predicate on the "avg_ping" field.
|
||||
func AvgPingNEQ(v float64) predicate.MatchPlayer {
|
||||
return predicate.MatchPlayer(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldAvgPing), v))
|
||||
})
|
||||
}
|
||||
|
||||
// AvgPingIn applies the In predicate on the "avg_ping" field.
|
||||
func AvgPingIn(vs ...float64) predicate.MatchPlayer {
|
||||
v := make([]any, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.MatchPlayer(func(s *sql.Selector) {
|
||||
s.Where(sql.In(s.C(FieldAvgPing), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// AvgPingNotIn applies the NotIn predicate on the "avg_ping" field.
|
||||
func AvgPingNotIn(vs ...float64) predicate.MatchPlayer {
|
||||
v := make([]any, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.MatchPlayer(func(s *sql.Selector) {
|
||||
s.Where(sql.NotIn(s.C(FieldAvgPing), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// AvgPingGT applies the GT predicate on the "avg_ping" field.
|
||||
func AvgPingGT(v float64) predicate.MatchPlayer {
|
||||
return predicate.MatchPlayer(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldAvgPing), v))
|
||||
})
|
||||
}
|
||||
|
||||
// AvgPingGTE applies the GTE predicate on the "avg_ping" field.
|
||||
func AvgPingGTE(v float64) predicate.MatchPlayer {
|
||||
return predicate.MatchPlayer(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldAvgPing), v))
|
||||
})
|
||||
}
|
||||
|
||||
// AvgPingLT applies the LT predicate on the "avg_ping" field.
|
||||
func AvgPingLT(v float64) predicate.MatchPlayer {
|
||||
return predicate.MatchPlayer(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldAvgPing), v))
|
||||
})
|
||||
}
|
||||
|
||||
// AvgPingLTE applies the LTE predicate on the "avg_ping" field.
|
||||
func AvgPingLTE(v float64) predicate.MatchPlayer {
|
||||
return predicate.MatchPlayer(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldAvgPing), v))
|
||||
})
|
||||
}
|
||||
|
||||
// AvgPingIsNil applies the IsNil predicate on the "avg_ping" field.
|
||||
func AvgPingIsNil() predicate.MatchPlayer {
|
||||
return predicate.MatchPlayer(func(s *sql.Selector) {
|
||||
s.Where(sql.IsNull(s.C(FieldAvgPing)))
|
||||
})
|
||||
}
|
||||
|
||||
// AvgPingNotNil applies the NotNil predicate on the "avg_ping" field.
|
||||
func AvgPingNotNil() predicate.MatchPlayer {
|
||||
return predicate.MatchPlayer(func(s *sql.Selector) {
|
||||
s.Where(sql.NotNull(s.C(FieldAvgPing)))
|
||||
})
|
||||
}
|
||||
|
||||
// HasMatches applies the HasEdge predicate on the "matches" edge.
|
||||
func HasMatches() predicate.MatchPlayer {
|
||||
return predicate.MatchPlayer(func(s *sql.Selector) {
|
||||
|
@@ -417,6 +417,20 @@ func (mpc *MatchPlayerCreate) SetNillableFlashAssists(i *int) *MatchPlayerCreate
|
||||
return mpc
|
||||
}
|
||||
|
||||
// SetAvgPing sets the "avg_ping" field.
|
||||
func (mpc *MatchPlayerCreate) SetAvgPing(f float64) *MatchPlayerCreate {
|
||||
mpc.mutation.SetAvgPing(f)
|
||||
return mpc
|
||||
}
|
||||
|
||||
// SetNillableAvgPing sets the "avg_ping" field if the given value is not nil.
|
||||
func (mpc *MatchPlayerCreate) SetNillableAvgPing(f *float64) *MatchPlayerCreate {
|
||||
if f != nil {
|
||||
mpc.SetAvgPing(*f)
|
||||
}
|
||||
return mpc
|
||||
}
|
||||
|
||||
// SetMatchesID sets the "matches" edge to the Match entity by ID.
|
||||
func (mpc *MatchPlayerCreate) SetMatchesID(id uint64) *MatchPlayerCreate {
|
||||
mpc.mutation.SetMatchesID(id)
|
||||
@@ -764,6 +778,10 @@ func (mpc *MatchPlayerCreate) createSpec() (*MatchPlayer, *sqlgraph.CreateSpec)
|
||||
_spec.SetField(matchplayer.FieldFlashAssists, field.TypeInt, value)
|
||||
_node.FlashAssists = value
|
||||
}
|
||||
if value, ok := mpc.mutation.AvgPing(); ok {
|
||||
_spec.SetField(matchplayer.FieldAvgPing, field.TypeFloat64, value)
|
||||
_node.AvgPing = value
|
||||
}
|
||||
if nodes := mpc.mutation.MatchesIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
|
@@ -772,6 +772,33 @@ func (mpu *MatchPlayerUpdate) ClearFlashAssists() *MatchPlayerUpdate {
|
||||
return mpu
|
||||
}
|
||||
|
||||
// SetAvgPing sets the "avg_ping" field.
|
||||
func (mpu *MatchPlayerUpdate) SetAvgPing(f float64) *MatchPlayerUpdate {
|
||||
mpu.mutation.ResetAvgPing()
|
||||
mpu.mutation.SetAvgPing(f)
|
||||
return mpu
|
||||
}
|
||||
|
||||
// SetNillableAvgPing sets the "avg_ping" field if the given value is not nil.
|
||||
func (mpu *MatchPlayerUpdate) SetNillableAvgPing(f *float64) *MatchPlayerUpdate {
|
||||
if f != nil {
|
||||
mpu.SetAvgPing(*f)
|
||||
}
|
||||
return mpu
|
||||
}
|
||||
|
||||
// AddAvgPing adds f to the "avg_ping" field.
|
||||
func (mpu *MatchPlayerUpdate) AddAvgPing(f float64) *MatchPlayerUpdate {
|
||||
mpu.mutation.AddAvgPing(f)
|
||||
return mpu
|
||||
}
|
||||
|
||||
// ClearAvgPing clears the value of the "avg_ping" field.
|
||||
func (mpu *MatchPlayerUpdate) ClearAvgPing() *MatchPlayerUpdate {
|
||||
mpu.mutation.ClearAvgPing()
|
||||
return mpu
|
||||
}
|
||||
|
||||
// SetMatchesID sets the "matches" edge to the Match entity by ID.
|
||||
func (mpu *MatchPlayerUpdate) SetMatchesID(id uint64) *MatchPlayerUpdate {
|
||||
mpu.mutation.SetMatchesID(id)
|
||||
@@ -1308,6 +1335,15 @@ func (mpu *MatchPlayerUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if mpu.mutation.FlashAssistsCleared() {
|
||||
_spec.ClearField(matchplayer.FieldFlashAssists, field.TypeInt)
|
||||
}
|
||||
if value, ok := mpu.mutation.AvgPing(); ok {
|
||||
_spec.SetField(matchplayer.FieldAvgPing, field.TypeFloat64, value)
|
||||
}
|
||||
if value, ok := mpu.mutation.AddedAvgPing(); ok {
|
||||
_spec.AddField(matchplayer.FieldAvgPing, field.TypeFloat64, value)
|
||||
}
|
||||
if mpu.mutation.AvgPingCleared() {
|
||||
_spec.ClearField(matchplayer.FieldAvgPing, field.TypeFloat64)
|
||||
}
|
||||
if mpu.mutation.MatchesCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
@@ -2353,6 +2389,33 @@ func (mpuo *MatchPlayerUpdateOne) ClearFlashAssists() *MatchPlayerUpdateOne {
|
||||
return mpuo
|
||||
}
|
||||
|
||||
// SetAvgPing sets the "avg_ping" field.
|
||||
func (mpuo *MatchPlayerUpdateOne) SetAvgPing(f float64) *MatchPlayerUpdateOne {
|
||||
mpuo.mutation.ResetAvgPing()
|
||||
mpuo.mutation.SetAvgPing(f)
|
||||
return mpuo
|
||||
}
|
||||
|
||||
// SetNillableAvgPing sets the "avg_ping" field if the given value is not nil.
|
||||
func (mpuo *MatchPlayerUpdateOne) SetNillableAvgPing(f *float64) *MatchPlayerUpdateOne {
|
||||
if f != nil {
|
||||
mpuo.SetAvgPing(*f)
|
||||
}
|
||||
return mpuo
|
||||
}
|
||||
|
||||
// AddAvgPing adds f to the "avg_ping" field.
|
||||
func (mpuo *MatchPlayerUpdateOne) AddAvgPing(f float64) *MatchPlayerUpdateOne {
|
||||
mpuo.mutation.AddAvgPing(f)
|
||||
return mpuo
|
||||
}
|
||||
|
||||
// ClearAvgPing clears the value of the "avg_ping" field.
|
||||
func (mpuo *MatchPlayerUpdateOne) ClearAvgPing() *MatchPlayerUpdateOne {
|
||||
mpuo.mutation.ClearAvgPing()
|
||||
return mpuo
|
||||
}
|
||||
|
||||
// SetMatchesID sets the "matches" edge to the Match entity by ID.
|
||||
func (mpuo *MatchPlayerUpdateOne) SetMatchesID(id uint64) *MatchPlayerUpdateOne {
|
||||
mpuo.mutation.SetMatchesID(id)
|
||||
@@ -2919,6 +2982,15 @@ func (mpuo *MatchPlayerUpdateOne) sqlSave(ctx context.Context) (_node *MatchPlay
|
||||
if mpuo.mutation.FlashAssistsCleared() {
|
||||
_spec.ClearField(matchplayer.FieldFlashAssists, field.TypeInt)
|
||||
}
|
||||
if value, ok := mpuo.mutation.AvgPing(); ok {
|
||||
_spec.SetField(matchplayer.FieldAvgPing, field.TypeFloat64, value)
|
||||
}
|
||||
if value, ok := mpuo.mutation.AddedAvgPing(); ok {
|
||||
_spec.AddField(matchplayer.FieldAvgPing, field.TypeFloat64, value)
|
||||
}
|
||||
if mpuo.mutation.AvgPingCleared() {
|
||||
_spec.ClearField(matchplayer.FieldAvgPing, field.TypeFloat64)
|
||||
}
|
||||
if mpuo.mutation.MatchesCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
|
@@ -65,6 +65,7 @@ var (
|
||||
{Name: "flash_total_team", Type: field.TypeUint, Nullable: true},
|
||||
{Name: "flash_total_enemy", Type: field.TypeUint, Nullable: true},
|
||||
{Name: "flash_assists", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "avg_ping", Type: field.TypeFloat64, Nullable: true},
|
||||
{Name: "match_stats", Type: field.TypeUint64, Nullable: true},
|
||||
{Name: "player_stats", Type: field.TypeUint64, Nullable: true},
|
||||
}
|
||||
@@ -76,13 +77,13 @@ var (
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "match_players_matches_stats",
|
||||
Columns: []*schema.Column{MatchPlayersColumns[31]},
|
||||
Columns: []*schema.Column{MatchPlayersColumns[32]},
|
||||
RefColumns: []*schema.Column{MatchesColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
{
|
||||
Symbol: "match_players_players_stats",
|
||||
Columns: []*schema.Column{MatchPlayersColumns[32]},
|
||||
Columns: []*schema.Column{MatchPlayersColumns[33]},
|
||||
RefColumns: []*schema.Column{PlayersColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
|
109
ent/mutation.go
109
ent/mutation.go
@@ -1579,6 +1579,8 @@ type MatchPlayerMutation struct {
|
||||
addflash_total_enemy *int
|
||||
flash_assists *int
|
||||
addflash_assists *int
|
||||
avg_ping *float64
|
||||
addavg_ping *float64
|
||||
clearedFields map[string]struct{}
|
||||
matches *uint64
|
||||
clearedmatches bool
|
||||
@@ -3757,6 +3759,76 @@ func (m *MatchPlayerMutation) ResetFlashAssists() {
|
||||
delete(m.clearedFields, matchplayer.FieldFlashAssists)
|
||||
}
|
||||
|
||||
// SetAvgPing sets the "avg_ping" field.
|
||||
func (m *MatchPlayerMutation) SetAvgPing(f float64) {
|
||||
m.avg_ping = &f
|
||||
m.addavg_ping = nil
|
||||
}
|
||||
|
||||
// AvgPing returns the value of the "avg_ping" field in the mutation.
|
||||
func (m *MatchPlayerMutation) AvgPing() (r float64, exists bool) {
|
||||
v := m.avg_ping
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldAvgPing returns the old "avg_ping" field's value of the MatchPlayer entity.
|
||||
// If the MatchPlayer object wasn't provided to the builder, the object is fetched from the database.
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *MatchPlayerMutation) OldAvgPing(ctx context.Context) (v float64, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, errors.New("OldAvgPing is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, errors.New("OldAvgPing requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldAvgPing: %w", err)
|
||||
}
|
||||
return oldValue.AvgPing, nil
|
||||
}
|
||||
|
||||
// AddAvgPing adds f to the "avg_ping" field.
|
||||
func (m *MatchPlayerMutation) AddAvgPing(f float64) {
|
||||
if m.addavg_ping != nil {
|
||||
*m.addavg_ping += f
|
||||
} else {
|
||||
m.addavg_ping = &f
|
||||
}
|
||||
}
|
||||
|
||||
// AddedAvgPing returns the value that was added to the "avg_ping" field in this mutation.
|
||||
func (m *MatchPlayerMutation) AddedAvgPing() (r float64, exists bool) {
|
||||
v := m.addavg_ping
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// ClearAvgPing clears the value of the "avg_ping" field.
|
||||
func (m *MatchPlayerMutation) ClearAvgPing() {
|
||||
m.avg_ping = nil
|
||||
m.addavg_ping = nil
|
||||
m.clearedFields[matchplayer.FieldAvgPing] = struct{}{}
|
||||
}
|
||||
|
||||
// AvgPingCleared returns if the "avg_ping" field was cleared in this mutation.
|
||||
func (m *MatchPlayerMutation) AvgPingCleared() bool {
|
||||
_, ok := m.clearedFields[matchplayer.FieldAvgPing]
|
||||
return ok
|
||||
}
|
||||
|
||||
// ResetAvgPing resets all changes to the "avg_ping" field.
|
||||
func (m *MatchPlayerMutation) ResetAvgPing() {
|
||||
m.avg_ping = nil
|
||||
m.addavg_ping = nil
|
||||
delete(m.clearedFields, matchplayer.FieldAvgPing)
|
||||
}
|
||||
|
||||
// SetMatchesID sets the "matches" edge to the Match entity by id.
|
||||
func (m *MatchPlayerMutation) SetMatchesID(id uint64) {
|
||||
m.matches = &id
|
||||
@@ -4070,7 +4142,7 @@ func (m *MatchPlayerMutation) Type() string {
|
||||
// order to get all numeric fields that were incremented/decremented, call
|
||||
// AddedFields().
|
||||
func (m *MatchPlayerMutation) Fields() []string {
|
||||
fields := make([]string, 0, 32)
|
||||
fields := make([]string, 0, 33)
|
||||
if m.team_id != nil {
|
||||
fields = append(fields, matchplayer.FieldTeamID)
|
||||
}
|
||||
@@ -4167,6 +4239,9 @@ func (m *MatchPlayerMutation) Fields() []string {
|
||||
if m.flash_assists != nil {
|
||||
fields = append(fields, matchplayer.FieldFlashAssists)
|
||||
}
|
||||
if m.avg_ping != nil {
|
||||
fields = append(fields, matchplayer.FieldAvgPing)
|
||||
}
|
||||
return fields
|
||||
}
|
||||
|
||||
@@ -4239,6 +4314,8 @@ func (m *MatchPlayerMutation) Field(name string) (ent.Value, bool) {
|
||||
return m.PlayerStats()
|
||||
case matchplayer.FieldFlashAssists:
|
||||
return m.FlashAssists()
|
||||
case matchplayer.FieldAvgPing:
|
||||
return m.AvgPing()
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
@@ -4312,6 +4389,8 @@ func (m *MatchPlayerMutation) OldField(ctx context.Context, name string) (ent.Va
|
||||
return m.OldPlayerStats(ctx)
|
||||
case matchplayer.FieldFlashAssists:
|
||||
return m.OldFlashAssists(ctx)
|
||||
case matchplayer.FieldAvgPing:
|
||||
return m.OldAvgPing(ctx)
|
||||
}
|
||||
return nil, fmt.Errorf("unknown MatchPlayer field %s", name)
|
||||
}
|
||||
@@ -4545,6 +4624,13 @@ func (m *MatchPlayerMutation) SetField(name string, value ent.Value) error {
|
||||
}
|
||||
m.SetFlashAssists(v)
|
||||
return nil
|
||||
case matchplayer.FieldAvgPing:
|
||||
v, ok := value.(float64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetAvgPing(v)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown MatchPlayer field %s", name)
|
||||
}
|
||||
@@ -4637,6 +4723,9 @@ func (m *MatchPlayerMutation) AddedFields() []string {
|
||||
if m.addflash_assists != nil {
|
||||
fields = append(fields, matchplayer.FieldFlashAssists)
|
||||
}
|
||||
if m.addavg_ping != nil {
|
||||
fields = append(fields, matchplayer.FieldAvgPing)
|
||||
}
|
||||
return fields
|
||||
}
|
||||
|
||||
@@ -4701,6 +4790,8 @@ func (m *MatchPlayerMutation) AddedField(name string) (ent.Value, bool) {
|
||||
return m.AddedFlashTotalEnemy()
|
||||
case matchplayer.FieldFlashAssists:
|
||||
return m.AddedFlashAssists()
|
||||
case matchplayer.FieldAvgPing:
|
||||
return m.AddedAvgPing()
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
@@ -4906,6 +4997,13 @@ func (m *MatchPlayerMutation) AddField(name string, value ent.Value) error {
|
||||
}
|
||||
m.AddFlashAssists(v)
|
||||
return nil
|
||||
case matchplayer.FieldAvgPing:
|
||||
v, ok := value.(float64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.AddAvgPing(v)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown MatchPlayer numeric field %s", name)
|
||||
}
|
||||
@@ -4989,6 +5087,9 @@ func (m *MatchPlayerMutation) ClearedFields() []string {
|
||||
if m.FieldCleared(matchplayer.FieldFlashAssists) {
|
||||
fields = append(fields, matchplayer.FieldFlashAssists)
|
||||
}
|
||||
if m.FieldCleared(matchplayer.FieldAvgPing) {
|
||||
fields = append(fields, matchplayer.FieldAvgPing)
|
||||
}
|
||||
return fields
|
||||
}
|
||||
|
||||
@@ -5078,6 +5179,9 @@ func (m *MatchPlayerMutation) ClearField(name string) error {
|
||||
case matchplayer.FieldFlashAssists:
|
||||
m.ClearFlashAssists()
|
||||
return nil
|
||||
case matchplayer.FieldAvgPing:
|
||||
m.ClearAvgPing()
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown MatchPlayer nullable field %s", name)
|
||||
}
|
||||
@@ -5182,6 +5286,9 @@ func (m *MatchPlayerMutation) ResetField(name string) error {
|
||||
case matchplayer.FieldFlashAssists:
|
||||
m.ResetFlashAssists()
|
||||
return nil
|
||||
case matchplayer.FieldAvgPing:
|
||||
m.ResetAvgPing()
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown MatchPlayer field %s", name)
|
||||
}
|
||||
|
@@ -46,6 +46,7 @@ func (MatchPlayer) Fields() []ent.Field {
|
||||
field.Uint64("match_stats").Optional(),
|
||||
field.Uint64("player_stats").Optional(),
|
||||
field.Int("flash_assists").Optional(),
|
||||
field.Float("avg_ping").Optional(),
|
||||
}
|
||||
}
|
||||
|
||||
|
13
go.mod
13
go.mod
@@ -4,10 +4,11 @@ go 1.18
|
||||
|
||||
require (
|
||||
entgo.io/ent v0.11.4
|
||||
github.com/aclements/go-moremath v0.0.0-20210112150236-f10218a38794
|
||||
github.com/an0nfunc/go-steam/v3 v3.0.6
|
||||
github.com/an0nfunc/go-steamapi v1.1.0
|
||||
github.com/gin-contrib/cors v1.4.0
|
||||
github.com/gin-gonic/gin v1.8.1
|
||||
github.com/gin-gonic/gin v1.8.2
|
||||
github.com/go-redis/cache/v8 v8.4.4
|
||||
github.com/go-redis/redis/v8 v8.11.5
|
||||
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551
|
||||
@@ -15,7 +16,7 @@ require (
|
||||
github.com/markus-wa/demoinfocs-golang/v3 v3.1.0
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/sabloger/sitemap-generator v1.2.1
|
||||
github.com/sethvargo/go-retry v0.2.3
|
||||
github.com/sethvargo/go-retry v0.2.4
|
||||
github.com/sirupsen/logrus v1.9.0
|
||||
github.com/wercker/journalhook v0.0.0-20180428041537-5d0a5ae867b3
|
||||
golang.org/x/text v0.5.0
|
||||
@@ -46,23 +47,23 @@ require (
|
||||
github.com/jackc/pgio v1.0.0 // indirect
|
||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||
github.com/jackc/pgproto3/v2 v2.3.1 // indirect
|
||||
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
|
||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
|
||||
github.com/jackc/pgtype v1.13.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/compress v1.15.12 // indirect
|
||||
github.com/klauspost/compress v1.15.13 // indirect
|
||||
github.com/leodido/go-urn v1.2.1 // indirect
|
||||
github.com/markus-wa/go-unassert v0.1.2 // indirect
|
||||
github.com/markus-wa/gobitread v0.2.3 // indirect
|
||||
github.com/markus-wa/godispatch v1.4.1 // indirect
|
||||
github.com/markus-wa/ice-cipher-go v0.0.0-20220823210642-1fcccd18c6c1 // indirect
|
||||
github.com/markus-wa/quickhull-go/v2 v2.1.0 // indirect
|
||||
github.com/mattn/go-isatty v0.0.16 // indirect
|
||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
||||
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/oklog/ulid/v2 v2.1.0 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
|
||||
github.com/ugorji/go/codec v1.2.7 // indirect
|
||||
github.com/ugorji/go/codec v1.2.8 // indirect
|
||||
github.com/vmihailenco/go-tinylfu v0.2.2 // indirect
|
||||
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
|
||||
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
|
||||
|
23
go.sum
23
go.sum
@@ -6,6 +6,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
|
||||
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
|
||||
github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc=
|
||||
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
|
||||
github.com/aclements/go-moremath v0.0.0-20210112150236-f10218a38794 h1:xlwdaKcTNVW4PtpQb8aKA4Pjy0CdJHEqvFbAnvR5m2g=
|
||||
github.com/aclements/go-moremath v0.0.0-20210112150236-f10218a38794/go.mod h1:7e+I0LQFUI9AXWxOfsQROs9xPhoJtbsyWcjJqDd4KPY=
|
||||
github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo=
|
||||
github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
|
||||
github.com/an0nfunc/go-steam/v3 v3.0.6 h1:HKkbSokGzoM5W+CsRlzOkmPayLgksW4UekmEaq98lRU=
|
||||
@@ -39,8 +41,9 @@ github.com/gin-contrib/cors v1.4.0 h1:oJ6gwtUl3lqV0WEIwM/LxPF1QZ5qe2lGWdY2+bz7y0
|
||||
github.com/gin-contrib/cors v1.4.0/go.mod h1:bs9pNM0x/UsmHPBWT2xZz9ROh8xYjYkiURUfmBoMlcs=
|
||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gin-gonic/gin v1.8.1 h1:4+fr/el88TOO3ewCmQr8cx/CtZ/umlIRIs5M4NTNjf8=
|
||||
github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk=
|
||||
github.com/gin-gonic/gin v1.8.2 h1:UzKToD9/PoFj/V4rvlKqTRKnQYyz8Sc1MJlv4JHPtvY=
|
||||
github.com/gin-gonic/gin v1.8.2/go.mod h1:qw5AYuDrzRTnhvusDsrov+fDIxp9Dleuu12h8nfB398=
|
||||
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
|
||||
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
|
||||
github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4=
|
||||
@@ -122,8 +125,9 @@ github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwX
|
||||
github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
|
||||
github.com/jackc/pgproto3/v2 v2.3.1 h1:nwj7qwf0S+Q7ISFfBndqeLwSwxs+4DPsbRFjECT1Y4Y=
|
||||
github.com/jackc/pgproto3/v2 v2.3.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
|
||||
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b h1:C8S2+VttkHFdOOCXJe+YGfa4vHYwlt4Zx+IVXQ97jYg=
|
||||
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E=
|
||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk=
|
||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
||||
github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg=
|
||||
github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc=
|
||||
github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw=
|
||||
@@ -145,8 +149,8 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
|
||||
github.com/klauspost/compress v1.15.12 h1:YClS/PImqYbn+UILDnqxQCZ3RehC9N318SU3kElDUEM=
|
||||
github.com/klauspost/compress v1.15.12/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM=
|
||||
github.com/klauspost/compress v1.15.13 h1:NFn1Wr8cfnenSJSA46lLq4wHCcBzKTSjnBIexDMMOV0=
|
||||
github.com/klauspost/compress v1.15.13/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
@@ -184,8 +188,8 @@ github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd
|
||||
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
|
||||
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
|
||||
github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0=
|
||||
github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0=
|
||||
@@ -228,8 +232,8 @@ github.com/sabloger/sitemap-generator v1.2.1 h1:H/vZE0Z49ZCmcXy57FNqw6zn27UJYO6z
|
||||
github.com/sabloger/sitemap-generator v1.2.1/go.mod h1:vm0TjqX6syzcmQDBK2HkIZzORA0WQ3baEN8248nhHVk=
|
||||
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
|
||||
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
|
||||
github.com/sethvargo/go-retry v0.2.3 h1:oYlgvIvsju3jNbottWABtbnoLC+GDtLdBHxKWxQm/iU=
|
||||
github.com/sethvargo/go-retry v0.2.3/go.mod h1:1afjQuvh7s4gflMObvjLPaWgluLLyhA1wmVZ6KLpICw=
|
||||
github.com/sethvargo/go-retry v0.2.4 h1:T+jHEQy/zKJf5s95UkguisicE0zuF9y7+/vgz08Ocec=
|
||||
github.com/sethvargo/go-retry v0.2.4/go.mod h1:1afjQuvh7s4gflMObvjLPaWgluLLyhA1wmVZ6KLpICw=
|
||||
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
|
||||
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
|
||||
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
||||
@@ -254,8 +258,9 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
|
||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M=
|
||||
github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0=
|
||||
github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY=
|
||||
github.com/ugorji/go/codec v1.2.8 h1:sgBJS6COt0b/P40VouWKdseidkDgHxYGm0SAglUHfP0=
|
||||
github.com/ugorji/go/codec v1.2.8/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
||||
github.com/vmihailenco/go-tinylfu v0.2.2 h1:H1eiG6HM36iniK6+21n9LLpzx1G9R3DJa2UjUjbynsI=
|
||||
github.com/vmihailenco/go-tinylfu v0.2.2/go.mod h1:CutYi2Q9puTxfcolkliPq4npPuofg9N9t8JVrjzwa3Q=
|
||||
github.com/vmihailenco/msgpack/v5 v5.3.4/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc=
|
||||
|
Reference in New Issue
Block a user