added avg ping recording
This commit is contained in:
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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user