diff --git a/ent/migrate/schema.go b/ent/migrate/schema.go index 45b47b8..bdf1fef 100644 --- a/ent/migrate/schema.go +++ b/ent/migrate/schema.go @@ -37,6 +37,8 @@ var ( {Name: "vanity_url_real", Type: field.TypeString, Nullable: true}, {Name: "vac_date", Type: field.TypeTime, Nullable: true}, {Name: "vac_count", Type: field.TypeInt, Nullable: true}, + {Name: "game_ban_date", Type: field.TypeTime, Nullable: true}, + {Name: "game_ban_count", Type: field.TypeInt, Nullable: true}, {Name: "steam_updated", Type: field.TypeTime}, {Name: "sharecode_updated", Type: field.TypeTime, Nullable: true}, {Name: "auth_code", Type: field.TypeString, Nullable: true}, diff --git a/ent/mutation.go b/ent/mutation.go index 8874af8..07241f1 100644 --- a/ent/mutation.go +++ b/ent/mutation.go @@ -1215,6 +1215,9 @@ type PlayerMutation struct { vac_date *time.Time vac_count *int addvac_count *int + game_ban_date *time.Time + game_ban_count *int + addgame_ban_count *int steam_updated *time.Time sharecode_updated *time.Time auth_code *string @@ -1632,6 +1635,125 @@ func (m *PlayerMutation) ResetVacCount() { delete(m.clearedFields, player.FieldVacCount) } +// SetGameBanDate sets the "game_ban_date" field. +func (m *PlayerMutation) SetGameBanDate(t time.Time) { + m.game_ban_date = &t +} + +// GameBanDate returns the value of the "game_ban_date" field in the mutation. +func (m *PlayerMutation) GameBanDate() (r time.Time, exists bool) { + v := m.game_ban_date + if v == nil { + return + } + return *v, true +} + +// OldGameBanDate returns the old "game_ban_date" field's value of the Player entity. +// If the Player 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 *PlayerMutation) OldGameBanDate(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldGameBanDate is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldGameBanDate requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldGameBanDate: %w", err) + } + return oldValue.GameBanDate, nil +} + +// ClearGameBanDate clears the value of the "game_ban_date" field. +func (m *PlayerMutation) ClearGameBanDate() { + m.game_ban_date = nil + m.clearedFields[player.FieldGameBanDate] = struct{}{} +} + +// GameBanDateCleared returns if the "game_ban_date" field was cleared in this mutation. +func (m *PlayerMutation) GameBanDateCleared() bool { + _, ok := m.clearedFields[player.FieldGameBanDate] + return ok +} + +// ResetGameBanDate resets all changes to the "game_ban_date" field. +func (m *PlayerMutation) ResetGameBanDate() { + m.game_ban_date = nil + delete(m.clearedFields, player.FieldGameBanDate) +} + +// SetGameBanCount sets the "game_ban_count" field. +func (m *PlayerMutation) SetGameBanCount(i int) { + m.game_ban_count = &i + m.addgame_ban_count = nil +} + +// GameBanCount returns the value of the "game_ban_count" field in the mutation. +func (m *PlayerMutation) GameBanCount() (r int, exists bool) { + v := m.game_ban_count + if v == nil { + return + } + return *v, true +} + +// OldGameBanCount returns the old "game_ban_count" field's value of the Player entity. +// If the Player 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 *PlayerMutation) OldGameBanCount(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldGameBanCount is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldGameBanCount requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldGameBanCount: %w", err) + } + return oldValue.GameBanCount, nil +} + +// AddGameBanCount adds i to the "game_ban_count" field. +func (m *PlayerMutation) AddGameBanCount(i int) { + if m.addgame_ban_count != nil { + *m.addgame_ban_count += i + } else { + m.addgame_ban_count = &i + } +} + +// AddedGameBanCount returns the value that was added to the "game_ban_count" field in this mutation. +func (m *PlayerMutation) AddedGameBanCount() (r int, exists bool) { + v := m.addgame_ban_count + if v == nil { + return + } + return *v, true +} + +// ClearGameBanCount clears the value of the "game_ban_count" field. +func (m *PlayerMutation) ClearGameBanCount() { + m.game_ban_count = nil + m.addgame_ban_count = nil + m.clearedFields[player.FieldGameBanCount] = struct{}{} +} + +// GameBanCountCleared returns if the "game_ban_count" field was cleared in this mutation. +func (m *PlayerMutation) GameBanCountCleared() bool { + _, ok := m.clearedFields[player.FieldGameBanCount] + return ok +} + +// ResetGameBanCount resets all changes to the "game_ban_count" field. +func (m *PlayerMutation) ResetGameBanCount() { + m.game_ban_count = nil + m.addgame_ban_count = nil + delete(m.clearedFields, player.FieldGameBanCount) +} + // SetSteamUpdated sets the "steam_updated" field. func (m *PlayerMutation) SetSteamUpdated(t time.Time) { m.steam_updated = &t @@ -1991,7 +2113,7 @@ func (m *PlayerMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *PlayerMutation) Fields() []string { - fields := make([]string, 0, 11) + fields := make([]string, 0, 13) if m.name != nil { fields = append(fields, player.FieldName) } @@ -2010,6 +2132,12 @@ func (m *PlayerMutation) Fields() []string { if m.vac_count != nil { fields = append(fields, player.FieldVacCount) } + if m.game_ban_date != nil { + fields = append(fields, player.FieldGameBanDate) + } + if m.game_ban_count != nil { + fields = append(fields, player.FieldGameBanCount) + } if m.steam_updated != nil { fields = append(fields, player.FieldSteamUpdated) } @@ -2045,6 +2173,10 @@ func (m *PlayerMutation) Field(name string) (ent.Value, bool) { return m.VacDate() case player.FieldVacCount: return m.VacCount() + case player.FieldGameBanDate: + return m.GameBanDate() + case player.FieldGameBanCount: + return m.GameBanCount() case player.FieldSteamUpdated: return m.SteamUpdated() case player.FieldSharecodeUpdated: @@ -2076,6 +2208,10 @@ func (m *PlayerMutation) OldField(ctx context.Context, name string) (ent.Value, return m.OldVacDate(ctx) case player.FieldVacCount: return m.OldVacCount(ctx) + case player.FieldGameBanDate: + return m.OldGameBanDate(ctx) + case player.FieldGameBanCount: + return m.OldGameBanCount(ctx) case player.FieldSteamUpdated: return m.OldSteamUpdated(ctx) case player.FieldSharecodeUpdated: @@ -2137,6 +2273,20 @@ func (m *PlayerMutation) SetField(name string, value ent.Value) error { } m.SetVacCount(v) return nil + case player.FieldGameBanDate: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetGameBanDate(v) + return nil + case player.FieldGameBanCount: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetGameBanCount(v) + return nil case player.FieldSteamUpdated: v, ok := value.(time.Time) if !ok { @@ -2183,6 +2333,9 @@ func (m *PlayerMutation) AddedFields() []string { if m.addvac_count != nil { fields = append(fields, player.FieldVacCount) } + if m.addgame_ban_count != nil { + fields = append(fields, player.FieldGameBanCount) + } return fields } @@ -2193,6 +2346,8 @@ func (m *PlayerMutation) AddedField(name string) (ent.Value, bool) { switch name { case player.FieldVacCount: return m.AddedVacCount() + case player.FieldGameBanCount: + return m.AddedGameBanCount() } return nil, false } @@ -2209,6 +2364,13 @@ func (m *PlayerMutation) AddField(name string, value ent.Value) error { } m.AddVacCount(v) return nil + case player.FieldGameBanCount: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddGameBanCount(v) + return nil } return fmt.Errorf("unknown Player numeric field %s", name) } @@ -2235,6 +2397,12 @@ func (m *PlayerMutation) ClearedFields() []string { if m.FieldCleared(player.FieldVacCount) { fields = append(fields, player.FieldVacCount) } + if m.FieldCleared(player.FieldGameBanDate) { + fields = append(fields, player.FieldGameBanDate) + } + if m.FieldCleared(player.FieldGameBanCount) { + fields = append(fields, player.FieldGameBanCount) + } if m.FieldCleared(player.FieldSharecodeUpdated) { fields = append(fields, player.FieldSharecodeUpdated) } @@ -2279,6 +2447,12 @@ func (m *PlayerMutation) ClearField(name string) error { case player.FieldVacCount: m.ClearVacCount() return nil + case player.FieldGameBanDate: + m.ClearGameBanDate() + return nil + case player.FieldGameBanCount: + m.ClearGameBanCount() + return nil case player.FieldSharecodeUpdated: m.ClearSharecodeUpdated() return nil @@ -2317,6 +2491,12 @@ func (m *PlayerMutation) ResetField(name string) error { case player.FieldVacCount: m.ResetVacCount() return nil + case player.FieldGameBanDate: + m.ResetGameBanDate() + return nil + case player.FieldGameBanCount: + m.ResetGameBanCount() + return nil case player.FieldSteamUpdated: m.ResetSteamUpdated() return nil diff --git a/ent/player.go b/ent/player.go index 23505db..cdc8ab3 100644 --- a/ent/player.go +++ b/ent/player.go @@ -28,6 +28,10 @@ type Player struct { VacDate time.Time `json:"vac_date,omitempty"` // VacCount holds the value of the "vac_count" field. VacCount int `json:"vac_count,omitempty"` + // GameBanDate holds the value of the "game_ban_date" field. + GameBanDate time.Time `json:"game_ban_date,omitempty"` + // GameBanCount holds the value of the "game_ban_count" field. + GameBanCount int `json:"game_ban_count,omitempty"` // SteamUpdated holds the value of the "steam_updated" field. SteamUpdated time.Time `json:"-"` // SharecodeUpdated holds the value of the "sharecode_updated" field. @@ -77,11 +81,11 @@ func (*Player) scanValues(columns []string) ([]interface{}, error) { values := make([]interface{}, len(columns)) for i := range columns { switch columns[i] { - case player.FieldID, player.FieldVacCount: + case player.FieldID, player.FieldVacCount, player.FieldGameBanCount: values[i] = new(sql.NullInt64) case player.FieldName, player.FieldAvatar, player.FieldVanityURL, player.FieldVanityURLReal, player.FieldAuthCode, player.FieldOldestSharecodeSeen: values[i] = new(sql.NullString) - case player.FieldVacDate, player.FieldSteamUpdated, player.FieldSharecodeUpdated, player.FieldProfileCreated: + case player.FieldVacDate, player.FieldGameBanDate, player.FieldSteamUpdated, player.FieldSharecodeUpdated, player.FieldProfileCreated: values[i] = new(sql.NullTime) default: return nil, fmt.Errorf("unexpected column %q for type Player", columns[i]) @@ -140,6 +144,18 @@ func (pl *Player) assignValues(columns []string, values []interface{}) error { } else if value.Valid { pl.VacCount = int(value.Int64) } + case player.FieldGameBanDate: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field game_ban_date", values[i]) + } else if value.Valid { + pl.GameBanDate = value.Time + } + case player.FieldGameBanCount: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field game_ban_count", values[i]) + } else if value.Valid { + pl.GameBanCount = int(value.Int64) + } case player.FieldSteamUpdated: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field steam_updated", values[i]) @@ -220,6 +236,10 @@ func (pl *Player) String() string { builder.WriteString(pl.VacDate.Format(time.ANSIC)) builder.WriteString(", vac_count=") builder.WriteString(fmt.Sprintf("%v", pl.VacCount)) + builder.WriteString(", game_ban_date=") + builder.WriteString(pl.GameBanDate.Format(time.ANSIC)) + builder.WriteString(", game_ban_count=") + builder.WriteString(fmt.Sprintf("%v", pl.GameBanCount)) builder.WriteString(", steam_updated=") builder.WriteString(pl.SteamUpdated.Format(time.ANSIC)) builder.WriteString(", sharecode_updated=") diff --git a/ent/player/player.go b/ent/player/player.go index 8743e90..e4f0bd8 100644 --- a/ent/player/player.go +++ b/ent/player/player.go @@ -23,6 +23,10 @@ const ( FieldVacDate = "vac_date" // FieldVacCount holds the string denoting the vac_count field in the database. FieldVacCount = "vac_count" + // FieldGameBanDate holds the string denoting the game_ban_date field in the database. + FieldGameBanDate = "game_ban_date" + // FieldGameBanCount holds the string denoting the game_ban_count field in the database. + FieldGameBanCount = "game_ban_count" // FieldSteamUpdated holds the string denoting the steam_updated field in the database. FieldSteamUpdated = "steam_updated" // FieldSharecodeUpdated holds the string denoting the sharecode_updated field in the database. @@ -62,6 +66,8 @@ var Columns = []string{ FieldVanityURLReal, FieldVacDate, FieldVacCount, + FieldGameBanDate, + FieldGameBanCount, FieldSteamUpdated, FieldSharecodeUpdated, FieldAuthCode, diff --git a/ent/player/where.go b/ent/player/where.go index 7f32ca6..fa2a45c 100644 --- a/ent/player/where.go +++ b/ent/player/where.go @@ -135,6 +135,20 @@ func VacCount(v int) predicate.Player { }) } +// GameBanDate applies equality check predicate on the "game_ban_date" field. It's identical to GameBanDateEQ. +func GameBanDate(v time.Time) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldGameBanDate), v)) + }) +} + +// GameBanCount applies equality check predicate on the "game_ban_count" field. It's identical to GameBanCountEQ. +func GameBanCount(v int) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldGameBanCount), v)) + }) +} + // SteamUpdated applies equality check predicate on the "steam_updated" field. It's identical to SteamUpdatedEQ. func SteamUpdated(v time.Time) predicate.Player { return predicate.Player(func(s *sql.Selector) { @@ -850,6 +864,186 @@ func VacCountNotNil() predicate.Player { }) } +// GameBanDateEQ applies the EQ predicate on the "game_ban_date" field. +func GameBanDateEQ(v time.Time) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldGameBanDate), v)) + }) +} + +// GameBanDateNEQ applies the NEQ predicate on the "game_ban_date" field. +func GameBanDateNEQ(v time.Time) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldGameBanDate), v)) + }) +} + +// GameBanDateIn applies the In predicate on the "game_ban_date" field. +func GameBanDateIn(vs ...time.Time) predicate.Player { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Player(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(FieldGameBanDate), v...)) + }) +} + +// GameBanDateNotIn applies the NotIn predicate on the "game_ban_date" field. +func GameBanDateNotIn(vs ...time.Time) predicate.Player { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Player(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(FieldGameBanDate), v...)) + }) +} + +// GameBanDateGT applies the GT predicate on the "game_ban_date" field. +func GameBanDateGT(v time.Time) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldGameBanDate), v)) + }) +} + +// GameBanDateGTE applies the GTE predicate on the "game_ban_date" field. +func GameBanDateGTE(v time.Time) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldGameBanDate), v)) + }) +} + +// GameBanDateLT applies the LT predicate on the "game_ban_date" field. +func GameBanDateLT(v time.Time) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldGameBanDate), v)) + }) +} + +// GameBanDateLTE applies the LTE predicate on the "game_ban_date" field. +func GameBanDateLTE(v time.Time) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldGameBanDate), v)) + }) +} + +// GameBanDateIsNil applies the IsNil predicate on the "game_ban_date" field. +func GameBanDateIsNil() predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldGameBanDate))) + }) +} + +// GameBanDateNotNil applies the NotNil predicate on the "game_ban_date" field. +func GameBanDateNotNil() predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldGameBanDate))) + }) +} + +// GameBanCountEQ applies the EQ predicate on the "game_ban_count" field. +func GameBanCountEQ(v int) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldGameBanCount), v)) + }) +} + +// GameBanCountNEQ applies the NEQ predicate on the "game_ban_count" field. +func GameBanCountNEQ(v int) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldGameBanCount), v)) + }) +} + +// GameBanCountIn applies the In predicate on the "game_ban_count" field. +func GameBanCountIn(vs ...int) predicate.Player { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Player(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(FieldGameBanCount), v...)) + }) +} + +// GameBanCountNotIn applies the NotIn predicate on the "game_ban_count" field. +func GameBanCountNotIn(vs ...int) predicate.Player { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Player(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(FieldGameBanCount), v...)) + }) +} + +// GameBanCountGT applies the GT predicate on the "game_ban_count" field. +func GameBanCountGT(v int) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldGameBanCount), v)) + }) +} + +// GameBanCountGTE applies the GTE predicate on the "game_ban_count" field. +func GameBanCountGTE(v int) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldGameBanCount), v)) + }) +} + +// GameBanCountLT applies the LT predicate on the "game_ban_count" field. +func GameBanCountLT(v int) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldGameBanCount), v)) + }) +} + +// GameBanCountLTE applies the LTE predicate on the "game_ban_count" field. +func GameBanCountLTE(v int) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldGameBanCount), v)) + }) +} + +// GameBanCountIsNil applies the IsNil predicate on the "game_ban_count" field. +func GameBanCountIsNil() predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldGameBanCount))) + }) +} + +// GameBanCountNotNil applies the NotNil predicate on the "game_ban_count" field. +func GameBanCountNotNil() predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldGameBanCount))) + }) +} + // SteamUpdatedEQ applies the EQ predicate on the "steam_updated" field. func SteamUpdatedEQ(v time.Time) predicate.Player { return predicate.Player(func(s *sql.Selector) { diff --git a/ent/player_create.go b/ent/player_create.go index 3195e1d..ea7d3b6 100644 --- a/ent/player_create.go +++ b/ent/player_create.go @@ -106,6 +106,34 @@ func (pc *PlayerCreate) SetNillableVacCount(i *int) *PlayerCreate { return pc } +// SetGameBanDate sets the "game_ban_date" field. +func (pc *PlayerCreate) SetGameBanDate(t time.Time) *PlayerCreate { + pc.mutation.SetGameBanDate(t) + return pc +} + +// SetNillableGameBanDate sets the "game_ban_date" field if the given value is not nil. +func (pc *PlayerCreate) SetNillableGameBanDate(t *time.Time) *PlayerCreate { + if t != nil { + pc.SetGameBanDate(*t) + } + return pc +} + +// SetGameBanCount sets the "game_ban_count" field. +func (pc *PlayerCreate) SetGameBanCount(i int) *PlayerCreate { + pc.mutation.SetGameBanCount(i) + return pc +} + +// SetNillableGameBanCount sets the "game_ban_count" field if the given value is not nil. +func (pc *PlayerCreate) SetNillableGameBanCount(i *int) *PlayerCreate { + if i != nil { + pc.SetGameBanCount(*i) + } + return pc +} + // SetSteamUpdated sets the "steam_updated" field. func (pc *PlayerCreate) SetSteamUpdated(t time.Time) *PlayerCreate { pc.mutation.SetSteamUpdated(t) @@ -375,6 +403,22 @@ func (pc *PlayerCreate) createSpec() (*Player, *sqlgraph.CreateSpec) { }) _node.VacCount = value } + if value, ok := pc.mutation.GameBanDate(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeTime, + Value: value, + Column: player.FieldGameBanDate, + }) + _node.GameBanDate = value + } + if value, ok := pc.mutation.GameBanCount(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: player.FieldGameBanCount, + }) + _node.GameBanCount = value + } if value, ok := pc.mutation.SteamUpdated(); ok { _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ Type: field.TypeTime, diff --git a/ent/player_update.go b/ent/player_update.go index 3a77972..d2057b5 100644 --- a/ent/player_update.go +++ b/ent/player_update.go @@ -156,6 +156,53 @@ func (pu *PlayerUpdate) ClearVacCount() *PlayerUpdate { return pu } +// SetGameBanDate sets the "game_ban_date" field. +func (pu *PlayerUpdate) SetGameBanDate(t time.Time) *PlayerUpdate { + pu.mutation.SetGameBanDate(t) + return pu +} + +// SetNillableGameBanDate sets the "game_ban_date" field if the given value is not nil. +func (pu *PlayerUpdate) SetNillableGameBanDate(t *time.Time) *PlayerUpdate { + if t != nil { + pu.SetGameBanDate(*t) + } + return pu +} + +// ClearGameBanDate clears the value of the "game_ban_date" field. +func (pu *PlayerUpdate) ClearGameBanDate() *PlayerUpdate { + pu.mutation.ClearGameBanDate() + return pu +} + +// SetGameBanCount sets the "game_ban_count" field. +func (pu *PlayerUpdate) SetGameBanCount(i int) *PlayerUpdate { + pu.mutation.ResetGameBanCount() + pu.mutation.SetGameBanCount(i) + return pu +} + +// SetNillableGameBanCount sets the "game_ban_count" field if the given value is not nil. +func (pu *PlayerUpdate) SetNillableGameBanCount(i *int) *PlayerUpdate { + if i != nil { + pu.SetGameBanCount(*i) + } + return pu +} + +// AddGameBanCount adds i to the "game_ban_count" field. +func (pu *PlayerUpdate) AddGameBanCount(i int) *PlayerUpdate { + pu.mutation.AddGameBanCount(i) + return pu +} + +// ClearGameBanCount clears the value of the "game_ban_count" field. +func (pu *PlayerUpdate) ClearGameBanCount() *PlayerUpdate { + pu.mutation.ClearGameBanCount() + return pu +} + // SetSteamUpdated sets the "steam_updated" field. func (pu *PlayerUpdate) SetSteamUpdated(t time.Time) *PlayerUpdate { pu.mutation.SetSteamUpdated(t) @@ -484,6 +531,39 @@ func (pu *PlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { Column: player.FieldVacCount, }) } + if value, ok := pu.mutation.GameBanDate(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeTime, + Value: value, + Column: player.FieldGameBanDate, + }) + } + if pu.mutation.GameBanDateCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeTime, + Column: player.FieldGameBanDate, + }) + } + if value, ok := pu.mutation.GameBanCount(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: player.FieldGameBanCount, + }) + } + if value, ok := pu.mutation.AddedGameBanCount(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: player.FieldGameBanCount, + }) + } + if pu.mutation.GameBanCountCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: player.FieldGameBanCount, + }) + } if value, ok := pu.mutation.SteamUpdated(); ok { _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ Type: field.TypeTime, @@ -797,6 +877,53 @@ func (puo *PlayerUpdateOne) ClearVacCount() *PlayerUpdateOne { return puo } +// SetGameBanDate sets the "game_ban_date" field. +func (puo *PlayerUpdateOne) SetGameBanDate(t time.Time) *PlayerUpdateOne { + puo.mutation.SetGameBanDate(t) + return puo +} + +// SetNillableGameBanDate sets the "game_ban_date" field if the given value is not nil. +func (puo *PlayerUpdateOne) SetNillableGameBanDate(t *time.Time) *PlayerUpdateOne { + if t != nil { + puo.SetGameBanDate(*t) + } + return puo +} + +// ClearGameBanDate clears the value of the "game_ban_date" field. +func (puo *PlayerUpdateOne) ClearGameBanDate() *PlayerUpdateOne { + puo.mutation.ClearGameBanDate() + return puo +} + +// SetGameBanCount sets the "game_ban_count" field. +func (puo *PlayerUpdateOne) SetGameBanCount(i int) *PlayerUpdateOne { + puo.mutation.ResetGameBanCount() + puo.mutation.SetGameBanCount(i) + return puo +} + +// SetNillableGameBanCount sets the "game_ban_count" field if the given value is not nil. +func (puo *PlayerUpdateOne) SetNillableGameBanCount(i *int) *PlayerUpdateOne { + if i != nil { + puo.SetGameBanCount(*i) + } + return puo +} + +// AddGameBanCount adds i to the "game_ban_count" field. +func (puo *PlayerUpdateOne) AddGameBanCount(i int) *PlayerUpdateOne { + puo.mutation.AddGameBanCount(i) + return puo +} + +// ClearGameBanCount clears the value of the "game_ban_count" field. +func (puo *PlayerUpdateOne) ClearGameBanCount() *PlayerUpdateOne { + puo.mutation.ClearGameBanCount() + return puo +} + // SetSteamUpdated sets the "steam_updated" field. func (puo *PlayerUpdateOne) SetSteamUpdated(t time.Time) *PlayerUpdateOne { puo.mutation.SetSteamUpdated(t) @@ -1149,6 +1276,39 @@ func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err err Column: player.FieldVacCount, }) } + if value, ok := puo.mutation.GameBanDate(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeTime, + Value: value, + Column: player.FieldGameBanDate, + }) + } + if puo.mutation.GameBanDateCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeTime, + Column: player.FieldGameBanDate, + }) + } + if value, ok := puo.mutation.GameBanCount(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: player.FieldGameBanCount, + }) + } + if value, ok := puo.mutation.AddedGameBanCount(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: player.FieldGameBanCount, + }) + } + if puo.mutation.GameBanCountCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: player.FieldGameBanCount, + }) + } if value, ok := puo.mutation.SteamUpdated(); ok { _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ Type: field.TypeTime, diff --git a/ent/runtime.go b/ent/runtime.go index 66aba5e..da2a266 100644 --- a/ent/runtime.go +++ b/ent/runtime.go @@ -22,7 +22,7 @@ func init() { playerFields := schema.Player{}.Fields() _ = playerFields // playerDescSteamUpdated is the schema descriptor for steam_updated field. - playerDescSteamUpdated := playerFields[7].Descriptor() + playerDescSteamUpdated := playerFields[9].Descriptor() // player.DefaultSteamUpdated holds the default value on creation for the steam_updated field. player.DefaultSteamUpdated = playerDescSteamUpdated.Default.(func() time.Time) } diff --git a/ent/schema/player.go b/ent/schema/player.go index e24db28..fd99270 100644 --- a/ent/schema/player.go +++ b/ent/schema/player.go @@ -22,6 +22,8 @@ func (Player) Fields() []ent.Field { field.String("vanity_url_real").Optional(), field.Time("vac_date").Optional(), field.Int("vac_count").Optional(), + field.Time("game_ban_date").Optional(), + field.Int("game_ban_count").Optional(), field.Time("steam_updated").Default(func() time.Time { return time.Now().UTC() }).StructTag(`json:"-"`), diff --git a/go.mod b/go.mod index 6a2ae23..e9cda18 100644 --- a/go.mod +++ b/go.mod @@ -26,12 +26,9 @@ require ( github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/felixge/httpsnoop v1.0.2 // indirect - github.com/go-bindata/go-bindata v1.0.1-0.20190711162640-ee3c2418e368 // indirect - github.com/go-openapi/inflect v0.19.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 // indirect github.com/google/uuid v1.3.0 // indirect - github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/jackc/chunkreader/v2 v2.0.1 // indirect github.com/jackc/pgconn v1.10.0 // indirect github.com/jackc/pgio v1.0.0 // indirect @@ -44,20 +41,13 @@ require ( github.com/markus-wa/gobitread v0.2.3 // indirect github.com/markus-wa/godispatch v1.4.1 // indirect github.com/markus-wa/quickhull-go/v2 v2.1.0 // indirect - github.com/mattn/go-runewidth v0.0.9 // indirect - github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/spf13/cobra v1.1.3 // indirect - github.com/spf13/pflag v1.0.5 // indirect github.com/vmihailenco/go-tinylfu v0.2.2 // indirect 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/mod v0.5.1-0.20210830214625-1b1db11ec8f4 // indirect golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect golang.org/x/sys v0.0.0-20211020174200-9d6173849985 // indirect golang.org/x/text v0.3.7 // indirect - golang.org/x/tools v0.1.5 // indirect - golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect ) diff --git a/go.sum b/go.sum index 99e1b9e..1fa5452 100644 --- a/go.sum +++ b/go.sum @@ -107,7 +107,6 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/go-bindata/go-bindata v1.0.1-0.20190711162640-ee3c2418e368 h1:WNHfSP1q2vuAa9vF54RrhCl4nqxCjVcXhlbsRXbGOSY= github.com/go-bindata/go-bindata v1.0.1-0.20190711162640-ee3c2418e368/go.mod h1:7xCgX1lzlrXPHkfvn3EhumqHkmSlzt8at9q7v0ax19c= github.com/go-gl/gl v0.0.0-20180407155706-68e253793080/go.mod h1:482civXOzJJCPzJ4ZOX/pwvXBWSnzD4OKMdH4ClKGbk= github.com/go-gl/glfw v0.0.0-20180426074136-46a8d530c326/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= @@ -121,7 +120,6 @@ 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= @@ -228,7 +226,6 @@ github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2p github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= -github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= github.com/jackc/chunkreader v1.0.0 h1:4s39bBR8ByfqH+DKm8rQA3E1LHZWB9XWcrz8fqaZbe0= @@ -315,8 +312,6 @@ github.com/llgcode/draw2d v0.0.0-20200930101115-bfaf5d914d1e/go.mod h1:mVa0dA29D github.com/llgcode/ps v0.0.0-20150911083025-f1443b32eedb/go.mod h1:1l8ky+Ew27CMX29uG+a2hNOKpeNYEQjjtiALiBlFQbY= github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/markus-wa/demoinfocs-golang/v2 v2.11.1 h1:KDPPB27MEDCg4j+Zx8xYzmCaMlb0qTb+bn66vEgGVJQ= -github.com/markus-wa/demoinfocs-golang/v2 v2.11.1/go.mod h1:BPIElNIVtyVzzc2AD3w/yMbiHiaq91o6L873PdZJobo= github.com/markus-wa/demoinfocs-golang/v2 v2.12.0 h1:XdUZ/SUgZdPNarerbErDuM1n7BlCzQs6DgbX5+9OR2w= github.com/markus-wa/demoinfocs-golang/v2 v2.12.0/go.mod h1:BPIElNIVtyVzzc2AD3w/yMbiHiaq91o6L873PdZJobo= github.com/markus-wa/go-unassert v0.1.2 h1:uXWlMDa8JVtc4RgNq4XJIjyRejv9MOVuy/E0VECPxxo= @@ -336,7 +331,6 @@ github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= 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/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/mattn/go-sqlite3 v1.14.9 h1:10HX2Td0ocZpYEjhilsuo6WWtUqttj2Kb0KtD86/KYA= @@ -371,7 +365,6 @@ 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= @@ -458,12 +451,10 @@ 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= @@ -487,7 +478,6 @@ github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijb github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/vmihailenco/go-tinylfu v0.2.2 h1:H1eiG6HM36iniK6+21n9LLpzx1G9R3DJa2UjUjbynsI= github.com/vmihailenco/go-tinylfu v0.2.2/go.mod h1:CutYi2Q9puTxfcolkliPq4npPuofg9N9t8JVrjzwa3Q= -github.com/vmihailenco/msgpack/v5 v5.3.4 h1:qMKAwOV+meBw2Y8k9cVwAy7qErtYCwBzZ2ellBfvnqc= github.com/vmihailenco/msgpack/v5 v5.3.4/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU= github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= @@ -575,7 +565,6 @@ 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= @@ -700,7 +689,6 @@ 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-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/main.go b/main.go index 30c598b..c375dac 100644 --- a/main.go +++ b/main.go @@ -171,14 +171,16 @@ func getPlayer(w http.ResponseWriter, r *http.Request) { } response := utils.PlayerResponse{ - SteamID64: tPlayer.ID, - Name: tPlayer.Name, - Avatar: tPlayer.Avatar, - VAC: !tPlayer.VacDate.IsZero(), - VACDate: tPlayer.VacDate.Unix(), - VanityURL: tPlayer.VanityURLReal, - Tracked: tPlayer.AuthCode != "", - Matches: []*utils.MatchResponse{}, + SteamID64: tPlayer.ID, + Name: tPlayer.Name, + Avatar: tPlayer.Avatar, + VAC: !tPlayer.VacDate.IsZero(), + VACDate: tPlayer.VacDate.Unix(), + GameBan: !tPlayer.GameBanDate.IsZero(), + GameBanDate: tPlayer.GameBanDate.Unix(), + VanityURL: tPlayer.VanityURLReal, + Tracked: tPlayer.AuthCode != "", + Matches: []*utils.MatchResponse{}, } var tMatches []*ent.Match @@ -616,13 +618,15 @@ func getMatch(w http.ResponseWriter, r *http.Request) { for _, iStats := range tStats { sResponse := &utils.StatsResponse{ Player: utils.PlayerResponse{ - SteamID64: iStats.Edges.Players.ID, - Name: iStats.Edges.Players.Name, - Avatar: iStats.Edges.Players.Avatar, - VAC: !iStats.Edges.Players.VacDate.IsZero(), - VACDate: iStats.Edges.Players.VacDate.Unix(), - VanityURL: iStats.Edges.Players.VanityURLReal, - Tracked: iStats.Edges.Players.AuthCode != "", + SteamID64: iStats.Edges.Players.ID, + Name: iStats.Edges.Players.Name, + Avatar: iStats.Edges.Players.Avatar, + VAC: !iStats.Edges.Players.VacDate.IsZero(), + VACDate: iStats.Edges.Players.VacDate.Unix(), + GameBan: !iStats.Edges.Players.GameBanDate.IsZero(), + GameBanDate: iStats.Edges.Players.GameBanDate.Unix(), + VanityURL: iStats.Edges.Players.VanityURLReal, + Tracked: iStats.Edges.Players.AuthCode != "", }, TeamID: iStats.TeamID, Kills: iStats.Kills, diff --git a/utils/utils.go b/utils/utils.go index d1a1548..dcd5b5e 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -131,15 +131,17 @@ type StatsResponse struct { } type PlayerResponse struct { - SteamID64 uint64 `json:"steamid64,string"` - Name string `json:"name,omitempty"` - Avatar string `json:"avatar,omitempty"` - VAC bool `json:"vac"` - VACDate int64 `json:"vac_date,omitempty"` - Tracked bool `json:"tracked"` - VanityURL string `json:"vanity_url,omitempty"` - MatchStats *MatchStats `json:"match_stats,omitempty"` - Matches []*MatchResponse `json:"matches,omitempty"` + SteamID64 uint64 `json:"steamid64,string"` + Name string `json:"name,omitempty"` + Avatar string `json:"avatar,omitempty"` + VAC bool `json:"vac"` + VACDate int64 `json:"vac_date,omitempty"` + GameBan bool `json:"game_ban"` + GameBanDate int64 `json:"game_ban_date"` + Tracked bool `json:"tracked"` + VanityURL string `json:"vanity_url,omitempty"` + MatchStats *MatchStats `json:"match_stats,omitempty"` + Matches []*MatchResponse `json:"matches,omitempty"` } type WeaponResponse struct { @@ -501,6 +503,16 @@ func UpdatePlayerFromSteam(players []*ent.Player, db *ent.Client, apiKey string, return nil, err } } + if ban.NumberOfGameBans > 0 { + banDate := time.Now().UTC().AddDate(0, 0, -1*int(ban.DaysSinceLastBan)) + + lock.Lock() + err := db.Player.UpdateOneID(ban.SteamID).SetGameBanCount(int(ban.NumberOfGameBans)).SetGameBanDate(banDate).Exec(context.Background()) + lock.Unlock() + if err != nil { + return nil, err + } + } } return nPlayers, nil