added vac/gameban marker for matches

This commit is contained in:
2021-10-28 08:47:41 +02:00
parent 25b153900f
commit 37233be336
14 changed files with 371 additions and 10 deletions

View File

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

View File

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

View File

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

View File

@@ -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,

View File

@@ -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,

View File

@@ -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{

View File

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

View File

@@ -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.

View File

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