diff --git a/csgo/demo_parser.go b/csgo/demo_parser.go index 39312c1..6de02e8 100644 --- a/csgo/demo_parser.go +++ b/csgo/demo_parser.go @@ -130,7 +130,7 @@ func (p *DemoParser) parseWorker() { continue } } - downloadTime := time.Now().Sub(startTime) + downloadTime := time.Since(startTime) tStats, err := tMatch.QueryStats().WithPlayers().All(context.Background()) if err != nil { @@ -336,7 +336,7 @@ func (p *DemoParser) parseWorker() { } } - log.Infof("[DP] parsed match %d (took %s/%s)", demo.MatchId, downloadTime, time.Now().Sub(startTime)) + log.Infof("[DP] parsed match %d (took %s/%s)", demo.MatchId, downloadTime, time.Since(startTime)) err = demoParser.Close() if err != nil { diff --git a/ent/match.go b/ent/match.go index 6f89005..caebedb 100644 --- a/ent/match.go +++ b/ent/match.go @@ -36,6 +36,10 @@ type Match struct { MaxRounds int `json:"max_rounds,omitempty"` // DemoParsed holds the value of the "demo_parsed" field. DemoParsed bool `json:"demo_parsed,omitempty"` + // VacPresent holds the value of the "vac_present" field. + VacPresent bool `json:"vac_present,omitempty"` + // GamebanPresent holds the value of the "gameban_present" field. + GamebanPresent bool `json:"gameban_present,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"` @@ -75,7 +79,7 @@ func (*Match) scanValues(columns []string) ([]interface{}, error) { values := make([]interface{}, len(columns)) for i := range columns { switch columns[i] { - case match.FieldDemoParsed: + case match.FieldDemoParsed, match.FieldVacPresent, match.FieldGamebanPresent: values[i] = new(sql.NullBool) case match.FieldID, match.FieldScoreTeamA, match.FieldScoreTeamB, match.FieldDuration, match.FieldMatchResult, match.FieldMaxRounds: values[i] = new(sql.NullInt64) @@ -164,6 +168,18 @@ func (m *Match) assignValues(columns []string, values []interface{}) error { } else if value.Valid { m.DemoParsed = value.Bool } + case match.FieldVacPresent: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field vac_present", values[i]) + } else if value.Valid { + m.VacPresent = value.Bool + } + case match.FieldGamebanPresent: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field gameban_present", values[i]) + } else if value.Valid { + m.GamebanPresent = value.Bool + } } } return nil @@ -222,6 +238,10 @@ func (m *Match) String() string { builder.WriteString(fmt.Sprintf("%v", m.MaxRounds)) builder.WriteString(", demo_parsed=") builder.WriteString(fmt.Sprintf("%v", m.DemoParsed)) + builder.WriteString(", vac_present=") + builder.WriteString(fmt.Sprintf("%v", m.VacPresent)) + builder.WriteString(", gameban_present=") + builder.WriteString(fmt.Sprintf("%v", m.GamebanPresent)) builder.WriteByte(')') return builder.String() } diff --git a/ent/match/match.go b/ent/match/match.go index 302a774..b0ac166 100644 --- a/ent/match/match.go +++ b/ent/match/match.go @@ -27,6 +27,10 @@ const ( FieldMaxRounds = "max_rounds" // FieldDemoParsed holds the string denoting the demo_parsed field in the database. FieldDemoParsed = "demo_parsed" + // FieldVacPresent holds the string denoting the vac_present field in the database. + FieldVacPresent = "vac_present" + // FieldGamebanPresent holds the string denoting the gameban_present field in the database. + FieldGamebanPresent = "gameban_present" // EdgeStats holds the string denoting the stats edge name in mutations. EdgeStats = "stats" // EdgePlayers holds the string denoting the players edge name in mutations. @@ -60,6 +64,8 @@ var Columns = []string{ FieldMatchResult, FieldMaxRounds, FieldDemoParsed, + FieldVacPresent, + FieldGamebanPresent, } var ( @@ -81,4 +87,8 @@ func ValidColumn(column string) bool { var ( // DefaultDemoParsed holds the default value on creation for the "demo_parsed" field. DefaultDemoParsed bool + // DefaultVacPresent holds the default value on creation for the "vac_present" field. + DefaultVacPresent bool + // DefaultGamebanPresent holds the default value on creation for the "gameban_present" field. + DefaultGamebanPresent bool ) diff --git a/ent/match/where.go b/ent/match/where.go index 4920aea..61015ab 100644 --- a/ent/match/where.go +++ b/ent/match/where.go @@ -163,6 +163,20 @@ func DemoParsed(v bool) predicate.Match { }) } +// VacPresent applies equality check predicate on the "vac_present" field. It's identical to VacPresentEQ. +func VacPresent(v bool) predicate.Match { + return predicate.Match(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldVacPresent), v)) + }) +} + +// GamebanPresent applies equality check predicate on the "gameban_present" field. It's identical to GamebanPresentEQ. +func GamebanPresent(v bool) predicate.Match { + return predicate.Match(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldGamebanPresent), v)) + }) +} + // ShareCodeEQ applies the EQ predicate on the "share_code" field. func ShareCodeEQ(v string) predicate.Match { return predicate.Match(func(s *sql.Selector) { @@ -994,6 +1008,34 @@ func DemoParsedNEQ(v bool) predicate.Match { }) } +// VacPresentEQ applies the EQ predicate on the "vac_present" field. +func VacPresentEQ(v bool) predicate.Match { + return predicate.Match(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldVacPresent), v)) + }) +} + +// VacPresentNEQ applies the NEQ predicate on the "vac_present" field. +func VacPresentNEQ(v bool) predicate.Match { + return predicate.Match(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldVacPresent), v)) + }) +} + +// GamebanPresentEQ applies the EQ predicate on the "gameban_present" field. +func GamebanPresentEQ(v bool) predicate.Match { + return predicate.Match(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldGamebanPresent), v)) + }) +} + +// GamebanPresentNEQ applies the NEQ predicate on the "gameban_present" field. +func GamebanPresentNEQ(v bool) predicate.Match { + return predicate.Match(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldGamebanPresent), v)) + }) +} + // HasStats applies the HasEdge predicate on the "stats" edge. func HasStats() predicate.Match { return predicate.Match(func(s *sql.Selector) { diff --git a/ent/match_create.go b/ent/match_create.go index e826882..1e42f94 100644 --- a/ent/match_create.go +++ b/ent/match_create.go @@ -106,6 +106,34 @@ func (mc *MatchCreate) SetNillableDemoParsed(b *bool) *MatchCreate { return mc } +// SetVacPresent sets the "vac_present" field. +func (mc *MatchCreate) SetVacPresent(b bool) *MatchCreate { + mc.mutation.SetVacPresent(b) + return mc +} + +// SetNillableVacPresent sets the "vac_present" field if the given value is not nil. +func (mc *MatchCreate) SetNillableVacPresent(b *bool) *MatchCreate { + if b != nil { + mc.SetVacPresent(*b) + } + return mc +} + +// SetGamebanPresent sets the "gameban_present" field. +func (mc *MatchCreate) SetGamebanPresent(b bool) *MatchCreate { + mc.mutation.SetGamebanPresent(b) + return mc +} + +// SetNillableGamebanPresent sets the "gameban_present" field if the given value is not nil. +func (mc *MatchCreate) SetNillableGamebanPresent(b *bool) *MatchCreate { + if b != nil { + mc.SetGamebanPresent(*b) + } + return mc +} + // SetID sets the "id" field. func (mc *MatchCreate) SetID(u uint64) *MatchCreate { mc.mutation.SetID(u) @@ -217,6 +245,14 @@ func (mc *MatchCreate) defaults() { v := match.DefaultDemoParsed mc.mutation.SetDemoParsed(v) } + if _, ok := mc.mutation.VacPresent(); !ok { + v := match.DefaultVacPresent + mc.mutation.SetVacPresent(v) + } + if _, ok := mc.mutation.GamebanPresent(); !ok { + v := match.DefaultGamebanPresent + mc.mutation.SetGamebanPresent(v) + } } // check runs all checks and user-defined validators on the builder. @@ -245,6 +281,12 @@ func (mc *MatchCreate) check() error { if _, ok := mc.mutation.DemoParsed(); !ok { return &ValidationError{Name: "demo_parsed", err: errors.New(`ent: missing required field "demo_parsed"`)} } + if _, ok := mc.mutation.VacPresent(); !ok { + return &ValidationError{Name: "vac_present", err: errors.New(`ent: missing required field "vac_present"`)} + } + if _, ok := mc.mutation.GamebanPresent(); !ok { + return &ValidationError{Name: "gameban_present", err: errors.New(`ent: missing required field "gameban_present"`)} + } return nil } @@ -358,6 +400,22 @@ func (mc *MatchCreate) createSpec() (*Match, *sqlgraph.CreateSpec) { }) _node.DemoParsed = value } + if value, ok := mc.mutation.VacPresent(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: match.FieldVacPresent, + }) + _node.VacPresent = value + } + if value, ok := mc.mutation.GamebanPresent(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: match.FieldGamebanPresent, + }) + _node.GamebanPresent = value + } if nodes := mc.mutation.StatsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, diff --git a/ent/match_update.go b/ent/match_update.go index 48a569a..b01c5c1 100644 --- a/ent/match_update.go +++ b/ent/match_update.go @@ -160,6 +160,34 @@ func (mu *MatchUpdate) SetNillableDemoParsed(b *bool) *MatchUpdate { return mu } +// SetVacPresent sets the "vac_present" field. +func (mu *MatchUpdate) SetVacPresent(b bool) *MatchUpdate { + mu.mutation.SetVacPresent(b) + return mu +} + +// SetNillableVacPresent sets the "vac_present" field if the given value is not nil. +func (mu *MatchUpdate) SetNillableVacPresent(b *bool) *MatchUpdate { + if b != nil { + mu.SetVacPresent(*b) + } + return mu +} + +// SetGamebanPresent sets the "gameban_present" field. +func (mu *MatchUpdate) SetGamebanPresent(b bool) *MatchUpdate { + mu.mutation.SetGamebanPresent(b) + return mu +} + +// SetNillableGamebanPresent sets the "gameban_present" field if the given value is not nil. +func (mu *MatchUpdate) SetNillableGamebanPresent(b *bool) *MatchUpdate { + if b != nil { + mu.SetGamebanPresent(*b) + } + return mu +} + // AddStatIDs adds the "stats" edge to the Stats entity by IDs. func (mu *MatchUpdate) AddStatIDs(ids ...int) *MatchUpdate { mu.mutation.AddStatIDs(ids...) @@ -426,6 +454,20 @@ func (mu *MatchUpdate) sqlSave(ctx context.Context) (n int, err error) { Column: match.FieldDemoParsed, }) } + if value, ok := mu.mutation.VacPresent(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: match.FieldVacPresent, + }) + } + if value, ok := mu.mutation.GamebanPresent(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: match.FieldGamebanPresent, + }) + } if mu.mutation.StatsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, @@ -684,6 +726,34 @@ func (muo *MatchUpdateOne) SetNillableDemoParsed(b *bool) *MatchUpdateOne { return muo } +// SetVacPresent sets the "vac_present" field. +func (muo *MatchUpdateOne) SetVacPresent(b bool) *MatchUpdateOne { + muo.mutation.SetVacPresent(b) + return muo +} + +// SetNillableVacPresent sets the "vac_present" field if the given value is not nil. +func (muo *MatchUpdateOne) SetNillableVacPresent(b *bool) *MatchUpdateOne { + if b != nil { + muo.SetVacPresent(*b) + } + return muo +} + +// SetGamebanPresent sets the "gameban_present" field. +func (muo *MatchUpdateOne) SetGamebanPresent(b bool) *MatchUpdateOne { + muo.mutation.SetGamebanPresent(b) + return muo +} + +// SetNillableGamebanPresent sets the "gameban_present" field if the given value is not nil. +func (muo *MatchUpdateOne) SetNillableGamebanPresent(b *bool) *MatchUpdateOne { + if b != nil { + muo.SetGamebanPresent(*b) + } + return muo +} + // AddStatIDs adds the "stats" edge to the Stats entity by IDs. func (muo *MatchUpdateOne) AddStatIDs(ids ...int) *MatchUpdateOne { muo.mutation.AddStatIDs(ids...) @@ -974,6 +1044,20 @@ func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error Column: match.FieldDemoParsed, }) } + if value, ok := muo.mutation.VacPresent(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: match.FieldVacPresent, + }) + } + if value, ok := muo.mutation.GamebanPresent(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: match.FieldGamebanPresent, + }) + } if muo.mutation.StatsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, diff --git a/ent/migrate/schema.go b/ent/migrate/schema.go index bdf1fef..7fbecee 100644 --- a/ent/migrate/schema.go +++ b/ent/migrate/schema.go @@ -21,6 +21,8 @@ var ( {Name: "match_result", Type: field.TypeInt}, {Name: "max_rounds", Type: field.TypeInt}, {Name: "demo_parsed", Type: field.TypeBool, Default: false}, + {Name: "vac_present", Type: field.TypeBool, Default: false}, + {Name: "gameban_present", Type: field.TypeBool, Default: false}, } // MatchesTable holds the schema information for the "matches" table. MatchesTable = &schema.Table{ diff --git a/ent/mutation.go b/ent/mutation.go index 07241f1..fb314a3 100644 --- a/ent/mutation.go +++ b/ent/mutation.go @@ -54,6 +54,8 @@ type MatchMutation struct { max_rounds *int addmax_rounds *int demo_parsed *bool + vac_present *bool + gameban_present *bool clearedFields map[string]struct{} stats map[int]struct{} removedstats map[int]struct{} @@ -637,6 +639,78 @@ func (m *MatchMutation) ResetDemoParsed() { m.demo_parsed = nil } +// SetVacPresent sets the "vac_present" field. +func (m *MatchMutation) SetVacPresent(b bool) { + m.vac_present = &b +} + +// VacPresent returns the value of the "vac_present" field in the mutation. +func (m *MatchMutation) VacPresent() (r bool, exists bool) { + v := m.vac_present + if v == nil { + return + } + return *v, true +} + +// OldVacPresent returns the old "vac_present" 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) OldVacPresent(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldVacPresent is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldVacPresent requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldVacPresent: %w", err) + } + return oldValue.VacPresent, nil +} + +// ResetVacPresent resets all changes to the "vac_present" field. +func (m *MatchMutation) ResetVacPresent() { + m.vac_present = nil +} + +// SetGamebanPresent sets the "gameban_present" field. +func (m *MatchMutation) SetGamebanPresent(b bool) { + m.gameban_present = &b +} + +// GamebanPresent returns the value of the "gameban_present" field in the mutation. +func (m *MatchMutation) GamebanPresent() (r bool, exists bool) { + v := m.gameban_present + if v == nil { + return + } + return *v, true +} + +// OldGamebanPresent returns the old "gameban_present" 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) OldGamebanPresent(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldGamebanPresent is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldGamebanPresent requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldGamebanPresent: %w", err) + } + return oldValue.GamebanPresent, nil +} + +// ResetGamebanPresent resets all changes to the "gameban_present" field. +func (m *MatchMutation) ResetGamebanPresent() { + m.gameban_present = nil +} + // AddStatIDs adds the "stats" edge to the Stats entity by ids. func (m *MatchMutation) AddStatIDs(ids ...int) { if m.stats == nil { @@ -764,7 +838,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, 10) + fields := make([]string, 0, 12) if m.share_code != nil { fields = append(fields, match.FieldShareCode) } @@ -795,6 +869,12 @@ func (m *MatchMutation) Fields() []string { if m.demo_parsed != nil { fields = append(fields, match.FieldDemoParsed) } + if m.vac_present != nil { + fields = append(fields, match.FieldVacPresent) + } + if m.gameban_present != nil { + fields = append(fields, match.FieldGamebanPresent) + } return fields } @@ -823,6 +903,10 @@ func (m *MatchMutation) Field(name string) (ent.Value, bool) { return m.MaxRounds() case match.FieldDemoParsed: return m.DemoParsed() + case match.FieldVacPresent: + return m.VacPresent() + case match.FieldGamebanPresent: + return m.GamebanPresent() } return nil, false } @@ -852,6 +936,10 @@ func (m *MatchMutation) OldField(ctx context.Context, name string) (ent.Value, e return m.OldMaxRounds(ctx) case match.FieldDemoParsed: return m.OldDemoParsed(ctx) + case match.FieldVacPresent: + return m.OldVacPresent(ctx) + case match.FieldGamebanPresent: + return m.OldGamebanPresent(ctx) } return nil, fmt.Errorf("unknown Match field %s", name) } @@ -931,6 +1019,20 @@ func (m *MatchMutation) SetField(name string, value ent.Value) error { } m.SetDemoParsed(v) return nil + case match.FieldVacPresent: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVacPresent(v) + return nil + case match.FieldGamebanPresent: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetGamebanPresent(v) + return nil } return fmt.Errorf("unknown Match field %s", name) } @@ -1088,6 +1190,12 @@ func (m *MatchMutation) ResetField(name string) error { case match.FieldDemoParsed: m.ResetDemoParsed() return nil + case match.FieldVacPresent: + m.ResetVacPresent() + return nil + case match.FieldGamebanPresent: + m.ResetGamebanPresent() + return nil } return fmt.Errorf("unknown Match field %s", name) } diff --git a/ent/runtime.go b/ent/runtime.go index da2a266..0ad7602 100644 --- a/ent/runtime.go +++ b/ent/runtime.go @@ -19,6 +19,14 @@ func init() { matchDescDemoParsed := matchFields[10].Descriptor() // match.DefaultDemoParsed holds the default value on creation for the demo_parsed field. match.DefaultDemoParsed = matchDescDemoParsed.Default.(bool) + // matchDescVacPresent is the schema descriptor for vac_present field. + matchDescVacPresent := matchFields[11].Descriptor() + // match.DefaultVacPresent holds the default value on creation for the vac_present field. + match.DefaultVacPresent = matchDescVacPresent.Default.(bool) + // matchDescGamebanPresent is the schema descriptor for gameban_present field. + matchDescGamebanPresent := matchFields[12].Descriptor() + // match.DefaultGamebanPresent holds the default value on creation for the gameban_present field. + match.DefaultGamebanPresent = matchDescGamebanPresent.Default.(bool) playerFields := schema.Player{}.Fields() _ = playerFields // playerDescSteamUpdated is the schema descriptor for steam_updated field. diff --git a/ent/schema/match.go b/ent/schema/match.go index d3bd0b1..e0cbfd2 100644 --- a/ent/schema/match.go +++ b/ent/schema/match.go @@ -25,6 +25,8 @@ func (Match) Fields() []ent.Field { field.Int("match_result"), field.Int("max_rounds"), field.Bool("demo_parsed").Default(false), + field.Bool("vac_present").Default(false), + field.Bool("gameban_present").Default(false), } } diff --git a/go.mod b/go.mod index 56f2741..b211ac0 100644 --- a/go.mod +++ b/go.mod @@ -45,8 +45,8 @@ require ( github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect - golang.org/x/exp v0.0.0-20211012155715-ffe10e552389 // indirect + golang.org/x/exp v0.0.0-20211025140241-8418b01e8c3b // indirect golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect - golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70 // indirect + golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359 // indirect golang.org/x/text v0.3.7 // indirect ) diff --git a/go.sum b/go.sum index c8d2843..bfa9db7 100644 --- a/go.sum +++ b/go.sum @@ -541,8 +541,8 @@ golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56/go.mod h1:JhuoJpWY28nO4Vef9t golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= golang.org/x/exp v0.0.0-20210916165020-5cb4fee858ee/go.mod h1:a3o/VtDNHN+dCVLEpzjjUHOzR+Ln3DHX056ZPzoZGGA= -golang.org/x/exp v0.0.0-20211012155715-ffe10e552389 h1:qFfBYVpJAdBCk6Nmd7ZbcyhGmKmv8fps+OyoOfpjvu8= -golang.org/x/exp v0.0.0-20211012155715-ffe10e552389/go.mod h1:a3o/VtDNHN+dCVLEpzjjUHOzR+Ln3DHX056ZPzoZGGA= +golang.org/x/exp v0.0.0-20211025140241-8418b01e8c3b h1:AHIXEGqpPGg/yJCO803Q+UbBiq/vkCe/OPwMSVE7psI= +golang.org/x/exp v0.0.0-20211025140241-8418b01e8c3b/go.mod h1:a3o/VtDNHN+dCVLEpzjjUHOzR+Ln3DHX056ZPzoZGGA= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= @@ -640,8 +640,8 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70 h1:SeSEfdIxyvwGJliREIJhRPPXvW6sDlLT+UQ3B0hD0NA= -golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359 h1:2B5p2L5IfGiD7+b9BOoRMC6DgObAVZV+Fsp050NqXik= +golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/main.go b/main.go index de6d3e9..2422be6 100644 --- a/main.go +++ b/main.go @@ -72,6 +72,29 @@ func housekeeping() { } } + // mark matches as vac/gameban + bPlayers, err := db.Player.Query().Select(player.FieldID, player.FieldGameBanDate, player.FieldVacDate).Where(player.Or(player.GameBanDateNotNil(), player.VacDateNotNil())).All(context.Background()) + if err != nil { + log.Warningf("[HK] Unable to query for banned players: %v", err) + } + + for _, bp := range bPlayers { + qMatch := db.Match.Update().Where(match.HasPlayersWith(player.ID(bp.ID))) + + if !bp.GameBanDate.IsZero() { + qMatch.Where(match.DateLTE(bp.GameBanDate.AddDate(0, 0, -30))).SetGamebanPresent(true) + } + + if !bp.VacDate.IsZero() { + qMatch.Where(match.DateLTE(bp.VacDate.AddDate(0, 0, -30))).SetVacPresent(true) + } + + err := qMatch.Exec(context.Background()) + if err != nil { + log.Warningf("[HK] Unable to query for banned players matches: %v", err) + } + } + // getting new sharecodes if !demoLoader.GCReady { log.Warningf("[HK] GC not ready, skipping sharecode refresh") @@ -349,6 +372,8 @@ func getPlayer(w http.ResponseWriter, r *http.Request) { MatchResult: iMatch.MatchResult, MaxRounds: iMatch.MaxRounds, Parsed: iMatch.DemoParsed, + VAC: iMatch.VacPresent, + GameBan: iMatch.GamebanPresent, } tStats, err := iMatch.QueryStats().Modify(func(s *sql.Selector) { diff --git a/utils/utils.go b/utils/utils.go index 96bb898..9c1ff7c 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -178,6 +178,8 @@ type MatchResponse struct { MaxRounds int `json:"max_rounds,omitempty"` Parsed bool `json:"parsed"` ReplayURL string `json:"replay_url,omitempty"` + VAC bool `json:"vac"` + GameBan bool `json:"game_ban"` Stats interface{} `json:"stats,omitempty"` }