removed unneeded field, fixed not setting spent amount
This commit is contained in:
@@ -374,7 +374,7 @@ func (p *DemoParser) parseWorker() {
|
||||
|
||||
for _, eco := range ecoMap[tMatchPlayer.PlayerStats] {
|
||||
p.lock.Lock()
|
||||
err := p.db.RoundStats.Create().SetStat(nMatchPLayer).SetRound(uint(eco.Round)).SetBank(uint(eco.Bank)).SetEquipment(uint(eco.EqV)).Exec(context.Background())
|
||||
err := p.db.RoundStats.Create().SetStat(nMatchPLayer).SetRound(uint(eco.Round)).SetBank(uint(eco.Bank)).SetEquipment(uint(eco.EqV)).SetSpent(uint(eco.Spent)).Exec(context.Background())
|
||||
p.lock.Unlock()
|
||||
if err != nil {
|
||||
log.Errorf("[DP] Unable to create WeaponStat: %v", err)
|
||||
|
21
ent/match.go
21
ent/match.go
@@ -4,7 +4,6 @@ package ent
|
||||
|
||||
import (
|
||||
"csgowtfd/ent/match"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -37,14 +36,6 @@ type Match struct {
|
||||
MaxRounds int `json:"max_rounds,omitempty"`
|
||||
// DemoParsed holds the value of the "demo_parsed" field.
|
||||
DemoParsed bool `json:"demo_parsed,omitempty"`
|
||||
// Eco holds the value of the "eco" field.
|
||||
Eco struct {
|
||||
Rounds []*struct {
|
||||
Team int "json:\"team\""
|
||||
Bank int "json:\"bank\""
|
||||
Equipment int "json:\"equipment\""
|
||||
} "json:\"rounds\""
|
||||
} `json:"eco,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"`
|
||||
@@ -84,8 +75,6 @@ func (*Match) scanValues(columns []string) ([]interface{}, error) {
|
||||
values := make([]interface{}, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case match.FieldEco:
|
||||
values[i] = new([]byte)
|
||||
case match.FieldDemoParsed:
|
||||
values[i] = new(sql.NullBool)
|
||||
case match.FieldID, match.FieldScoreTeamA, match.FieldScoreTeamB, match.FieldDuration, match.FieldMatchResult, match.FieldMaxRounds:
|
||||
@@ -175,14 +164,6 @@ func (m *Match) assignValues(columns []string, values []interface{}) error {
|
||||
} else if value.Valid {
|
||||
m.DemoParsed = value.Bool
|
||||
}
|
||||
case match.FieldEco:
|
||||
if value, ok := values[i].(*[]byte); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field eco", values[i])
|
||||
} else if value != nil && len(*value) > 0 {
|
||||
if err := json.Unmarshal(*value, &m.Eco); err != nil {
|
||||
return fmt.Errorf("unmarshal field eco: %w", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -241,8 +222,6 @@ 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(", eco=")
|
||||
builder.WriteString(fmt.Sprintf("%v", m.Eco))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
@@ -27,8 +27,6 @@ const (
|
||||
FieldMaxRounds = "max_rounds"
|
||||
// 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.
|
||||
FieldEco = "eco"
|
||||
// EdgeStats holds the string denoting the stats edge name in mutations.
|
||||
EdgeStats = "stats"
|
||||
// EdgePlayers holds the string denoting the players edge name in mutations.
|
||||
@@ -62,7 +60,6 @@ var Columns = []string{
|
||||
FieldMatchResult,
|
||||
FieldMaxRounds,
|
||||
FieldDemoParsed,
|
||||
FieldEco,
|
||||
}
|
||||
|
||||
var (
|
||||
|
@@ -994,20 +994,6 @@ func DemoParsedNEQ(v bool) predicate.Match {
|
||||
})
|
||||
}
|
||||
|
||||
// EcoIsNil applies the IsNil predicate on the "eco" field.
|
||||
func EcoIsNil() predicate.Match {
|
||||
return predicate.Match(func(s *sql.Selector) {
|
||||
s.Where(sql.IsNull(s.C(FieldEco)))
|
||||
})
|
||||
}
|
||||
|
||||
// EcoNotNil applies the NotNil predicate on the "eco" field.
|
||||
func EcoNotNil() predicate.Match {
|
||||
return predicate.Match(func(s *sql.Selector) {
|
||||
s.Where(sql.NotNull(s.C(FieldEco)))
|
||||
})
|
||||
}
|
||||
|
||||
// HasStats applies the HasEdge predicate on the "stats" edge.
|
||||
func HasStats() predicate.Match {
|
||||
return predicate.Match(func(s *sql.Selector) {
|
||||
|
@@ -106,32 +106,6 @@ func (mc *MatchCreate) SetNillableDemoParsed(b *bool) *MatchCreate {
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetEco sets the "eco" field.
|
||||
func (mc *MatchCreate) SetEco(s struct {
|
||||
Rounds []*struct {
|
||||
Team int "json:\"team\""
|
||||
Bank int "json:\"bank\""
|
||||
Equipment int "json:\"equipment\""
|
||||
} "json:\"rounds\""
|
||||
}) *MatchCreate {
|
||||
mc.mutation.SetEco(s)
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetNillableEco sets the "eco" field if the given value is not nil.
|
||||
func (mc *MatchCreate) SetNillableEco(s *struct {
|
||||
Rounds []*struct {
|
||||
Team int "json:\"team\""
|
||||
Bank int "json:\"bank\""
|
||||
Equipment int "json:\"equipment\""
|
||||
} "json:\"rounds\""
|
||||
}) *MatchCreate {
|
||||
if s != nil {
|
||||
mc.SetEco(*s)
|
||||
}
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetID sets the "id" field.
|
||||
func (mc *MatchCreate) SetID(u uint64) *MatchCreate {
|
||||
mc.mutation.SetID(u)
|
||||
@@ -384,14 +358,6 @@ func (mc *MatchCreate) createSpec() (*Match, *sqlgraph.CreateSpec) {
|
||||
})
|
||||
_node.DemoParsed = value
|
||||
}
|
||||
if value, ok := mc.mutation.Eco(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeJSON,
|
||||
Value: value,
|
||||
Column: match.FieldEco,
|
||||
})
|
||||
_node.Eco = value
|
||||
}
|
||||
if nodes := mc.mutation.StatsIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
|
@@ -160,38 +160,6 @@ func (mu *MatchUpdate) SetNillableDemoParsed(b *bool) *MatchUpdate {
|
||||
return mu
|
||||
}
|
||||
|
||||
// SetEco sets the "eco" field.
|
||||
func (mu *MatchUpdate) SetEco(s struct {
|
||||
Rounds []*struct {
|
||||
Team int "json:\"team\""
|
||||
Bank int "json:\"bank\""
|
||||
Equipment int "json:\"equipment\""
|
||||
} "json:\"rounds\""
|
||||
}) *MatchUpdate {
|
||||
mu.mutation.SetEco(s)
|
||||
return mu
|
||||
}
|
||||
|
||||
// SetNillableEco sets the "eco" field if the given value is not nil.
|
||||
func (mu *MatchUpdate) SetNillableEco(s *struct {
|
||||
Rounds []*struct {
|
||||
Team int "json:\"team\""
|
||||
Bank int "json:\"bank\""
|
||||
Equipment int "json:\"equipment\""
|
||||
} "json:\"rounds\""
|
||||
}) *MatchUpdate {
|
||||
if s != nil {
|
||||
mu.SetEco(*s)
|
||||
}
|
||||
return mu
|
||||
}
|
||||
|
||||
// ClearEco clears the value of the "eco" field.
|
||||
func (mu *MatchUpdate) ClearEco() *MatchUpdate {
|
||||
mu.mutation.ClearEco()
|
||||
return mu
|
||||
}
|
||||
|
||||
// AddStatIDs adds the "stats" edge to the Stats entity by IDs.
|
||||
func (mu *MatchUpdate) AddStatIDs(ids ...int) *MatchUpdate {
|
||||
mu.mutation.AddStatIDs(ids...)
|
||||
@@ -458,19 +426,6 @@ func (mu *MatchUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
Column: match.FieldDemoParsed,
|
||||
})
|
||||
}
|
||||
if value, ok := mu.mutation.Eco(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeJSON,
|
||||
Value: value,
|
||||
Column: match.FieldEco,
|
||||
})
|
||||
}
|
||||
if mu.mutation.EcoCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeJSON,
|
||||
Column: match.FieldEco,
|
||||
})
|
||||
}
|
||||
if mu.mutation.StatsCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
@@ -729,38 +684,6 @@ func (muo *MatchUpdateOne) SetNillableDemoParsed(b *bool) *MatchUpdateOne {
|
||||
return muo
|
||||
}
|
||||
|
||||
// SetEco sets the "eco" field.
|
||||
func (muo *MatchUpdateOne) SetEco(s struct {
|
||||
Rounds []*struct {
|
||||
Team int "json:\"team\""
|
||||
Bank int "json:\"bank\""
|
||||
Equipment int "json:\"equipment\""
|
||||
} "json:\"rounds\""
|
||||
}) *MatchUpdateOne {
|
||||
muo.mutation.SetEco(s)
|
||||
return muo
|
||||
}
|
||||
|
||||
// SetNillableEco sets the "eco" field if the given value is not nil.
|
||||
func (muo *MatchUpdateOne) SetNillableEco(s *struct {
|
||||
Rounds []*struct {
|
||||
Team int "json:\"team\""
|
||||
Bank int "json:\"bank\""
|
||||
Equipment int "json:\"equipment\""
|
||||
} "json:\"rounds\""
|
||||
}) *MatchUpdateOne {
|
||||
if s != nil {
|
||||
muo.SetEco(*s)
|
||||
}
|
||||
return muo
|
||||
}
|
||||
|
||||
// ClearEco clears the value of the "eco" field.
|
||||
func (muo *MatchUpdateOne) ClearEco() *MatchUpdateOne {
|
||||
muo.mutation.ClearEco()
|
||||
return muo
|
||||
}
|
||||
|
||||
// AddStatIDs adds the "stats" edge to the Stats entity by IDs.
|
||||
func (muo *MatchUpdateOne) AddStatIDs(ids ...int) *MatchUpdateOne {
|
||||
muo.mutation.AddStatIDs(ids...)
|
||||
@@ -1051,19 +974,6 @@ func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error
|
||||
Column: match.FieldDemoParsed,
|
||||
})
|
||||
}
|
||||
if value, ok := muo.mutation.Eco(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeJSON,
|
||||
Value: value,
|
||||
Column: match.FieldEco,
|
||||
})
|
||||
}
|
||||
if muo.mutation.EcoCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeJSON,
|
||||
Column: match.FieldEco,
|
||||
})
|
||||
}
|
||||
if muo.mutation.StatsCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
|
@@ -21,7 +21,6 @@ var (
|
||||
{Name: "match_result", Type: field.TypeInt},
|
||||
{Name: "max_rounds", Type: field.TypeInt},
|
||||
{Name: "demo_parsed", Type: field.TypeBool, Default: false},
|
||||
{Name: "eco", Type: field.TypeJSON, Nullable: true},
|
||||
}
|
||||
// MatchesTable holds the schema information for the "matches" table.
|
||||
MatchesTable = &schema.Table{
|
||||
|
105
ent/mutation.go
105
ent/mutation.go
@@ -54,13 +54,6 @@ type MatchMutation struct {
|
||||
max_rounds *int
|
||||
addmax_rounds *int
|
||||
demo_parsed *bool
|
||||
eco *struct {
|
||||
Rounds []*struct {
|
||||
Team int "json:\"team\""
|
||||
Bank int "json:\"bank\""
|
||||
Equipment int "json:\"equipment\""
|
||||
} "json:\"rounds\""
|
||||
}
|
||||
clearedFields map[string]struct{}
|
||||
stats map[int]struct{}
|
||||
removedstats map[int]struct{}
|
||||
@@ -644,73 +637,6 @@ func (m *MatchMutation) ResetDemoParsed() {
|
||||
m.demo_parsed = nil
|
||||
}
|
||||
|
||||
// SetEco sets the "eco" field.
|
||||
func (m *MatchMutation) SetEco(s struct {
|
||||
Rounds []*struct {
|
||||
Team int "json:\"team\""
|
||||
Bank int "json:\"bank\""
|
||||
Equipment int "json:\"equipment\""
|
||||
} "json:\"rounds\""
|
||||
}) {
|
||||
m.eco = &s
|
||||
}
|
||||
|
||||
// Eco returns the value of the "eco" field in the mutation.
|
||||
func (m *MatchMutation) Eco() (r struct {
|
||||
Rounds []*struct {
|
||||
Team int "json:\"team\""
|
||||
Bank int "json:\"bank\""
|
||||
Equipment int "json:\"equipment\""
|
||||
} "json:\"rounds\""
|
||||
}, exists bool) {
|
||||
v := m.eco
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldEco returns the old "eco" 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) OldEco(ctx context.Context) (v struct {
|
||||
Rounds []*struct {
|
||||
Team int "json:\"team\""
|
||||
Bank int "json:\"bank\""
|
||||
Equipment int "json:\"equipment\""
|
||||
} "json:\"rounds\""
|
||||
}, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, fmt.Errorf("OldEco is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, fmt.Errorf("OldEco requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldEco: %w", err)
|
||||
}
|
||||
return oldValue.Eco, nil
|
||||
}
|
||||
|
||||
// ClearEco clears the value of the "eco" field.
|
||||
func (m *MatchMutation) ClearEco() {
|
||||
m.eco = nil
|
||||
m.clearedFields[match.FieldEco] = struct{}{}
|
||||
}
|
||||
|
||||
// EcoCleared returns if the "eco" field was cleared in this mutation.
|
||||
func (m *MatchMutation) EcoCleared() bool {
|
||||
_, ok := m.clearedFields[match.FieldEco]
|
||||
return ok
|
||||
}
|
||||
|
||||
// ResetEco resets all changes to the "eco" field.
|
||||
func (m *MatchMutation) ResetEco() {
|
||||
m.eco = nil
|
||||
delete(m.clearedFields, match.FieldEco)
|
||||
}
|
||||
|
||||
// AddStatIDs adds the "stats" edge to the Stats entity by ids.
|
||||
func (m *MatchMutation) AddStatIDs(ids ...int) {
|
||||
if m.stats == nil {
|
||||
@@ -838,7 +764,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, 11)
|
||||
fields := make([]string, 0, 10)
|
||||
if m.share_code != nil {
|
||||
fields = append(fields, match.FieldShareCode)
|
||||
}
|
||||
@@ -869,9 +795,6 @@ func (m *MatchMutation) Fields() []string {
|
||||
if m.demo_parsed != nil {
|
||||
fields = append(fields, match.FieldDemoParsed)
|
||||
}
|
||||
if m.eco != nil {
|
||||
fields = append(fields, match.FieldEco)
|
||||
}
|
||||
return fields
|
||||
}
|
||||
|
||||
@@ -900,8 +823,6 @@ func (m *MatchMutation) Field(name string) (ent.Value, bool) {
|
||||
return m.MaxRounds()
|
||||
case match.FieldDemoParsed:
|
||||
return m.DemoParsed()
|
||||
case match.FieldEco:
|
||||
return m.Eco()
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
@@ -931,8 +852,6 @@ 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.FieldEco:
|
||||
return m.OldEco(ctx)
|
||||
}
|
||||
return nil, fmt.Errorf("unknown Match field %s", name)
|
||||
}
|
||||
@@ -1012,19 +931,6 @@ func (m *MatchMutation) SetField(name string, value ent.Value) error {
|
||||
}
|
||||
m.SetDemoParsed(v)
|
||||
return nil
|
||||
case match.FieldEco:
|
||||
v, ok := value.(struct {
|
||||
Rounds []*struct {
|
||||
Team int "json:\"team\""
|
||||
Bank int "json:\"bank\""
|
||||
Equipment int "json:\"equipment\""
|
||||
} "json:\"rounds\""
|
||||
})
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetEco(v)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown Match field %s", name)
|
||||
}
|
||||
@@ -1124,9 +1030,6 @@ func (m *MatchMutation) ClearedFields() []string {
|
||||
if m.FieldCleared(match.FieldReplayURL) {
|
||||
fields = append(fields, match.FieldReplayURL)
|
||||
}
|
||||
if m.FieldCleared(match.FieldEco) {
|
||||
fields = append(fields, match.FieldEco)
|
||||
}
|
||||
return fields
|
||||
}
|
||||
|
||||
@@ -1147,9 +1050,6 @@ func (m *MatchMutation) ClearField(name string) error {
|
||||
case match.FieldReplayURL:
|
||||
m.ClearReplayURL()
|
||||
return nil
|
||||
case match.FieldEco:
|
||||
m.ClearEco()
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown Match nullable field %s", name)
|
||||
}
|
||||
@@ -1188,9 +1088,6 @@ func (m *MatchMutation) ResetField(name string) error {
|
||||
case match.FieldDemoParsed:
|
||||
m.ResetDemoParsed()
|
||||
return nil
|
||||
case match.FieldEco:
|
||||
m.ResetEco()
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown Match field %s", name)
|
||||
}
|
||||
|
@@ -25,13 +25,6 @@ func (Match) Fields() []ent.Field {
|
||||
field.Int("match_result"),
|
||||
field.Int("max_rounds"),
|
||||
field.Bool("demo_parsed").Default(false),
|
||||
field.JSON("eco", struct {
|
||||
Rounds []*struct {
|
||||
Team int `json:"team"`
|
||||
Bank int `json:"bank"`
|
||||
Equipment int `json:"equipment"`
|
||||
} `json:"rounds"`
|
||||
}{}).Optional(),
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user