diff --git a/ent/match.go b/ent/match.go index f24650e..ac4559f 100644 --- a/ent/match.go +++ b/ent/match.go @@ -35,8 +35,6 @@ type Match struct { MatchResult int `json:"match_result,omitempty"` // MaxRounds holds the value of the "max_rounds" field. MaxRounds int `json:"max_rounds,omitempty"` - // Rounds holds the value of the "rounds" field. - Rounds int `json:"rounds,omitempty"` // DemoExpired holds the value of the "demo_expired" field. DemoExpired bool `json:"demo_expired,omitempty"` // DemoParsed holds the value of the "demo_parsed" field. @@ -92,7 +90,7 @@ func (*Match) scanValues(columns []string) ([]interface{}, error) { values[i] = new([]byte) case match.FieldDemoExpired, match.FieldDemoParsed: values[i] = new(sql.NullBool) - case match.FieldID, match.FieldScoreTeamA, match.FieldScoreTeamB, match.FieldDuration, match.FieldMatchResult, match.FieldMaxRounds, match.FieldRounds: + 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: values[i] = new(sql.NullString) @@ -173,12 +171,6 @@ func (m *Match) assignValues(columns []string, values []interface{}) error { } else if value.Valid { m.MaxRounds = int(value.Int64) } - case match.FieldRounds: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field rounds", values[i]) - } else if value.Valid { - m.Rounds = int(value.Int64) - } case match.FieldDemoExpired: if value, ok := values[i].(*sql.NullBool); !ok { return fmt.Errorf("unexpected type %T for field demo_expired", values[i]) @@ -255,8 +247,6 @@ func (m *Match) String() string { builder.WriteString(fmt.Sprintf("%v", m.MatchResult)) builder.WriteString(", max_rounds=") builder.WriteString(fmt.Sprintf("%v", m.MaxRounds)) - builder.WriteString(", rounds=") - builder.WriteString(fmt.Sprintf("%v", m.Rounds)) builder.WriteString(", demo_expired=") builder.WriteString(fmt.Sprintf("%v", m.DemoExpired)) builder.WriteString(", demo_parsed=") diff --git a/ent/match/match.go b/ent/match/match.go index f71b1fa..01134f4 100644 --- a/ent/match/match.go +++ b/ent/match/match.go @@ -25,8 +25,6 @@ const ( FieldMatchResult = "match_result" // FieldMaxRounds holds the string denoting the max_rounds field in the database. FieldMaxRounds = "max_rounds" - // FieldRounds holds the string denoting the rounds field in the database. - FieldRounds = "rounds" // FieldDemoExpired holds the string denoting the demo_expired field in the database. FieldDemoExpired = "demo_expired" // FieldDemoParsed holds the string denoting the demo_parsed field in the database. @@ -65,7 +63,6 @@ var Columns = []string{ FieldDuration, FieldMatchResult, FieldMaxRounds, - FieldRounds, FieldDemoExpired, FieldDemoParsed, FieldEco, diff --git a/ent/match/where.go b/ent/match/where.go index e26a630..2a34c1e 100644 --- a/ent/match/where.go +++ b/ent/match/where.go @@ -156,13 +156,6 @@ func MaxRounds(v int) predicate.Match { }) } -// Rounds applies equality check predicate on the "rounds" field. It's identical to RoundsEQ. -func Rounds(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldRounds), v)) - }) -} - // DemoExpired applies equality check predicate on the "demo_expired" field. It's identical to DemoExpiredEQ. func DemoExpired(v bool) predicate.Match { return predicate.Match(func(s *sql.Selector) { @@ -994,82 +987,6 @@ func MaxRoundsLTE(v int) predicate.Match { }) } -// RoundsEQ applies the EQ predicate on the "rounds" field. -func RoundsEQ(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldRounds), v)) - }) -} - -// RoundsNEQ applies the NEQ predicate on the "rounds" field. -func RoundsNEQ(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldRounds), v)) - }) -} - -// RoundsIn applies the In predicate on the "rounds" field. -func RoundsIn(vs ...int) 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(FieldRounds), v...)) - }) -} - -// RoundsNotIn applies the NotIn predicate on the "rounds" field. -func RoundsNotIn(vs ...int) 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(FieldRounds), v...)) - }) -} - -// RoundsGT applies the GT predicate on the "rounds" field. -func RoundsGT(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldRounds), v)) - }) -} - -// RoundsGTE applies the GTE predicate on the "rounds" field. -func RoundsGTE(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldRounds), v)) - }) -} - -// RoundsLT applies the LT predicate on the "rounds" field. -func RoundsLT(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldRounds), v)) - }) -} - -// RoundsLTE applies the LTE predicate on the "rounds" field. -func RoundsLTE(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldRounds), v)) - }) -} - // DemoExpiredEQ applies the EQ predicate on the "demo_expired" field. func DemoExpiredEQ(v bool) predicate.Match { return predicate.Match(func(s *sql.Selector) { diff --git a/ent/match_create.go b/ent/match_create.go index baef170..d161a52 100644 --- a/ent/match_create.go +++ b/ent/match_create.go @@ -92,12 +92,6 @@ func (mc *MatchCreate) SetMaxRounds(i int) *MatchCreate { return mc } -// SetRounds sets the "rounds" field. -func (mc *MatchCreate) SetRounds(i int) *MatchCreate { - mc.mutation.SetRounds(i) - return mc -} - // SetDemoExpired sets the "demo_expired" field. func (mc *MatchCreate) SetDemoExpired(b bool) *MatchCreate { mc.mutation.SetDemoExpired(b) @@ -292,9 +286,6 @@ func (mc *MatchCreate) check() error { if _, ok := mc.mutation.MaxRounds(); !ok { return &ValidationError{Name: "max_rounds", err: errors.New(`ent: missing required field "max_rounds"`)} } - if _, ok := mc.mutation.Rounds(); !ok { - return &ValidationError{Name: "rounds", err: errors.New(`ent: missing required field "rounds"`)} - } if _, ok := mc.mutation.DemoExpired(); !ok { return &ValidationError{Name: "demo_expired", err: errors.New(`ent: missing required field "demo_expired"`)} } @@ -406,14 +397,6 @@ func (mc *MatchCreate) createSpec() (*Match, *sqlgraph.CreateSpec) { }) _node.MaxRounds = value } - if value, ok := mc.mutation.Rounds(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Value: value, - Column: match.FieldRounds, - }) - _node.Rounds = value - } if value, ok := mc.mutation.DemoExpired(); ok { _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ Type: field.TypeBool, diff --git a/ent/match_update.go b/ent/match_update.go index 8d61316..68af549 100644 --- a/ent/match_update.go +++ b/ent/match_update.go @@ -146,19 +146,6 @@ func (mu *MatchUpdate) AddMaxRounds(i int) *MatchUpdate { return mu } -// SetRounds sets the "rounds" field. -func (mu *MatchUpdate) SetRounds(i int) *MatchUpdate { - mu.mutation.ResetRounds() - mu.mutation.SetRounds(i) - return mu -} - -// AddRounds adds i to the "rounds" field. -func (mu *MatchUpdate) AddRounds(i int) *MatchUpdate { - mu.mutation.AddRounds(i) - return mu -} - // SetDemoExpired sets the "demo_expired" field. func (mu *MatchUpdate) SetDemoExpired(b bool) *MatchUpdate { mu.mutation.SetDemoExpired(b) @@ -478,20 +465,6 @@ func (mu *MatchUpdate) sqlSave(ctx context.Context) (n int, err error) { Column: match.FieldMaxRounds, }) } - if value, ok := mu.mutation.Rounds(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Value: value, - Column: match.FieldRounds, - }) - } - if value, ok := mu.mutation.AddedRounds(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Value: value, - Column: match.FieldRounds, - }) - } if value, ok := mu.mutation.DemoExpired(); ok { _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ Type: field.TypeBool, @@ -763,19 +736,6 @@ func (muo *MatchUpdateOne) AddMaxRounds(i int) *MatchUpdateOne { return muo } -// SetRounds sets the "rounds" field. -func (muo *MatchUpdateOne) SetRounds(i int) *MatchUpdateOne { - muo.mutation.ResetRounds() - muo.mutation.SetRounds(i) - return muo -} - -// AddRounds adds i to the "rounds" field. -func (muo *MatchUpdateOne) AddRounds(i int) *MatchUpdateOne { - muo.mutation.AddRounds(i) - return muo -} - // SetDemoExpired sets the "demo_expired" field. func (muo *MatchUpdateOne) SetDemoExpired(b bool) *MatchUpdateOne { muo.mutation.SetDemoExpired(b) @@ -1119,20 +1079,6 @@ func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error Column: match.FieldMaxRounds, }) } - if value, ok := muo.mutation.Rounds(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Value: value, - Column: match.FieldRounds, - }) - } - if value, ok := muo.mutation.AddedRounds(); ok { - _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Value: value, - Column: match.FieldRounds, - }) - } if value, ok := muo.mutation.DemoExpired(); ok { _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ Type: field.TypeBool, diff --git a/ent/migrate/schema.go b/ent/migrate/schema.go index e97149d..114fa0b 100644 --- a/ent/migrate/schema.go +++ b/ent/migrate/schema.go @@ -20,7 +20,6 @@ var ( {Name: "duration", Type: field.TypeInt}, {Name: "match_result", Type: field.TypeInt}, {Name: "max_rounds", Type: field.TypeInt}, - {Name: "rounds", Type: field.TypeInt}, {Name: "demo_expired", Type: field.TypeBool, Default: false}, {Name: "demo_parsed", Type: field.TypeBool, Default: false}, {Name: "eco", Type: field.TypeJSON, Nullable: true}, diff --git a/ent/mutation.go b/ent/mutation.go index da5644c..8b199ef 100644 --- a/ent/mutation.go +++ b/ent/mutation.go @@ -49,8 +49,6 @@ type MatchMutation struct { addmatch_result *int max_rounds *int addmax_rounds *int - rounds *int - addrounds *int demo_expired *bool demo_parsed *bool eco *struct { @@ -607,62 +605,6 @@ func (m *MatchMutation) ResetMaxRounds() { m.addmax_rounds = nil } -// SetRounds sets the "rounds" field. -func (m *MatchMutation) SetRounds(i int) { - m.rounds = &i - m.addrounds = nil -} - -// Rounds returns the value of the "rounds" field in the mutation. -func (m *MatchMutation) Rounds() (r int, exists bool) { - v := m.rounds - if v == nil { - return - } - return *v, true -} - -// OldRounds returns the old "rounds" 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) OldRounds(ctx context.Context) (v int, err error) { - if !m.op.Is(OpUpdateOne) { - return v, fmt.Errorf("OldRounds is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, fmt.Errorf("OldRounds requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldRounds: %w", err) - } - return oldValue.Rounds, nil -} - -// AddRounds adds i to the "rounds" field. -func (m *MatchMutation) AddRounds(i int) { - if m.addrounds != nil { - *m.addrounds += i - } else { - m.addrounds = &i - } -} - -// AddedRounds returns the value that was added to the "rounds" field in this mutation. -func (m *MatchMutation) AddedRounds() (r int, exists bool) { - v := m.addrounds - if v == nil { - return - } - return *v, true -} - -// ResetRounds resets all changes to the "rounds" field. -func (m *MatchMutation) ResetRounds() { - m.rounds = nil - m.addrounds = nil -} - // SetDemoExpired sets the "demo_expired" field. func (m *MatchMutation) SetDemoExpired(b bool) { m.demo_expired = &b @@ -929,7 +871,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, 12) if m.share_code != nil { fields = append(fields, match.FieldShareCode) } @@ -957,9 +899,6 @@ func (m *MatchMutation) Fields() []string { if m.max_rounds != nil { fields = append(fields, match.FieldMaxRounds) } - if m.rounds != nil { - fields = append(fields, match.FieldRounds) - } if m.demo_expired != nil { fields = append(fields, match.FieldDemoExpired) } @@ -995,8 +934,6 @@ func (m *MatchMutation) Field(name string) (ent.Value, bool) { return m.MatchResult() case match.FieldMaxRounds: return m.MaxRounds() - case match.FieldRounds: - return m.Rounds() case match.FieldDemoExpired: return m.DemoExpired() case match.FieldDemoParsed: @@ -1030,8 +967,6 @@ func (m *MatchMutation) OldField(ctx context.Context, name string) (ent.Value, e return m.OldMatchResult(ctx) case match.FieldMaxRounds: return m.OldMaxRounds(ctx) - case match.FieldRounds: - return m.OldRounds(ctx) case match.FieldDemoExpired: return m.OldDemoExpired(ctx) case match.FieldDemoParsed: @@ -1110,13 +1045,6 @@ func (m *MatchMutation) SetField(name string, value ent.Value) error { } m.SetMaxRounds(v) return nil - case match.FieldRounds: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetRounds(v) - return nil case match.FieldDemoExpired: v, ok := value.(bool) if !ok { @@ -1167,9 +1095,6 @@ func (m *MatchMutation) AddedFields() []string { if m.addmax_rounds != nil { fields = append(fields, match.FieldMaxRounds) } - if m.addrounds != nil { - fields = append(fields, match.FieldRounds) - } return fields } @@ -1188,8 +1113,6 @@ func (m *MatchMutation) AddedField(name string) (ent.Value, bool) { return m.AddedMatchResult() case match.FieldMaxRounds: return m.AddedMaxRounds() - case match.FieldRounds: - return m.AddedRounds() } return nil, false } @@ -1234,13 +1157,6 @@ func (m *MatchMutation) AddField(name string, value ent.Value) error { } m.AddMaxRounds(v) return nil - case match.FieldRounds: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddRounds(v) - return nil } return fmt.Errorf("unknown Match numeric field %s", name) } @@ -1316,9 +1232,6 @@ func (m *MatchMutation) ResetField(name string) error { case match.FieldMaxRounds: m.ResetMaxRounds() return nil - case match.FieldRounds: - m.ResetRounds() - return nil case match.FieldDemoExpired: m.ResetDemoExpired() return nil diff --git a/ent/runtime.go b/ent/runtime.go index 6cd8905..bfb8aa7 100644 --- a/ent/runtime.go +++ b/ent/runtime.go @@ -16,11 +16,11 @@ func init() { matchFields := schema.Match{}.Fields() _ = matchFields // matchDescDemoExpired is the schema descriptor for demo_expired field. - matchDescDemoExpired := matchFields[11].Descriptor() + matchDescDemoExpired := matchFields[10].Descriptor() // match.DefaultDemoExpired holds the default value on creation for the demo_expired field. match.DefaultDemoExpired = matchDescDemoExpired.Default.(bool) // matchDescDemoParsed is the schema descriptor for demo_parsed field. - matchDescDemoParsed := matchFields[12].Descriptor() + matchDescDemoParsed := matchFields[11].Descriptor() // match.DefaultDemoParsed holds the default value on creation for the demo_parsed field. match.DefaultDemoParsed = matchDescDemoParsed.Default.(bool) playerFields := schema.Player{}.Fields() diff --git a/ent/schema/match.go b/ent/schema/match.go index 8799c33..b73232f 100644 --- a/ent/schema/match.go +++ b/ent/schema/match.go @@ -24,7 +24,6 @@ func (Match) Fields() []ent.Field { field.Int("duration"), field.Int("match_result"), field.Int("max_rounds"), - field.Int("rounds"), field.Bool("demo_expired").Default(false), field.Bool("demo_parsed").Default(false), field.JSON("eco", struct { diff --git a/main.go b/main.go index d3c0b39..ba065ee 100644 --- a/main.go +++ b/main.go @@ -66,7 +66,6 @@ type MatchResponse struct { Duration int `json:"duration"` MatchResult int `json:"match_result"` MaxRounds int `json:"max_rounds,omitempty"` - Rounds int `json:"rounds"` Parsed bool `json:"parsed"` Stats []*StatsResponse `json:"stats"` } @@ -216,7 +215,6 @@ func getPlayer(w http.ResponseWriter, r *http.Request) { Duration: iMatch.Duration, MatchResult: iMatch.MatchResult, MaxRounds: iMatch.MaxRounds, - Rounds: iMatch.Rounds, Parsed: iMatch.DemoParsed, Stats: []*StatsResponse{}, } @@ -353,7 +351,6 @@ func getMatch(w http.ResponseWriter, r *http.Request) { Duration: tMatch.Duration, MatchResult: tMatch.MatchResult, MaxRounds: tMatch.MaxRounds, - Rounds: tMatch.Rounds, Parsed: tMatch.DemoParsed, Stats: []*StatsResponse{}, } diff --git a/utils/utils.go b/utils/utils.go index d53679d..3adef07 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -378,7 +378,6 @@ func GCInfoParser(channel chan *csgo.Demo, dl *csgo.DemoMatchLoader, dp *csgo.De SetID(matchZero.GetMatchid()). AddPlayers(players...). SetDate(time.Unix(int64(matchZero.GetMatchtime()), 0).UTC()). - SetRounds(len(matchZero.Roundstatsall)). SetMaxRounds(int(lastRound.GetMaxRounds())). SetDuration(int(lastRound.GetMatchDuration())). SetShareCode(demo.ShareCode).