From cce5c5d0727d58abdc4faa4c54acc283d4b6dd33 Mon Sep 17 00:00:00 2001 From: Giovanni Harting <539@idlegandalf.com> Date: Fri, 8 Oct 2021 20:59:14 +0200 Subject: [PATCH] return color by string, added rounds since maxrounds is not defined in pre-riptide matches --- csgo/demo_parser.go | 2 +- ent/match.go | 12 +++++- ent/match/match.go | 3 ++ ent/match/where.go | 83 ++++++++++++++++++++++++++++++++++++ ent/match_create.go | 17 ++++++++ ent/match_update.go | 54 +++++++++++++++++++++++ ent/migrate/schema.go | 1 + ent/mutation.go | 99 ++++++++++++++++++++++++++++++++++++++++--- ent/runtime.go | 4 +- ent/schema/match.go | 1 + ent/schema/stats.go | 2 +- ent/stats.go | 2 +- ent/stats_create.go | 4 +- ent/stats_update.go | 8 ++-- go.sum | 7 +++ main.go | 1 + utils/utils.go | 1 + 17 files changed, 283 insertions(+), 18 deletions(-) diff --git a/csgo/demo_parser.go b/csgo/demo_parser.go index 60c17d1..0b25dbd 100644 --- a/csgo/demo_parser.go +++ b/csgo/demo_parser.go @@ -274,7 +274,7 @@ func (p *DemoParser) parseWorker() { tMatchPlayer := p.getMatchPlayerBySteamID(tStats, demoPlayer.SteamID64) tMatchPlayer.Extended.Crosshair = demoPlayer.CrosshairCode() - tMatchPlayer.Extended.Color = int(demoPlayer.Color()) + tMatchPlayer.Extended.Color = demoPlayer.Color().String() } } }) diff --git a/ent/match.go b/ent/match.go index ac4559f..f24650e 100644 --- a/ent/match.go +++ b/ent/match.go @@ -35,6 +35,8 @@ 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. @@ -90,7 +92,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: + case match.FieldID, match.FieldScoreTeamA, match.FieldScoreTeamB, match.FieldDuration, match.FieldMatchResult, match.FieldMaxRounds, match.FieldRounds: values[i] = new(sql.NullInt64) case match.FieldShareCode, match.FieldMap, match.FieldReplayURL: values[i] = new(sql.NullString) @@ -171,6 +173,12 @@ 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]) @@ -247,6 +255,8 @@ 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 01134f4..f71b1fa 100644 --- a/ent/match/match.go +++ b/ent/match/match.go @@ -25,6 +25,8 @@ 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. @@ -63,6 +65,7 @@ var Columns = []string{ FieldDuration, FieldMatchResult, FieldMaxRounds, + FieldRounds, FieldDemoExpired, FieldDemoParsed, FieldEco, diff --git a/ent/match/where.go b/ent/match/where.go index 2a34c1e..e26a630 100644 --- a/ent/match/where.go +++ b/ent/match/where.go @@ -156,6 +156,13 @@ 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) { @@ -987,6 +994,82 @@ 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 d161a52..baef170 100644 --- a/ent/match_create.go +++ b/ent/match_create.go @@ -92,6 +92,12 @@ 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) @@ -286,6 +292,9 @@ 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"`)} } @@ -397,6 +406,14 @@ 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 68af549..8d61316 100644 --- a/ent/match_update.go +++ b/ent/match_update.go @@ -146,6 +146,19 @@ 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) @@ -465,6 +478,20 @@ 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, @@ -736,6 +763,19 @@ 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) @@ -1079,6 +1119,20 @@ 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 114fa0b..e97149d 100644 --- a/ent/migrate/schema.go +++ b/ent/migrate/schema.go @@ -20,6 +20,7 @@ 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 491ba4e..da5644c 100644 --- a/ent/mutation.go +++ b/ent/mutation.go @@ -49,6 +49,8 @@ type MatchMutation struct { addmatch_result *int max_rounds *int addmax_rounds *int + rounds *int + addrounds *int demo_expired *bool demo_parsed *bool eco *struct { @@ -605,6 +607,62 @@ 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 @@ -871,7 +929,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, 12) + fields := make([]string, 0, 13) if m.share_code != nil { fields = append(fields, match.FieldShareCode) } @@ -899,6 +957,9 @@ 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) } @@ -934,6 +995,8 @@ 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: @@ -967,6 +1030,8 @@ 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: @@ -1045,6 +1110,13 @@ 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 { @@ -1095,6 +1167,9 @@ 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 } @@ -1113,6 +1188,8 @@ 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 } @@ -1157,6 +1234,13 @@ 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) } @@ -1232,6 +1316,9 @@ 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 @@ -2556,7 +2643,7 @@ type StatsMutation struct { } "json:\"hit_group,omitempty\"" } "json:\"dmg,omitempty\"" Crosshair string "json:\"crosshair,omitempty\"" - Color int "json:\"color,omitempty\"" + Color string "json:\"color,omitempty\"" KAST int "json:\"kast,omitempty\"" Rank struct { Old int "json:\"old,omitempty\"" @@ -3086,7 +3173,7 @@ func (m *StatsMutation) SetExtended(skkgaaaallllg struct { } "json:\"hit_group,omitempty\"" } "json:\"dmg,omitempty\"" Crosshair string "json:\"crosshair,omitempty\"" - Color int "json:\"color,omitempty\"" + Color string "json:\"color,omitempty\"" KAST int "json:\"kast,omitempty\"" Rank struct { Old int "json:\"old,omitempty\"" @@ -3138,7 +3225,7 @@ func (m *StatsMutation) Extended() (r struct { } "json:\"hit_group,omitempty\"" } "json:\"dmg,omitempty\"" Crosshair string "json:\"crosshair,omitempty\"" - Color int "json:\"color,omitempty\"" + Color string "json:\"color,omitempty\"" KAST int "json:\"kast,omitempty\"" Rank struct { Old int "json:\"old,omitempty\"" @@ -3196,7 +3283,7 @@ func (m *StatsMutation) OldExtended(ctx context.Context) (v struct { } "json:\"hit_group,omitempty\"" } "json:\"dmg,omitempty\"" Crosshair string "json:\"crosshair,omitempty\"" - Color int "json:\"color,omitempty\"" + Color string "json:\"color,omitempty\"" KAST int "json:\"kast,omitempty\"" Rank struct { Old int "json:\"old,omitempty\"" @@ -3505,7 +3592,7 @@ func (m *StatsMutation) SetField(name string, value ent.Value) error { } "json:\"hit_group,omitempty\"" } "json:\"dmg,omitempty\"" Crosshair string "json:\"crosshair,omitempty\"" - Color int "json:\"color,omitempty\"" + Color string "json:\"color,omitempty\"" KAST int "json:\"kast,omitempty\"" Rank struct { Old int "json:\"old,omitempty\"" diff --git a/ent/runtime.go b/ent/runtime.go index bfb8aa7..6cd8905 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[10].Descriptor() + matchDescDemoExpired := matchFields[11].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[11].Descriptor() + matchDescDemoParsed := matchFields[12].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 b73232f..8799c33 100644 --- a/ent/schema/match.go +++ b/ent/schema/match.go @@ -24,6 +24,7 @@ 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/ent/schema/stats.go b/ent/schema/stats.go index 85610b9..131ba2d 100644 --- a/ent/schema/stats.go +++ b/ent/schema/stats.go @@ -50,7 +50,7 @@ func (Stats) Fields() []ent.Field { } `json:"hit_group,omitempty"` } `json:"dmg,omitempty"` Crosshair string `json:"crosshair,omitempty"` - Color int `json:"color,omitempty"` + Color string `json:"color,omitempty"` KAST int `json:"kast,omitempty"` Rank struct { Old int `json:"old,omitempty"` diff --git a/ent/stats.go b/ent/stats.go index dd7a89e..f7589bc 100644 --- a/ent/stats.go +++ b/ent/stats.go @@ -62,7 +62,7 @@ type Stats struct { } "json:\"hit_group,omitempty\"" } "json:\"dmg,omitempty\"" Crosshair string "json:\"crosshair,omitempty\"" - Color int "json:\"color,omitempty\"" + Color string "json:\"color,omitempty\"" KAST int "json:\"kast,omitempty\"" Rank struct { Old int "json:\"old,omitempty\"" diff --git a/ent/stats_create.go b/ent/stats_create.go index 63b4cc3..5955f04 100644 --- a/ent/stats_create.go +++ b/ent/stats_create.go @@ -93,7 +93,7 @@ func (sc *StatsCreate) SetExtended(skkgaaaallllg struct { } "json:\"hit_group,omitempty\"" } "json:\"dmg,omitempty\"" Crosshair string "json:\"crosshair,omitempty\"" - Color int "json:\"color,omitempty\"" + Color string "json:\"color,omitempty\"" KAST int "json:\"kast,omitempty\"" Rank struct { Old int "json:\"old,omitempty\"" @@ -146,7 +146,7 @@ func (sc *StatsCreate) SetNillableExtended(skkgaaaallllg *struct { } "json:\"hit_group,omitempty\"" } "json:\"dmg,omitempty\"" Crosshair string "json:\"crosshair,omitempty\"" - Color int "json:\"color,omitempty\"" + Color string "json:\"color,omitempty\"" KAST int "json:\"kast,omitempty\"" Rank struct { Old int "json:\"old,omitempty\"" diff --git a/ent/stats_update.go b/ent/stats_update.go index 8f53f69..2ab1676 100644 --- a/ent/stats_update.go +++ b/ent/stats_update.go @@ -149,7 +149,7 @@ func (su *StatsUpdate) SetExtended(skkgaaaallllg struct { } "json:\"hit_group,omitempty\"" } "json:\"dmg,omitempty\"" Crosshair string "json:\"crosshair,omitempty\"" - Color int "json:\"color,omitempty\"" + Color string "json:\"color,omitempty\"" KAST int "json:\"kast,omitempty\"" Rank struct { Old int "json:\"old,omitempty\"" @@ -202,7 +202,7 @@ func (su *StatsUpdate) SetNillableExtended(skkgaaaallllg *struct { } "json:\"hit_group,omitempty\"" } "json:\"dmg,omitempty\"" Crosshair string "json:\"crosshair,omitempty\"" - Color int "json:\"color,omitempty\"" + Color string "json:\"color,omitempty\"" KAST int "json:\"kast,omitempty\"" Rank struct { Old int "json:\"old,omitempty\"" @@ -681,7 +681,7 @@ func (suo *StatsUpdateOne) SetExtended(skkgaaaallllg struct { } "json:\"hit_group,omitempty\"" } "json:\"dmg,omitempty\"" Crosshair string "json:\"crosshair,omitempty\"" - Color int "json:\"color,omitempty\"" + Color string "json:\"color,omitempty\"" KAST int "json:\"kast,omitempty\"" Rank struct { Old int "json:\"old,omitempty\"" @@ -734,7 +734,7 @@ func (suo *StatsUpdateOne) SetNillableExtended(skkgaaaallllg *struct { } "json:\"hit_group,omitempty\"" } "json:\"dmg,omitempty\"" Crosshair string "json:\"crosshair,omitempty\"" - Color int "json:\"color,omitempty\"" + Color string "json:\"color,omitempty\"" KAST int "json:\"kast,omitempty\"" Rank struct { Old int "json:\"old,omitempty\"" diff --git a/go.sum b/go.sum index 4e86b5d..3619f72 100644 --- a/go.sum +++ b/go.sum @@ -112,6 +112,7 @@ github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9 github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logr/logr v0.4.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= +github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4= github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4= github.com/go-redis/cache/v8 v8.4.3 h1:+RZ0pQM+zOd6h/oWCsOl3+nsCgii9rn26oCYmU87kN8= github.com/go-redis/cache/v8 v8.4.3/go.mod h1:5lQPQ63uyBt4aZuRmdvUJOJRRjPxfLtJtlcJ/z8o1jA= @@ -263,6 +264,7 @@ github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaO github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-sqlite3 v1.14.8 h1:gDp86IdQsN/xWjIEmr9MF6o9mpksUgh0fu+9ByFxzIU= github.com/mattn/go-sqlite3 v1.14.8/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= @@ -296,6 +298,7 @@ github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtb github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -375,10 +378,12 @@ github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasO github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= +github.com/spf13/cobra v1.1.3 h1:xghbfqPkxzxP3C/f3n5DdpAbdKLj4ZE4BWQI362l53M= github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= @@ -478,6 +483,7 @@ golang.org/x/mod v0.1.1-0.20191209134235-331c550502dd/go.mod h1:s0Qsj1ACt9ePp/hM golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.5.1-0.20210830214625-1b1db11ec8f4 h1:7Qds88gNaRx0Dz/1wOwXlR7asekh1B1u26wEwN6FcEI= golang.org/x/mod v0.5.1-0.20210830214625-1b1db11ec8f4/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -589,6 +595,7 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= +golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/main.go b/main.go index 7e72e19..ba838bd 100644 --- a/main.go +++ b/main.go @@ -65,6 +65,7 @@ type MatchResponse struct { Score [2]int `json:"score"` 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"` diff --git a/utils/utils.go b/utils/utils.go index 3adef07..d53679d 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -378,6 +378,7 @@ 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).