fixed match win/loss/ties

This commit is contained in:
2021-10-08 17:15:06 +02:00
parent 1fda101a35
commit 1816c5a2b5
28 changed files with 363 additions and 654 deletions

View File

@@ -22,12 +22,6 @@ type PlayerCreate struct {
hooks []Hook
}
// SetSteamid sets the "steamid" field.
func (pc *PlayerCreate) SetSteamid(u uint64) *PlayerCreate {
pc.mutation.SetSteamid(u)
return pc
}
// SetName sets the "name" field.
func (pc *PlayerCreate) SetName(s string) *PlayerCreate {
pc.mutation.SetName(s)
@@ -168,6 +162,12 @@ func (pc *PlayerCreate) SetNillableAuthCode(s *string) *PlayerCreate {
return pc
}
// SetID sets the "id" field.
func (pc *PlayerCreate) SetID(u uint64) *PlayerCreate {
pc.mutation.SetID(u)
return pc
}
// AddStatIDs adds the "stats" edge to the Stats entity by IDs.
func (pc *PlayerCreate) AddStatIDs(ids ...int) *PlayerCreate {
pc.mutation.AddStatIDs(ids...)
@@ -184,14 +184,14 @@ func (pc *PlayerCreate) AddStats(s ...*Stats) *PlayerCreate {
}
// AddMatchIDs adds the "matches" edge to the Match entity by IDs.
func (pc *PlayerCreate) AddMatchIDs(ids ...int) *PlayerCreate {
func (pc *PlayerCreate) AddMatchIDs(ids ...uint64) *PlayerCreate {
pc.mutation.AddMatchIDs(ids...)
return pc
}
// AddMatches adds the "matches" edges to the Match entity.
func (pc *PlayerCreate) AddMatches(m ...*Match) *PlayerCreate {
ids := make([]int, len(m))
ids := make([]uint64, len(m))
for i := range m {
ids[i] = m[i].ID
}
@@ -281,9 +281,6 @@ func (pc *PlayerCreate) defaults() {
// check runs all checks and user-defined validators on the builder.
func (pc *PlayerCreate) check() error {
if _, ok := pc.mutation.Steamid(); !ok {
return &ValidationError{Name: "steamid", err: errors.New(`ent: missing required field "steamid"`)}
}
if _, ok := pc.mutation.Vac(); !ok {
return &ValidationError{Name: "vac", err: errors.New(`ent: missing required field "vac"`)}
}
@@ -301,8 +298,10 @@ func (pc *PlayerCreate) sqlSave(ctx context.Context) (*Player, error) {
}
return nil, err
}
id := _spec.ID.Value.(int64)
_node.ID = int(id)
if _spec.ID.Value != _node.ID {
id := _spec.ID.Value.(int64)
_node.ID = uint64(id)
}
return _node, nil
}
@@ -312,18 +311,14 @@ func (pc *PlayerCreate) createSpec() (*Player, *sqlgraph.CreateSpec) {
_spec = &sqlgraph.CreateSpec{
Table: player.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Type: field.TypeUint64,
Column: player.FieldID,
},
}
)
if value, ok := pc.mutation.Steamid(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeUint64,
Value: value,
Column: player.FieldSteamid,
})
_node.Steamid = value
if id, ok := pc.mutation.ID(); ok {
_node.ID = id
_spec.ID.Value = id
}
if value, ok := pc.mutation.Name(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
@@ -433,7 +428,7 @@ func (pc *PlayerCreate) createSpec() (*Player, *sqlgraph.CreateSpec) {
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Type: field.TypeUint64,
Column: match.FieldID,
},
},
@@ -488,9 +483,9 @@ func (pcb *PlayerCreateBulk) Save(ctx context.Context) ([]*Player, error) {
}
mutation.id = &nodes[i].ID
mutation.done = true
if specs[i].ID.Value != nil {
if specs[i].ID.Value != nil && nodes[i].ID == 0 {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
nodes[i].ID = uint64(id)
}
return nodes[i], nil
})