tracking tickrate
This commit is contained in:
109
ent/mutation.go
109
ent/mutation.go
@@ -62,6 +62,8 @@ type MatchMutation struct {
|
||||
vac_present *bool
|
||||
gameban_present *bool
|
||||
decryption_key *[]byte
|
||||
tick_rate *float64
|
||||
addtick_rate *float64
|
||||
clearedFields map[string]struct{}
|
||||
stats map[int]struct{}
|
||||
removedstats map[int]struct{}
|
||||
@@ -785,6 +787,76 @@ func (m *MatchMutation) ResetDecryptionKey() {
|
||||
delete(m.clearedFields, match.FieldDecryptionKey)
|
||||
}
|
||||
|
||||
// SetTickRate sets the "tick_rate" field.
|
||||
func (m *MatchMutation) SetTickRate(f float64) {
|
||||
m.tick_rate = &f
|
||||
m.addtick_rate = nil
|
||||
}
|
||||
|
||||
// TickRate returns the value of the "tick_rate" field in the mutation.
|
||||
func (m *MatchMutation) TickRate() (r float64, exists bool) {
|
||||
v := m.tick_rate
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldTickRate returns the old "tick_rate" field's value of the Match entity.
|
||||
// If the Match 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 *MatchMutation) OldTickRate(ctx context.Context) (v float64, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, errors.New("OldTickRate is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, errors.New("OldTickRate requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldTickRate: %w", err)
|
||||
}
|
||||
return oldValue.TickRate, nil
|
||||
}
|
||||
|
||||
// AddTickRate adds f to the "tick_rate" field.
|
||||
func (m *MatchMutation) AddTickRate(f float64) {
|
||||
if m.addtick_rate != nil {
|
||||
*m.addtick_rate += f
|
||||
} else {
|
||||
m.addtick_rate = &f
|
||||
}
|
||||
}
|
||||
|
||||
// AddedTickRate returns the value that was added to the "tick_rate" field in this mutation.
|
||||
func (m *MatchMutation) AddedTickRate() (r float64, exists bool) {
|
||||
v := m.addtick_rate
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// ClearTickRate clears the value of the "tick_rate" field.
|
||||
func (m *MatchMutation) ClearTickRate() {
|
||||
m.tick_rate = nil
|
||||
m.addtick_rate = nil
|
||||
m.clearedFields[match.FieldTickRate] = struct{}{}
|
||||
}
|
||||
|
||||
// TickRateCleared returns if the "tick_rate" field was cleared in this mutation.
|
||||
func (m *MatchMutation) TickRateCleared() bool {
|
||||
_, ok := m.clearedFields[match.FieldTickRate]
|
||||
return ok
|
||||
}
|
||||
|
||||
// ResetTickRate resets all changes to the "tick_rate" field.
|
||||
func (m *MatchMutation) ResetTickRate() {
|
||||
m.tick_rate = nil
|
||||
m.addtick_rate = nil
|
||||
delete(m.clearedFields, match.FieldTickRate)
|
||||
}
|
||||
|
||||
// AddStatIDs adds the "stats" edge to the MatchPlayer entity by ids.
|
||||
func (m *MatchMutation) AddStatIDs(ids ...int) {
|
||||
if m.stats == nil {
|
||||
@@ -912,7 +984,7 @@ func (m *MatchMutation) Type() string {
|
||||
// order to get all numeric fields that were incremented/decremented, call
|
||||
// AddedFields().
|
||||
func (m *MatchMutation) Fields() []string {
|
||||
fields := make([]string, 0, 13)
|
||||
fields := make([]string, 0, 14)
|
||||
if m.share_code != nil {
|
||||
fields = append(fields, match.FieldShareCode)
|
||||
}
|
||||
@@ -952,6 +1024,9 @@ func (m *MatchMutation) Fields() []string {
|
||||
if m.decryption_key != nil {
|
||||
fields = append(fields, match.FieldDecryptionKey)
|
||||
}
|
||||
if m.tick_rate != nil {
|
||||
fields = append(fields, match.FieldTickRate)
|
||||
}
|
||||
return fields
|
||||
}
|
||||
|
||||
@@ -986,6 +1061,8 @@ func (m *MatchMutation) Field(name string) (ent.Value, bool) {
|
||||
return m.GamebanPresent()
|
||||
case match.FieldDecryptionKey:
|
||||
return m.DecryptionKey()
|
||||
case match.FieldTickRate:
|
||||
return m.TickRate()
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
@@ -1021,6 +1098,8 @@ func (m *MatchMutation) OldField(ctx context.Context, name string) (ent.Value, e
|
||||
return m.OldGamebanPresent(ctx)
|
||||
case match.FieldDecryptionKey:
|
||||
return m.OldDecryptionKey(ctx)
|
||||
case match.FieldTickRate:
|
||||
return m.OldTickRate(ctx)
|
||||
}
|
||||
return nil, fmt.Errorf("unknown Match field %s", name)
|
||||
}
|
||||
@@ -1121,6 +1200,13 @@ func (m *MatchMutation) SetField(name string, value ent.Value) error {
|
||||
}
|
||||
m.SetDecryptionKey(v)
|
||||
return nil
|
||||
case match.FieldTickRate:
|
||||
v, ok := value.(float64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetTickRate(v)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown Match field %s", name)
|
||||
}
|
||||
@@ -1144,6 +1230,9 @@ func (m *MatchMutation) AddedFields() []string {
|
||||
if m.addmax_rounds != nil {
|
||||
fields = append(fields, match.FieldMaxRounds)
|
||||
}
|
||||
if m.addtick_rate != nil {
|
||||
fields = append(fields, match.FieldTickRate)
|
||||
}
|
||||
return fields
|
||||
}
|
||||
|
||||
@@ -1162,6 +1251,8 @@ func (m *MatchMutation) AddedField(name string) (ent.Value, bool) {
|
||||
return m.AddedMatchResult()
|
||||
case match.FieldMaxRounds:
|
||||
return m.AddedMaxRounds()
|
||||
case match.FieldTickRate:
|
||||
return m.AddedTickRate()
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
@@ -1206,6 +1297,13 @@ func (m *MatchMutation) AddField(name string, value ent.Value) error {
|
||||
}
|
||||
m.AddMaxRounds(v)
|
||||
return nil
|
||||
case match.FieldTickRate:
|
||||
v, ok := value.(float64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.AddTickRate(v)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown Match numeric field %s", name)
|
||||
}
|
||||
@@ -1223,6 +1321,9 @@ func (m *MatchMutation) ClearedFields() []string {
|
||||
if m.FieldCleared(match.FieldDecryptionKey) {
|
||||
fields = append(fields, match.FieldDecryptionKey)
|
||||
}
|
||||
if m.FieldCleared(match.FieldTickRate) {
|
||||
fields = append(fields, match.FieldTickRate)
|
||||
}
|
||||
return fields
|
||||
}
|
||||
|
||||
@@ -1246,6 +1347,9 @@ func (m *MatchMutation) ClearField(name string) error {
|
||||
case match.FieldDecryptionKey:
|
||||
m.ClearDecryptionKey()
|
||||
return nil
|
||||
case match.FieldTickRate:
|
||||
m.ClearTickRate()
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown Match nullable field %s", name)
|
||||
}
|
||||
@@ -1293,6 +1397,9 @@ func (m *MatchMutation) ResetField(name string) error {
|
||||
case match.FieldDecryptionKey:
|
||||
m.ResetDecryptionKey()
|
||||
return nil
|
||||
case match.FieldTickRate:
|
||||
m.ResetTickRate()
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown Match field %s", name)
|
||||
}
|
||||
|
Reference in New Issue
Block a user