tracking tickrate

This commit is contained in:
2022-02-03 16:27:29 +01:00
parent ff0ea43cea
commit 182c7d8fc1
12 changed files with 352 additions and 3 deletions

View File

@@ -42,6 +42,8 @@ type Match struct {
GamebanPresent bool `json:"gameban_present,omitempty"`
// DecryptionKey holds the value of the "decryption_key" field.
DecryptionKey []byte `json:"decryption_key,omitempty"`
// TickRate holds the value of the "tick_rate" field.
TickRate float64 `json:"tick_rate,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the MatchQuery when eager-loading is set.
Edges MatchEdges `json:"edges"`
@@ -85,6 +87,8 @@ func (*Match) scanValues(columns []string) ([]interface{}, error) {
values[i] = new([]byte)
case match.FieldDemoParsed, match.FieldVacPresent, match.FieldGamebanPresent:
values[i] = new(sql.NullBool)
case match.FieldTickRate:
values[i] = new(sql.NullFloat64)
case match.FieldID, match.FieldScoreTeamA, match.FieldScoreTeamB, match.FieldDuration, match.FieldMatchResult, match.FieldMaxRounds:
values[i] = new(sql.NullInt64)
case match.FieldShareCode, match.FieldMap, match.FieldReplayURL:
@@ -190,6 +194,12 @@ func (m *Match) assignValues(columns []string, values []interface{}) error {
} else if value != nil {
m.DecryptionKey = *value
}
case match.FieldTickRate:
if value, ok := values[i].(*sql.NullFloat64); !ok {
return fmt.Errorf("unexpected type %T for field tick_rate", values[i])
} else if value.Valid {
m.TickRate = value.Float64
}
}
}
return nil
@@ -254,6 +264,8 @@ func (m *Match) String() string {
builder.WriteString(fmt.Sprintf("%v", m.GamebanPresent))
builder.WriteString(", decryption_key=")
builder.WriteString(fmt.Sprintf("%v", m.DecryptionKey))
builder.WriteString(", tick_rate=")
builder.WriteString(fmt.Sprintf("%v", m.TickRate))
builder.WriteByte(')')
return builder.String()
}

View File

@@ -33,6 +33,8 @@ const (
FieldGamebanPresent = "gameban_present"
// FieldDecryptionKey holds the string denoting the decryption_key field in the database.
FieldDecryptionKey = "decryption_key"
// FieldTickRate holds the string denoting the tick_rate field in the database.
FieldTickRate = "tick_rate"
// EdgeStats holds the string denoting the stats edge name in mutations.
EdgeStats = "stats"
// EdgePlayers holds the string denoting the players edge name in mutations.
@@ -69,6 +71,7 @@ var Columns = []string{
FieldVacPresent,
FieldGamebanPresent,
FieldDecryptionKey,
FieldTickRate,
}
var (

View File

@@ -184,6 +184,13 @@ func DecryptionKey(v []byte) predicate.Match {
})
}
// TickRate applies equality check predicate on the "tick_rate" field. It's identical to TickRateEQ.
func TickRate(v float64) predicate.Match {
return predicate.Match(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldTickRate), v))
})
}
// ShareCodeEQ applies the EQ predicate on the "share_code" field.
func ShareCodeEQ(v string) predicate.Match {
return predicate.Match(func(s *sql.Selector) {
@@ -1133,6 +1140,96 @@ func DecryptionKeyNotNil() predicate.Match {
})
}
// TickRateEQ applies the EQ predicate on the "tick_rate" field.
func TickRateEQ(v float64) predicate.Match {
return predicate.Match(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldTickRate), v))
})
}
// TickRateNEQ applies the NEQ predicate on the "tick_rate" field.
func TickRateNEQ(v float64) predicate.Match {
return predicate.Match(func(s *sql.Selector) {
s.Where(sql.NEQ(s.C(FieldTickRate), v))
})
}
// TickRateIn applies the In predicate on the "tick_rate" field.
func TickRateIn(vs ...float64) predicate.Match {
v := make([]interface{}, len(vs))
for i := range v {
v[i] = vs[i]
}
return predicate.Match(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldTickRate), v...))
})
}
// TickRateNotIn applies the NotIn predicate on the "tick_rate" field.
func TickRateNotIn(vs ...float64) predicate.Match {
v := make([]interface{}, len(vs))
for i := range v {
v[i] = vs[i]
}
return predicate.Match(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldTickRate), v...))
})
}
// TickRateGT applies the GT predicate on the "tick_rate" field.
func TickRateGT(v float64) predicate.Match {
return predicate.Match(func(s *sql.Selector) {
s.Where(sql.GT(s.C(FieldTickRate), v))
})
}
// TickRateGTE applies the GTE predicate on the "tick_rate" field.
func TickRateGTE(v float64) predicate.Match {
return predicate.Match(func(s *sql.Selector) {
s.Where(sql.GTE(s.C(FieldTickRate), v))
})
}
// TickRateLT applies the LT predicate on the "tick_rate" field.
func TickRateLT(v float64) predicate.Match {
return predicate.Match(func(s *sql.Selector) {
s.Where(sql.LT(s.C(FieldTickRate), v))
})
}
// TickRateLTE applies the LTE predicate on the "tick_rate" field.
func TickRateLTE(v float64) predicate.Match {
return predicate.Match(func(s *sql.Selector) {
s.Where(sql.LTE(s.C(FieldTickRate), v))
})
}
// TickRateIsNil applies the IsNil predicate on the "tick_rate" field.
func TickRateIsNil() predicate.Match {
return predicate.Match(func(s *sql.Selector) {
s.Where(sql.IsNull(s.C(FieldTickRate)))
})
}
// TickRateNotNil applies the NotNil predicate on the "tick_rate" field.
func TickRateNotNil() predicate.Match {
return predicate.Match(func(s *sql.Selector) {
s.Where(sql.NotNull(s.C(FieldTickRate)))
})
}
// HasStats applies the HasEdge predicate on the "stats" edge.
func HasStats() predicate.Match {
return predicate.Match(func(s *sql.Selector) {

View File

@@ -140,6 +140,20 @@ func (mc *MatchCreate) SetDecryptionKey(b []byte) *MatchCreate {
return mc
}
// SetTickRate sets the "tick_rate" field.
func (mc *MatchCreate) SetTickRate(f float64) *MatchCreate {
mc.mutation.SetTickRate(f)
return mc
}
// SetNillableTickRate sets the "tick_rate" field if the given value is not nil.
func (mc *MatchCreate) SetNillableTickRate(f *float64) *MatchCreate {
if f != nil {
mc.SetTickRate(*f)
}
return mc
}
// SetID sets the "id" field.
func (mc *MatchCreate) SetID(u uint64) *MatchCreate {
mc.mutation.SetID(u)
@@ -430,6 +444,14 @@ func (mc *MatchCreate) createSpec() (*Match, *sqlgraph.CreateSpec) {
})
_node.DecryptionKey = value
}
if value, ok := mc.mutation.TickRate(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeFloat64,
Value: value,
Column: match.FieldTickRate,
})
_node.TickRate = value
}
if nodes := mc.mutation.StatsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,

View File

@@ -201,6 +201,33 @@ func (mu *MatchUpdate) ClearDecryptionKey() *MatchUpdate {
return mu
}
// SetTickRate sets the "tick_rate" field.
func (mu *MatchUpdate) SetTickRate(f float64) *MatchUpdate {
mu.mutation.ResetTickRate()
mu.mutation.SetTickRate(f)
return mu
}
// SetNillableTickRate sets the "tick_rate" field if the given value is not nil.
func (mu *MatchUpdate) SetNillableTickRate(f *float64) *MatchUpdate {
if f != nil {
mu.SetTickRate(*f)
}
return mu
}
// AddTickRate adds f to the "tick_rate" field.
func (mu *MatchUpdate) AddTickRate(f float64) *MatchUpdate {
mu.mutation.AddTickRate(f)
return mu
}
// ClearTickRate clears the value of the "tick_rate" field.
func (mu *MatchUpdate) ClearTickRate() *MatchUpdate {
mu.mutation.ClearTickRate()
return mu
}
// AddStatIDs adds the "stats" edge to the MatchPlayer entity by IDs.
func (mu *MatchUpdate) AddStatIDs(ids ...int) *MatchUpdate {
mu.mutation.AddStatIDs(ids...)
@@ -494,6 +521,26 @@ func (mu *MatchUpdate) sqlSave(ctx context.Context) (n int, err error) {
Column: match.FieldDecryptionKey,
})
}
if value, ok := mu.mutation.TickRate(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeFloat64,
Value: value,
Column: match.FieldTickRate,
})
}
if value, ok := mu.mutation.AddedTickRate(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeFloat64,
Value: value,
Column: match.FieldTickRate,
})
}
if mu.mutation.TickRateCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeFloat64,
Column: match.FieldTickRate,
})
}
if mu.mutation.StatsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
@@ -792,6 +839,33 @@ func (muo *MatchUpdateOne) ClearDecryptionKey() *MatchUpdateOne {
return muo
}
// SetTickRate sets the "tick_rate" field.
func (muo *MatchUpdateOne) SetTickRate(f float64) *MatchUpdateOne {
muo.mutation.ResetTickRate()
muo.mutation.SetTickRate(f)
return muo
}
// SetNillableTickRate sets the "tick_rate" field if the given value is not nil.
func (muo *MatchUpdateOne) SetNillableTickRate(f *float64) *MatchUpdateOne {
if f != nil {
muo.SetTickRate(*f)
}
return muo
}
// AddTickRate adds f to the "tick_rate" field.
func (muo *MatchUpdateOne) AddTickRate(f float64) *MatchUpdateOne {
muo.mutation.AddTickRate(f)
return muo
}
// ClearTickRate clears the value of the "tick_rate" field.
func (muo *MatchUpdateOne) ClearTickRate() *MatchUpdateOne {
muo.mutation.ClearTickRate()
return muo
}
// AddStatIDs adds the "stats" edge to the MatchPlayer entity by IDs.
func (muo *MatchUpdateOne) AddStatIDs(ids ...int) *MatchUpdateOne {
muo.mutation.AddStatIDs(ids...)
@@ -1109,6 +1183,26 @@ func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error
Column: match.FieldDecryptionKey,
})
}
if value, ok := muo.mutation.TickRate(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeFloat64,
Value: value,
Column: match.FieldTickRate,
})
}
if value, ok := muo.mutation.AddedTickRate(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeFloat64,
Value: value,
Column: match.FieldTickRate,
})
}
if muo.mutation.TickRateCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeFloat64,
Column: match.FieldTickRate,
})
}
if muo.mutation.StatsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,

View File

@@ -24,6 +24,7 @@ var (
{Name: "vac_present", Type: field.TypeBool, Default: false},
{Name: "gameban_present", Type: field.TypeBool, Default: false},
{Name: "decryption_key", Type: field.TypeBytes, Nullable: true},
{Name: "tick_rate", Type: field.TypeFloat64, Nullable: true},
}
// MatchesTable holds the schema information for the "matches" table.
MatchesTable = &schema.Table{

View File

@@ -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)
}

View File

@@ -28,6 +28,7 @@ func (Match) Fields() []ent.Field {
field.Bool("vac_present").Default(false),
field.Bool("gameban_present").Default(false),
field.Bytes("decryption_key").Optional(),
field.Float("tick_rate").Optional(),
}
}