refactored some functions, added demo download retry
This commit is contained in:
12
ent/match.go
12
ent/match.go
@@ -35,8 +35,6 @@ type Match struct {
|
||||
MatchResult int `json:"match_result,omitempty"`
|
||||
// MaxRounds holds the value of the "max_rounds" field.
|
||||
MaxRounds int `json:"max_rounds,omitempty"`
|
||||
// DemoExpired holds the value of the "demo_expired" field.
|
||||
DemoExpired bool `json:"demo_expired,omitempty"`
|
||||
// DemoParsed holds the value of the "demo_parsed" field.
|
||||
DemoParsed bool `json:"demo_parsed,omitempty"`
|
||||
// Eco holds the value of the "eco" field.
|
||||
@@ -88,7 +86,7 @@ func (*Match) scanValues(columns []string) ([]interface{}, error) {
|
||||
switch columns[i] {
|
||||
case match.FieldEco:
|
||||
values[i] = new([]byte)
|
||||
case match.FieldDemoExpired, match.FieldDemoParsed:
|
||||
case match.FieldDemoParsed:
|
||||
values[i] = new(sql.NullBool)
|
||||
case match.FieldID, match.FieldScoreTeamA, match.FieldScoreTeamB, match.FieldDuration, match.FieldMatchResult, match.FieldMaxRounds:
|
||||
values[i] = new(sql.NullInt64)
|
||||
@@ -171,12 +169,6 @@ func (m *Match) assignValues(columns []string, values []interface{}) error {
|
||||
} else if value.Valid {
|
||||
m.MaxRounds = 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])
|
||||
} else if value.Valid {
|
||||
m.DemoExpired = value.Bool
|
||||
}
|
||||
case match.FieldDemoParsed:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field demo_parsed", values[i])
|
||||
@@ -247,8 +239,6 @@ func (m *Match) String() string {
|
||||
builder.WriteString(fmt.Sprintf("%v", m.MatchResult))
|
||||
builder.WriteString(", max_rounds=")
|
||||
builder.WriteString(fmt.Sprintf("%v", m.MaxRounds))
|
||||
builder.WriteString(", demo_expired=")
|
||||
builder.WriteString(fmt.Sprintf("%v", m.DemoExpired))
|
||||
builder.WriteString(", demo_parsed=")
|
||||
builder.WriteString(fmt.Sprintf("%v", m.DemoParsed))
|
||||
builder.WriteString(", eco=")
|
||||
|
@@ -25,8 +25,6 @@ const (
|
||||
FieldMatchResult = "match_result"
|
||||
// FieldMaxRounds holds the string denoting the max_rounds field in the database.
|
||||
FieldMaxRounds = "max_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.
|
||||
FieldDemoParsed = "demo_parsed"
|
||||
// FieldEco holds the string denoting the eco field in the database.
|
||||
@@ -63,7 +61,6 @@ var Columns = []string{
|
||||
FieldDuration,
|
||||
FieldMatchResult,
|
||||
FieldMaxRounds,
|
||||
FieldDemoExpired,
|
||||
FieldDemoParsed,
|
||||
FieldEco,
|
||||
}
|
||||
@@ -85,8 +82,6 @@ func ValidColumn(column string) bool {
|
||||
}
|
||||
|
||||
var (
|
||||
// DefaultDemoExpired holds the default value on creation for the "demo_expired" field.
|
||||
DefaultDemoExpired bool
|
||||
// DefaultDemoParsed holds the default value on creation for the "demo_parsed" field.
|
||||
DefaultDemoParsed bool
|
||||
)
|
||||
|
@@ -156,13 +156,6 @@ func MaxRounds(v int) predicate.Match {
|
||||
})
|
||||
}
|
||||
|
||||
// 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) {
|
||||
s.Where(sql.EQ(s.C(FieldDemoExpired), v))
|
||||
})
|
||||
}
|
||||
|
||||
// DemoParsed applies equality check predicate on the "demo_parsed" field. It's identical to DemoParsedEQ.
|
||||
func DemoParsed(v bool) predicate.Match {
|
||||
return predicate.Match(func(s *sql.Selector) {
|
||||
@@ -987,20 +980,6 @@ func MaxRoundsLTE(v int) predicate.Match {
|
||||
})
|
||||
}
|
||||
|
||||
// DemoExpiredEQ applies the EQ predicate on the "demo_expired" field.
|
||||
func DemoExpiredEQ(v bool) predicate.Match {
|
||||
return predicate.Match(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldDemoExpired), v))
|
||||
})
|
||||
}
|
||||
|
||||
// DemoExpiredNEQ applies the NEQ predicate on the "demo_expired" field.
|
||||
func DemoExpiredNEQ(v bool) predicate.Match {
|
||||
return predicate.Match(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldDemoExpired), v))
|
||||
})
|
||||
}
|
||||
|
||||
// DemoParsedEQ applies the EQ predicate on the "demo_parsed" field.
|
||||
func DemoParsedEQ(v bool) predicate.Match {
|
||||
return predicate.Match(func(s *sql.Selector) {
|
||||
|
@@ -92,20 +92,6 @@ func (mc *MatchCreate) SetMaxRounds(i int) *MatchCreate {
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetDemoExpired sets the "demo_expired" field.
|
||||
func (mc *MatchCreate) SetDemoExpired(b bool) *MatchCreate {
|
||||
mc.mutation.SetDemoExpired(b)
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetNillableDemoExpired sets the "demo_expired" field if the given value is not nil.
|
||||
func (mc *MatchCreate) SetNillableDemoExpired(b *bool) *MatchCreate {
|
||||
if b != nil {
|
||||
mc.SetDemoExpired(*b)
|
||||
}
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetDemoParsed sets the "demo_parsed" field.
|
||||
func (mc *MatchCreate) SetDemoParsed(b bool) *MatchCreate {
|
||||
mc.mutation.SetDemoParsed(b)
|
||||
@@ -253,10 +239,6 @@ func (mc *MatchCreate) ExecX(ctx context.Context) {
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (mc *MatchCreate) defaults() {
|
||||
if _, ok := mc.mutation.DemoExpired(); !ok {
|
||||
v := match.DefaultDemoExpired
|
||||
mc.mutation.SetDemoExpired(v)
|
||||
}
|
||||
if _, ok := mc.mutation.DemoParsed(); !ok {
|
||||
v := match.DefaultDemoParsed
|
||||
mc.mutation.SetDemoParsed(v)
|
||||
@@ -286,9 +268,6 @@ func (mc *MatchCreate) check() error {
|
||||
if _, ok := mc.mutation.MaxRounds(); !ok {
|
||||
return &ValidationError{Name: "max_rounds", err: errors.New(`ent: missing required field "max_rounds"`)}
|
||||
}
|
||||
if _, ok := mc.mutation.DemoExpired(); !ok {
|
||||
return &ValidationError{Name: "demo_expired", err: errors.New(`ent: missing required field "demo_expired"`)}
|
||||
}
|
||||
if _, ok := mc.mutation.DemoParsed(); !ok {
|
||||
return &ValidationError{Name: "demo_parsed", err: errors.New(`ent: missing required field "demo_parsed"`)}
|
||||
}
|
||||
@@ -397,14 +376,6 @@ func (mc *MatchCreate) createSpec() (*Match, *sqlgraph.CreateSpec) {
|
||||
})
|
||||
_node.MaxRounds = value
|
||||
}
|
||||
if value, ok := mc.mutation.DemoExpired(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeBool,
|
||||
Value: value,
|
||||
Column: match.FieldDemoExpired,
|
||||
})
|
||||
_node.DemoExpired = value
|
||||
}
|
||||
if value, ok := mc.mutation.DemoParsed(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeBool,
|
||||
|
@@ -146,20 +146,6 @@ func (mu *MatchUpdate) AddMaxRounds(i int) *MatchUpdate {
|
||||
return mu
|
||||
}
|
||||
|
||||
// SetDemoExpired sets the "demo_expired" field.
|
||||
func (mu *MatchUpdate) SetDemoExpired(b bool) *MatchUpdate {
|
||||
mu.mutation.SetDemoExpired(b)
|
||||
return mu
|
||||
}
|
||||
|
||||
// SetNillableDemoExpired sets the "demo_expired" field if the given value is not nil.
|
||||
func (mu *MatchUpdate) SetNillableDemoExpired(b *bool) *MatchUpdate {
|
||||
if b != nil {
|
||||
mu.SetDemoExpired(*b)
|
||||
}
|
||||
return mu
|
||||
}
|
||||
|
||||
// SetDemoParsed sets the "demo_parsed" field.
|
||||
func (mu *MatchUpdate) SetDemoParsed(b bool) *MatchUpdate {
|
||||
mu.mutation.SetDemoParsed(b)
|
||||
@@ -465,13 +451,6 @@ func (mu *MatchUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
Column: match.FieldMaxRounds,
|
||||
})
|
||||
}
|
||||
if value, ok := mu.mutation.DemoExpired(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeBool,
|
||||
Value: value,
|
||||
Column: match.FieldDemoExpired,
|
||||
})
|
||||
}
|
||||
if value, ok := mu.mutation.DemoParsed(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeBool,
|
||||
@@ -736,20 +715,6 @@ func (muo *MatchUpdateOne) AddMaxRounds(i int) *MatchUpdateOne {
|
||||
return muo
|
||||
}
|
||||
|
||||
// SetDemoExpired sets the "demo_expired" field.
|
||||
func (muo *MatchUpdateOne) SetDemoExpired(b bool) *MatchUpdateOne {
|
||||
muo.mutation.SetDemoExpired(b)
|
||||
return muo
|
||||
}
|
||||
|
||||
// SetNillableDemoExpired sets the "demo_expired" field if the given value is not nil.
|
||||
func (muo *MatchUpdateOne) SetNillableDemoExpired(b *bool) *MatchUpdateOne {
|
||||
if b != nil {
|
||||
muo.SetDemoExpired(*b)
|
||||
}
|
||||
return muo
|
||||
}
|
||||
|
||||
// SetDemoParsed sets the "demo_parsed" field.
|
||||
func (muo *MatchUpdateOne) SetDemoParsed(b bool) *MatchUpdateOne {
|
||||
muo.mutation.SetDemoParsed(b)
|
||||
@@ -1079,13 +1044,6 @@ func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error
|
||||
Column: match.FieldMaxRounds,
|
||||
})
|
||||
}
|
||||
if value, ok := muo.mutation.DemoExpired(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeBool,
|
||||
Value: value,
|
||||
Column: match.FieldDemoExpired,
|
||||
})
|
||||
}
|
||||
if value, ok := muo.mutation.DemoParsed(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeBool,
|
||||
|
@@ -20,7 +20,6 @@ var (
|
||||
{Name: "duration", Type: field.TypeInt},
|
||||
{Name: "match_result", Type: field.TypeInt},
|
||||
{Name: "max_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},
|
||||
}
|
||||
|
@@ -49,7 +49,6 @@ type MatchMutation struct {
|
||||
addmatch_result *int
|
||||
max_rounds *int
|
||||
addmax_rounds *int
|
||||
demo_expired *bool
|
||||
demo_parsed *bool
|
||||
eco *struct {
|
||||
Rounds []*struct {
|
||||
@@ -605,42 +604,6 @@ func (m *MatchMutation) ResetMaxRounds() {
|
||||
m.addmax_rounds = nil
|
||||
}
|
||||
|
||||
// SetDemoExpired sets the "demo_expired" field.
|
||||
func (m *MatchMutation) SetDemoExpired(b bool) {
|
||||
m.demo_expired = &b
|
||||
}
|
||||
|
||||
// DemoExpired returns the value of the "demo_expired" field in the mutation.
|
||||
func (m *MatchMutation) DemoExpired() (r bool, exists bool) {
|
||||
v := m.demo_expired
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldDemoExpired returns the old "demo_expired" 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) OldDemoExpired(ctx context.Context) (v bool, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, fmt.Errorf("OldDemoExpired is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, fmt.Errorf("OldDemoExpired requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldDemoExpired: %w", err)
|
||||
}
|
||||
return oldValue.DemoExpired, nil
|
||||
}
|
||||
|
||||
// ResetDemoExpired resets all changes to the "demo_expired" field.
|
||||
func (m *MatchMutation) ResetDemoExpired() {
|
||||
m.demo_expired = nil
|
||||
}
|
||||
|
||||
// SetDemoParsed sets the "demo_parsed" field.
|
||||
func (m *MatchMutation) SetDemoParsed(b bool) {
|
||||
m.demo_parsed = &b
|
||||
@@ -871,7 +834,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, 11)
|
||||
if m.share_code != nil {
|
||||
fields = append(fields, match.FieldShareCode)
|
||||
}
|
||||
@@ -899,9 +862,6 @@ func (m *MatchMutation) Fields() []string {
|
||||
if m.max_rounds != nil {
|
||||
fields = append(fields, match.FieldMaxRounds)
|
||||
}
|
||||
if m.demo_expired != nil {
|
||||
fields = append(fields, match.FieldDemoExpired)
|
||||
}
|
||||
if m.demo_parsed != nil {
|
||||
fields = append(fields, match.FieldDemoParsed)
|
||||
}
|
||||
@@ -934,8 +894,6 @@ func (m *MatchMutation) Field(name string) (ent.Value, bool) {
|
||||
return m.MatchResult()
|
||||
case match.FieldMaxRounds:
|
||||
return m.MaxRounds()
|
||||
case match.FieldDemoExpired:
|
||||
return m.DemoExpired()
|
||||
case match.FieldDemoParsed:
|
||||
return m.DemoParsed()
|
||||
case match.FieldEco:
|
||||
@@ -967,8 +925,6 @@ func (m *MatchMutation) OldField(ctx context.Context, name string) (ent.Value, e
|
||||
return m.OldMatchResult(ctx)
|
||||
case match.FieldMaxRounds:
|
||||
return m.OldMaxRounds(ctx)
|
||||
case match.FieldDemoExpired:
|
||||
return m.OldDemoExpired(ctx)
|
||||
case match.FieldDemoParsed:
|
||||
return m.OldDemoParsed(ctx)
|
||||
case match.FieldEco:
|
||||
@@ -1045,13 +1001,6 @@ func (m *MatchMutation) SetField(name string, value ent.Value) error {
|
||||
}
|
||||
m.SetMaxRounds(v)
|
||||
return nil
|
||||
case match.FieldDemoExpired:
|
||||
v, ok := value.(bool)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetDemoExpired(v)
|
||||
return nil
|
||||
case match.FieldDemoParsed:
|
||||
v, ok := value.(bool)
|
||||
if !ok {
|
||||
@@ -1232,9 +1181,6 @@ func (m *MatchMutation) ResetField(name string) error {
|
||||
case match.FieldMaxRounds:
|
||||
m.ResetMaxRounds()
|
||||
return nil
|
||||
case match.FieldDemoExpired:
|
||||
m.ResetDemoExpired()
|
||||
return nil
|
||||
case match.FieldDemoParsed:
|
||||
m.ResetDemoParsed()
|
||||
return nil
|
||||
|
@@ -15,12 +15,8 @@ import (
|
||||
func init() {
|
||||
matchFields := schema.Match{}.Fields()
|
||||
_ = matchFields
|
||||
// matchDescDemoExpired is the schema descriptor for demo_expired field.
|
||||
matchDescDemoExpired := matchFields[10].Descriptor()
|
||||
// match.DefaultDemoExpired holds the default value on creation for the demo_expired field.
|
||||
match.DefaultDemoExpired = matchDescDemoExpired.Default.(bool)
|
||||
// matchDescDemoParsed is the schema descriptor for demo_parsed field.
|
||||
matchDescDemoParsed := matchFields[11].Descriptor()
|
||||
matchDescDemoParsed := matchFields[10].Descriptor()
|
||||
// match.DefaultDemoParsed holds the default value on creation for the demo_parsed field.
|
||||
match.DefaultDemoParsed = matchDescDemoParsed.Default.(bool)
|
||||
playerFields := schema.Player{}.Fields()
|
||||
|
@@ -24,7 +24,6 @@ func (Match) Fields() []ent.Field {
|
||||
field.Int("duration"),
|
||||
field.Int("match_result"),
|
||||
field.Int("max_rounds"),
|
||||
field.Bool("demo_expired").Default(false),
|
||||
field.Bool("demo_parsed").Default(false),
|
||||
field.JSON("eco", struct {
|
||||
Rounds []*struct {
|
||||
|
Reference in New Issue
Block a user