fixed match win/loss/ties
This commit is contained in:
@@ -217,6 +217,8 @@ func (d *DemoMatchLoader) steamEventHandler() {
|
||||
os.Remove(d.sentryFile)
|
||||
os.Remove(d.loginKey)
|
||||
log.Fatalf("[DL] Steam login wrong")
|
||||
case steamlang.EResult_InvalidLoginAuthCode:
|
||||
log.Fatalf("[DL] Steam auth code wrong")
|
||||
}
|
||||
case *steam.DisconnectedEvent:
|
||||
log.Warningf("Steam disconnected, trying to reconnect...")
|
||||
|
@@ -74,9 +74,9 @@ func (p *DemoParser) downloadReplay(demo *Demo) (io.Reader, error) {
|
||||
func (p *DemoParser) getDBPlayer(demo *Demo, demoPlayer *common.Player) (*ent.Stats, error) {
|
||||
p.lock.RLock()
|
||||
tMatchPlayer, err := p.db.Stats.Query().WithMatches(func(q *ent.MatchQuery) {
|
||||
q.Where(match.MatchID(demo.MatchId))
|
||||
q.Where(match.ID(demo.MatchId))
|
||||
}).WithPlayers(func(q *ent.PlayerQuery) {
|
||||
q.Where(player.Steamid(demoPlayer.SteamID64))
|
||||
q.Where(player.ID(demoPlayer.SteamID64))
|
||||
}).Only(context.Background())
|
||||
p.lock.RUnlock()
|
||||
if err != nil {
|
||||
@@ -93,7 +93,7 @@ func (p *DemoParser) getMatchPlayerBySteamID(stats []*ent.Stats, steamId uint64)
|
||||
log.Errorf("Unbale to get Stats from statList: %v", err)
|
||||
return nil
|
||||
}
|
||||
if tPLayer.Steamid == steamId {
|
||||
if tPLayer.ID == steamId {
|
||||
return tStats
|
||||
}
|
||||
}
|
||||
@@ -111,7 +111,7 @@ func (p *DemoParser) parseWorker() {
|
||||
}
|
||||
|
||||
p.lock.RLock()
|
||||
tMatch, err := p.db.Match.Query().Where(match.MatchID(demo.MatchId)).Only(context.Background())
|
||||
tMatch, err := p.db.Match.Query().Where(match.ID(demo.MatchId)).Only(context.Background())
|
||||
p.lock.RUnlock()
|
||||
if err != nil {
|
||||
log.Errorf("[DP] Unable to get match %d: %v", demo.MatchId, err)
|
||||
@@ -313,7 +313,7 @@ func (p *DemoParser) parseWorker() {
|
||||
err := tMatchPlayer.Update().SetExtended(tMatchPlayer.Extended).Exec(context.Background())
|
||||
p.lock.Unlock()
|
||||
if err != nil {
|
||||
log.Errorf("[DP] Unable to update player %d in database: %v", tMatchPlayer.Edges.Players.Steamid, err)
|
||||
log.Errorf("[DP] Unable to update player %d in database: %v", tMatchPlayer.Edges.Players.ID, err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
@@ -176,7 +176,7 @@ func (c *MatchClient) UpdateOne(m *Match) *MatchUpdateOne {
|
||||
}
|
||||
|
||||
// UpdateOneID returns an update builder for the given id.
|
||||
func (c *MatchClient) UpdateOneID(id int) *MatchUpdateOne {
|
||||
func (c *MatchClient) UpdateOneID(id uint64) *MatchUpdateOne {
|
||||
mutation := newMatchMutation(c.config, OpUpdateOne, withMatchID(id))
|
||||
return &MatchUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
@@ -193,7 +193,7 @@ func (c *MatchClient) DeleteOne(m *Match) *MatchDeleteOne {
|
||||
}
|
||||
|
||||
// DeleteOneID returns a delete builder for the given id.
|
||||
func (c *MatchClient) DeleteOneID(id int) *MatchDeleteOne {
|
||||
func (c *MatchClient) DeleteOneID(id uint64) *MatchDeleteOne {
|
||||
builder := c.Delete().Where(match.ID(id))
|
||||
builder.mutation.id = &id
|
||||
builder.mutation.op = OpDeleteOne
|
||||
@@ -208,12 +208,12 @@ func (c *MatchClient) Query() *MatchQuery {
|
||||
}
|
||||
|
||||
// Get returns a Match entity by its id.
|
||||
func (c *MatchClient) Get(ctx context.Context, id int) (*Match, error) {
|
||||
func (c *MatchClient) Get(ctx context.Context, id uint64) (*Match, error) {
|
||||
return c.Query().Where(match.ID(id)).Only(ctx)
|
||||
}
|
||||
|
||||
// GetX is like Get, but panics if an error occurs.
|
||||
func (c *MatchClient) GetX(ctx context.Context, id int) *Match {
|
||||
func (c *MatchClient) GetX(ctx context.Context, id uint64) *Match {
|
||||
obj, err := c.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -298,7 +298,7 @@ func (c *PlayerClient) UpdateOne(pl *Player) *PlayerUpdateOne {
|
||||
}
|
||||
|
||||
// UpdateOneID returns an update builder for the given id.
|
||||
func (c *PlayerClient) UpdateOneID(id int) *PlayerUpdateOne {
|
||||
func (c *PlayerClient) UpdateOneID(id uint64) *PlayerUpdateOne {
|
||||
mutation := newPlayerMutation(c.config, OpUpdateOne, withPlayerID(id))
|
||||
return &PlayerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
@@ -315,7 +315,7 @@ func (c *PlayerClient) DeleteOne(pl *Player) *PlayerDeleteOne {
|
||||
}
|
||||
|
||||
// DeleteOneID returns a delete builder for the given id.
|
||||
func (c *PlayerClient) DeleteOneID(id int) *PlayerDeleteOne {
|
||||
func (c *PlayerClient) DeleteOneID(id uint64) *PlayerDeleteOne {
|
||||
builder := c.Delete().Where(player.ID(id))
|
||||
builder.mutation.id = &id
|
||||
builder.mutation.op = OpDeleteOne
|
||||
@@ -330,12 +330,12 @@ func (c *PlayerClient) Query() *PlayerQuery {
|
||||
}
|
||||
|
||||
// Get returns a Player entity by its id.
|
||||
func (c *PlayerClient) Get(ctx context.Context, id int) (*Player, error) {
|
||||
func (c *PlayerClient) Get(ctx context.Context, id uint64) (*Player, error) {
|
||||
return c.Query().Where(player.ID(id)).Only(ctx)
|
||||
}
|
||||
|
||||
// GetX is like Get, but panics if an error occurs.
|
||||
func (c *PlayerClient) GetX(ctx context.Context, id int) *Player {
|
||||
func (c *PlayerClient) GetX(ctx context.Context, id uint64) *Player {
|
||||
obj, err := c.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
16
ent/match.go
16
ent/match.go
@@ -16,9 +16,7 @@ import (
|
||||
type Match struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int `json:"id,omitempty"`
|
||||
// MatchID holds the value of the "match_id" field.
|
||||
MatchID uint64 `json:"match_id,string"`
|
||||
ID uint64 `json:"match_id,string"`
|
||||
// ShareCode holds the value of the "share_code" field.
|
||||
ShareCode string `json:"share_code,omitempty"`
|
||||
// Map holds the value of the "map" field.
|
||||
@@ -92,7 +90,7 @@ func (*Match) scanValues(columns []string) ([]interface{}, error) {
|
||||
values[i] = new([]byte)
|
||||
case match.FieldDemoExpired, match.FieldDemoParsed:
|
||||
values[i] = new(sql.NullBool)
|
||||
case match.FieldID, match.FieldMatchID, match.FieldScoreTeamA, match.FieldScoreTeamB, match.FieldDuration, match.FieldMatchResult, match.FieldMaxRounds:
|
||||
case match.FieldID, match.FieldScoreTeamA, match.FieldScoreTeamB, match.FieldDuration, match.FieldMatchResult, match.FieldMaxRounds:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case match.FieldShareCode, match.FieldMap, match.FieldReplayURL:
|
||||
values[i] = new(sql.NullString)
|
||||
@@ -118,13 +116,7 @@ func (m *Match) assignValues(columns []string, values []interface{}) error {
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
m.ID = int(value.Int64)
|
||||
case match.FieldMatchID:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field match_id", values[i])
|
||||
} else if value.Valid {
|
||||
m.MatchID = uint64(value.Int64)
|
||||
}
|
||||
m.ID = uint64(value.Int64)
|
||||
case match.FieldShareCode:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field share_code", values[i])
|
||||
@@ -237,8 +229,6 @@ func (m *Match) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Match(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v", m.ID))
|
||||
builder.WriteString(", match_id=")
|
||||
builder.WriteString(fmt.Sprintf("%v", m.MatchID))
|
||||
builder.WriteString(", share_code=")
|
||||
builder.WriteString(m.ShareCode)
|
||||
builder.WriteString(", map=")
|
||||
|
@@ -7,8 +7,6 @@ const (
|
||||
Label = "match"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldMatchID holds the string denoting the match_id field in the database.
|
||||
FieldMatchID = "match_id"
|
||||
// FieldShareCode holds the string denoting the share_code field in the database.
|
||||
FieldShareCode = "share_code"
|
||||
// FieldMap holds the string denoting the map field in the database.
|
||||
@@ -56,7 +54,6 @@ const (
|
||||
// Columns holds all SQL columns for match fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldMatchID,
|
||||
FieldShareCode,
|
||||
FieldMap,
|
||||
FieldDate,
|
||||
|
@@ -11,28 +11,28 @@ import (
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
func ID(id int) predicate.Match {
|
||||
func ID(id uint64) predicate.Match {
|
||||
return predicate.Match(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id int) predicate.Match {
|
||||
func IDEQ(id uint64) predicate.Match {
|
||||
return predicate.Match(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id int) predicate.Match {
|
||||
func IDNEQ(id uint64) predicate.Match {
|
||||
return predicate.Match(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...int) predicate.Match {
|
||||
func IDIn(ids ...uint64) predicate.Match {
|
||||
return predicate.Match(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.
|
||||
@@ -49,7 +49,7 @@ func IDIn(ids ...int) predicate.Match {
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...int) predicate.Match {
|
||||
func IDNotIn(ids ...uint64) predicate.Match {
|
||||
return predicate.Match(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.
|
||||
@@ -66,40 +66,33 @@ func IDNotIn(ids ...int) predicate.Match {
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id int) predicate.Match {
|
||||
func IDGT(id uint64) predicate.Match {
|
||||
return predicate.Match(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id int) predicate.Match {
|
||||
func IDGTE(id uint64) predicate.Match {
|
||||
return predicate.Match(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id int) predicate.Match {
|
||||
func IDLT(id uint64) predicate.Match {
|
||||
return predicate.Match(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id int) predicate.Match {
|
||||
func IDLTE(id uint64) predicate.Match {
|
||||
return predicate.Match(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// MatchID applies equality check predicate on the "match_id" field. It's identical to MatchIDEQ.
|
||||
func MatchID(v uint64) predicate.Match {
|
||||
return predicate.Match(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldMatchID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// ShareCode applies equality check predicate on the "share_code" field. It's identical to ShareCodeEQ.
|
||||
func ShareCode(v string) predicate.Match {
|
||||
return predicate.Match(func(s *sql.Selector) {
|
||||
@@ -177,82 +170,6 @@ func DemoParsed(v bool) predicate.Match {
|
||||
})
|
||||
}
|
||||
|
||||
// MatchIDEQ applies the EQ predicate on the "match_id" field.
|
||||
func MatchIDEQ(v uint64) predicate.Match {
|
||||
return predicate.Match(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldMatchID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// MatchIDNEQ applies the NEQ predicate on the "match_id" field.
|
||||
func MatchIDNEQ(v uint64) predicate.Match {
|
||||
return predicate.Match(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldMatchID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// MatchIDIn applies the In predicate on the "match_id" field.
|
||||
func MatchIDIn(vs ...uint64) predicate.Match {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Match(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(FieldMatchID), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// MatchIDNotIn applies the NotIn predicate on the "match_id" field.
|
||||
func MatchIDNotIn(vs ...uint64) predicate.Match {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Match(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(FieldMatchID), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// MatchIDGT applies the GT predicate on the "match_id" field.
|
||||
func MatchIDGT(v uint64) predicate.Match {
|
||||
return predicate.Match(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldMatchID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// MatchIDGTE applies the GTE predicate on the "match_id" field.
|
||||
func MatchIDGTE(v uint64) predicate.Match {
|
||||
return predicate.Match(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldMatchID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// MatchIDLT applies the LT predicate on the "match_id" field.
|
||||
func MatchIDLT(v uint64) predicate.Match {
|
||||
return predicate.Match(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldMatchID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// MatchIDLTE applies the LTE predicate on the "match_id" field.
|
||||
func MatchIDLTE(v uint64) predicate.Match {
|
||||
return predicate.Match(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldMatchID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// ShareCodeEQ applies the EQ predicate on the "share_code" field.
|
||||
func ShareCodeEQ(v string) predicate.Match {
|
||||
return predicate.Match(func(s *sql.Selector) {
|
||||
|
@@ -22,12 +22,6 @@ type MatchCreate struct {
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetMatchID sets the "match_id" field.
|
||||
func (mc *MatchCreate) SetMatchID(u uint64) *MatchCreate {
|
||||
mc.mutation.SetMatchID(u)
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetShareCode sets the "share_code" field.
|
||||
func (mc *MatchCreate) SetShareCode(s string) *MatchCreate {
|
||||
mc.mutation.SetShareCode(s)
|
||||
@@ -152,6 +146,12 @@ func (mc *MatchCreate) SetNillableEco(s *struct {
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetID sets the "id" field.
|
||||
func (mc *MatchCreate) SetID(u uint64) *MatchCreate {
|
||||
mc.mutation.SetID(u)
|
||||
return mc
|
||||
}
|
||||
|
||||
// AddStatIDs adds the "stats" edge to the Stats entity by IDs.
|
||||
func (mc *MatchCreate) AddStatIDs(ids ...int) *MatchCreate {
|
||||
mc.mutation.AddStatIDs(ids...)
|
||||
@@ -168,14 +168,14 @@ func (mc *MatchCreate) AddStats(s ...*Stats) *MatchCreate {
|
||||
}
|
||||
|
||||
// AddPlayerIDs adds the "players" edge to the Player entity by IDs.
|
||||
func (mc *MatchCreate) AddPlayerIDs(ids ...int) *MatchCreate {
|
||||
func (mc *MatchCreate) AddPlayerIDs(ids ...uint64) *MatchCreate {
|
||||
mc.mutation.AddPlayerIDs(ids...)
|
||||
return mc
|
||||
}
|
||||
|
||||
// AddPlayers adds the "players" edges to the Player entity.
|
||||
func (mc *MatchCreate) AddPlayers(p ...*Player) *MatchCreate {
|
||||
ids := make([]int, len(p))
|
||||
ids := make([]uint64, len(p))
|
||||
for i := range p {
|
||||
ids[i] = p[i].ID
|
||||
}
|
||||
@@ -265,9 +265,6 @@ func (mc *MatchCreate) defaults() {
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (mc *MatchCreate) check() error {
|
||||
if _, ok := mc.mutation.MatchID(); !ok {
|
||||
return &ValidationError{Name: "match_id", err: errors.New(`ent: missing required field "match_id"`)}
|
||||
}
|
||||
if _, ok := mc.mutation.ShareCode(); !ok {
|
||||
return &ValidationError{Name: "share_code", err: errors.New(`ent: missing required field "share_code"`)}
|
||||
}
|
||||
@@ -306,8 +303,10 @@ func (mc *MatchCreate) sqlSave(ctx context.Context) (*Match, 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
|
||||
}
|
||||
|
||||
@@ -317,18 +316,14 @@ func (mc *MatchCreate) createSpec() (*Match, *sqlgraph.CreateSpec) {
|
||||
_spec = &sqlgraph.CreateSpec{
|
||||
Table: match.Table,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Type: field.TypeUint64,
|
||||
Column: match.FieldID,
|
||||
},
|
||||
}
|
||||
)
|
||||
if value, ok := mc.mutation.MatchID(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUint64,
|
||||
Value: value,
|
||||
Column: match.FieldMatchID,
|
||||
})
|
||||
_node.MatchID = value
|
||||
if id, ok := mc.mutation.ID(); ok {
|
||||
_node.ID = id
|
||||
_spec.ID.Value = id
|
||||
}
|
||||
if value, ok := mc.mutation.ShareCode(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
@@ -454,7 +449,7 @@ func (mc *MatchCreate) createSpec() (*Match, *sqlgraph.CreateSpec) {
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Type: field.TypeUint64,
|
||||
Column: player.FieldID,
|
||||
},
|
||||
},
|
||||
@@ -509,9 +504,9 @@ func (mcb *MatchCreateBulk) Save(ctx context.Context) ([]*Match, 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
|
||||
})
|
||||
|
@@ -72,7 +72,7 @@ func (md *MatchDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
Node: &sqlgraph.NodeSpec{
|
||||
Table: match.Table,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Type: field.TypeUint64,
|
||||
Column: match.FieldID,
|
||||
},
|
||||
},
|
||||
|
@@ -30,6 +30,7 @@ type MatchQuery struct {
|
||||
// eager-loading edges.
|
||||
withStats *StatsQuery
|
||||
withPlayers *PlayerQuery
|
||||
modifiers []func(s *sql.Selector)
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
@@ -134,8 +135,8 @@ func (mq *MatchQuery) FirstX(ctx context.Context) *Match {
|
||||
|
||||
// FirstID returns the first Match ID from the query.
|
||||
// Returns a *NotFoundError when no Match ID was found.
|
||||
func (mq *MatchQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
func (mq *MatchQuery) FirstID(ctx context.Context) (id uint64, err error) {
|
||||
var ids []uint64
|
||||
if ids, err = mq.Limit(1).IDs(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
@@ -147,7 +148,7 @@ func (mq *MatchQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (mq *MatchQuery) FirstIDX(ctx context.Context) int {
|
||||
func (mq *MatchQuery) FirstIDX(ctx context.Context) uint64 {
|
||||
id, err := mq.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
@@ -185,8 +186,8 @@ func (mq *MatchQuery) OnlyX(ctx context.Context) *Match {
|
||||
// OnlyID is like Only, but returns the only Match ID in the query.
|
||||
// Returns a *NotSingularError when exactly one Match ID is not found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (mq *MatchQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
func (mq *MatchQuery) OnlyID(ctx context.Context) (id uint64, err error) {
|
||||
var ids []uint64
|
||||
if ids, err = mq.Limit(2).IDs(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
@@ -202,7 +203,7 @@ func (mq *MatchQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (mq *MatchQuery) OnlyIDX(ctx context.Context) int {
|
||||
func (mq *MatchQuery) OnlyIDX(ctx context.Context) uint64 {
|
||||
id, err := mq.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -228,8 +229,8 @@ func (mq *MatchQuery) AllX(ctx context.Context) []*Match {
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of Match IDs.
|
||||
func (mq *MatchQuery) IDs(ctx context.Context) ([]int, error) {
|
||||
var ids []int
|
||||
func (mq *MatchQuery) IDs(ctx context.Context) ([]uint64, error) {
|
||||
var ids []uint64
|
||||
if err := mq.Select(match.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -237,7 +238,7 @@ func (mq *MatchQuery) IDs(ctx context.Context) ([]int, error) {
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (mq *MatchQuery) IDsX(ctx context.Context) []int {
|
||||
func (mq *MatchQuery) IDsX(ctx context.Context) []uint64 {
|
||||
ids, err := mq.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -327,12 +328,12 @@ func (mq *MatchQuery) WithPlayers(opts ...func(*PlayerQuery)) *MatchQuery {
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// MatchID uint64 `json:"match_id,string"`
|
||||
// ShareCode string `json:"share_code,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Match.Query().
|
||||
// GroupBy(match.FieldMatchID).
|
||||
// GroupBy(match.FieldShareCode).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
//
|
||||
@@ -354,11 +355,11 @@ func (mq *MatchQuery) GroupBy(field string, fields ...string) *MatchGroupBy {
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// MatchID uint64 `json:"match_id,string"`
|
||||
// ShareCode string `json:"share_code,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Match.Query().
|
||||
// Select(match.FieldMatchID).
|
||||
// Select(match.FieldShareCode).
|
||||
// Scan(ctx, &v)
|
||||
//
|
||||
func (mq *MatchQuery) Select(fields ...string) *MatchSelect {
|
||||
@@ -404,6 +405,9 @@ func (mq *MatchQuery) sqlAll(ctx context.Context) ([]*Match, error) {
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
if len(mq.modifiers) > 0 {
|
||||
_spec.Modifiers = mq.modifiers
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, mq.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -413,7 +417,7 @@ func (mq *MatchQuery) sqlAll(ctx context.Context) ([]*Match, error) {
|
||||
|
||||
if query := mq.withStats; query != nil {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[int]*Match)
|
||||
nodeids := make(map[uint64]*Match)
|
||||
for i := range nodes {
|
||||
fks = append(fks, nodes[i].ID)
|
||||
nodeids[nodes[i].ID] = nodes[i]
|
||||
@@ -442,15 +446,15 @@ func (mq *MatchQuery) sqlAll(ctx context.Context) ([]*Match, error) {
|
||||
|
||||
if query := mq.withPlayers; query != nil {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
ids := make(map[int]*Match, len(nodes))
|
||||
ids := make(map[uint64]*Match, len(nodes))
|
||||
for _, node := range nodes {
|
||||
ids[node.ID] = node
|
||||
fks = append(fks, node.ID)
|
||||
node.Edges.Players = []*Player{}
|
||||
}
|
||||
var (
|
||||
edgeids []int
|
||||
edges = make(map[int][]*Match)
|
||||
edgeids []uint64
|
||||
edges = make(map[uint64][]*Match)
|
||||
)
|
||||
_spec := &sqlgraph.EdgeQuerySpec{
|
||||
Edge: &sqlgraph.EdgeSpec{
|
||||
@@ -473,8 +477,8 @@ func (mq *MatchQuery) sqlAll(ctx context.Context) ([]*Match, error) {
|
||||
if !ok || ein == nil {
|
||||
return fmt.Errorf("unexpected id value for edge-in")
|
||||
}
|
||||
outValue := int(eout.Int64)
|
||||
inValue := int(ein.Int64)
|
||||
outValue := uint64(eout.Int64)
|
||||
inValue := uint64(ein.Int64)
|
||||
node, ok := ids[outValue]
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected node id in edges: %v", outValue)
|
||||
@@ -510,6 +514,9 @@ func (mq *MatchQuery) sqlAll(ctx context.Context) ([]*Match, error) {
|
||||
|
||||
func (mq *MatchQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := mq.querySpec()
|
||||
if len(mq.modifiers) > 0 {
|
||||
_spec.Modifiers = mq.modifiers
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, mq.driver, _spec)
|
||||
}
|
||||
|
||||
@@ -527,7 +534,7 @@ func (mq *MatchQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
Table: match.Table,
|
||||
Columns: match.Columns,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Type: field.TypeUint64,
|
||||
Column: match.FieldID,
|
||||
},
|
||||
},
|
||||
@@ -581,6 +588,9 @@ func (mq *MatchQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
selector = mq.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
for _, m := range mq.modifiers {
|
||||
m(selector)
|
||||
}
|
||||
for _, p := range mq.predicates {
|
||||
p(selector)
|
||||
}
|
||||
@@ -598,6 +608,12 @@ func (mq *MatchQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
return selector
|
||||
}
|
||||
|
||||
// Modify adds a query modifier for attaching custom logic to queries.
|
||||
func (mq *MatchQuery) Modify(modifiers ...func(s *sql.Selector)) *MatchSelect {
|
||||
mq.modifiers = append(mq.modifiers, modifiers...)
|
||||
return mq.Select()
|
||||
}
|
||||
|
||||
// MatchGroupBy is the group-by builder for Match entities.
|
||||
type MatchGroupBy struct {
|
||||
config
|
||||
@@ -1087,3 +1103,9 @@ func (ms *MatchSelect) sqlScan(ctx context.Context, v interface{}) error {
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
// Modify adds a query modifier for attaching custom logic to queries.
|
||||
func (ms *MatchSelect) Modify(modifiers ...func(s *sql.Selector)) *MatchSelect {
|
||||
ms.modifiers = append(ms.modifiers, modifiers...)
|
||||
return ms
|
||||
}
|
||||
|
@@ -222,14 +222,14 @@ func (mu *MatchUpdate) AddStats(s ...*Stats) *MatchUpdate {
|
||||
}
|
||||
|
||||
// AddPlayerIDs adds the "players" edge to the Player entity by IDs.
|
||||
func (mu *MatchUpdate) AddPlayerIDs(ids ...int) *MatchUpdate {
|
||||
func (mu *MatchUpdate) AddPlayerIDs(ids ...uint64) *MatchUpdate {
|
||||
mu.mutation.AddPlayerIDs(ids...)
|
||||
return mu
|
||||
}
|
||||
|
||||
// AddPlayers adds the "players" edges to the Player entity.
|
||||
func (mu *MatchUpdate) AddPlayers(p ...*Player) *MatchUpdate {
|
||||
ids := make([]int, len(p))
|
||||
ids := make([]uint64, len(p))
|
||||
for i := range p {
|
||||
ids[i] = p[i].ID
|
||||
}
|
||||
@@ -269,14 +269,14 @@ func (mu *MatchUpdate) ClearPlayers() *MatchUpdate {
|
||||
}
|
||||
|
||||
// RemovePlayerIDs removes the "players" edge to Player entities by IDs.
|
||||
func (mu *MatchUpdate) RemovePlayerIDs(ids ...int) *MatchUpdate {
|
||||
func (mu *MatchUpdate) RemovePlayerIDs(ids ...uint64) *MatchUpdate {
|
||||
mu.mutation.RemovePlayerIDs(ids...)
|
||||
return mu
|
||||
}
|
||||
|
||||
// RemovePlayers removes "players" edges to Player entities.
|
||||
func (mu *MatchUpdate) RemovePlayers(p ...*Player) *MatchUpdate {
|
||||
ids := make([]int, len(p))
|
||||
ids := make([]uint64, len(p))
|
||||
for i := range p {
|
||||
ids[i] = p[i].ID
|
||||
}
|
||||
@@ -343,7 +343,7 @@ func (mu *MatchUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
Table: match.Table,
|
||||
Columns: match.Columns,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Type: field.TypeUint64,
|
||||
Column: match.FieldID,
|
||||
},
|
||||
},
|
||||
@@ -555,7 +555,7 @@ func (mu *MatchUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Type: field.TypeUint64,
|
||||
Column: player.FieldID,
|
||||
},
|
||||
},
|
||||
@@ -571,7 +571,7 @@ func (mu *MatchUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Type: field.TypeUint64,
|
||||
Column: player.FieldID,
|
||||
},
|
||||
},
|
||||
@@ -590,7 +590,7 @@ func (mu *MatchUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Type: field.TypeUint64,
|
||||
Column: player.FieldID,
|
||||
},
|
||||
},
|
||||
@@ -812,14 +812,14 @@ func (muo *MatchUpdateOne) AddStats(s ...*Stats) *MatchUpdateOne {
|
||||
}
|
||||
|
||||
// AddPlayerIDs adds the "players" edge to the Player entity by IDs.
|
||||
func (muo *MatchUpdateOne) AddPlayerIDs(ids ...int) *MatchUpdateOne {
|
||||
func (muo *MatchUpdateOne) AddPlayerIDs(ids ...uint64) *MatchUpdateOne {
|
||||
muo.mutation.AddPlayerIDs(ids...)
|
||||
return muo
|
||||
}
|
||||
|
||||
// AddPlayers adds the "players" edges to the Player entity.
|
||||
func (muo *MatchUpdateOne) AddPlayers(p ...*Player) *MatchUpdateOne {
|
||||
ids := make([]int, len(p))
|
||||
ids := make([]uint64, len(p))
|
||||
for i := range p {
|
||||
ids[i] = p[i].ID
|
||||
}
|
||||
@@ -859,14 +859,14 @@ func (muo *MatchUpdateOne) ClearPlayers() *MatchUpdateOne {
|
||||
}
|
||||
|
||||
// RemovePlayerIDs removes the "players" edge to Player entities by IDs.
|
||||
func (muo *MatchUpdateOne) RemovePlayerIDs(ids ...int) *MatchUpdateOne {
|
||||
func (muo *MatchUpdateOne) RemovePlayerIDs(ids ...uint64) *MatchUpdateOne {
|
||||
muo.mutation.RemovePlayerIDs(ids...)
|
||||
return muo
|
||||
}
|
||||
|
||||
// RemovePlayers removes "players" edges to Player entities.
|
||||
func (muo *MatchUpdateOne) RemovePlayers(p ...*Player) *MatchUpdateOne {
|
||||
ids := make([]int, len(p))
|
||||
ids := make([]uint64, len(p))
|
||||
for i := range p {
|
||||
ids[i] = p[i].ID
|
||||
}
|
||||
@@ -940,7 +940,7 @@ func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error
|
||||
Table: match.Table,
|
||||
Columns: match.Columns,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Type: field.TypeUint64,
|
||||
Column: match.FieldID,
|
||||
},
|
||||
},
|
||||
@@ -1169,7 +1169,7 @@ func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Type: field.TypeUint64,
|
||||
Column: player.FieldID,
|
||||
},
|
||||
},
|
||||
@@ -1185,7 +1185,7 @@ func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Type: field.TypeUint64,
|
||||
Column: player.FieldID,
|
||||
},
|
||||
},
|
||||
@@ -1204,7 +1204,7 @@ func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Type: field.TypeUint64,
|
||||
Column: player.FieldID,
|
||||
},
|
||||
},
|
||||
|
@@ -10,8 +10,7 @@ import (
|
||||
var (
|
||||
// MatchesColumns holds the columns for the "matches" table.
|
||||
MatchesColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "match_id", Type: field.TypeUint64, Unique: true},
|
||||
{Name: "id", Type: field.TypeUint64, Increment: true},
|
||||
{Name: "share_code", Type: field.TypeString},
|
||||
{Name: "map", Type: field.TypeString, Nullable: true},
|
||||
{Name: "date", Type: field.TypeTime},
|
||||
@@ -33,8 +32,7 @@ var (
|
||||
}
|
||||
// PlayersColumns holds the columns for the "players" table.
|
||||
PlayersColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "steamid", Type: field.TypeUint64, Unique: true},
|
||||
{Name: "id", Type: field.TypeUint64, Increment: true},
|
||||
{Name: "name", Type: field.TypeString, Nullable: true},
|
||||
{Name: "avatar_url", Type: field.TypeString, Nullable: true},
|
||||
{Name: "vanity_url", Type: field.TypeString, Nullable: true},
|
||||
@@ -63,8 +61,8 @@ var (
|
||||
{Name: "mvp", Type: field.TypeInt},
|
||||
{Name: "score", Type: field.TypeInt},
|
||||
{Name: "extended", Type: field.TypeJSON, Nullable: true},
|
||||
{Name: "match_stats", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "player_stats", Type: field.TypeInt, Nullable: true},
|
||||
{Name: "match_stats", Type: field.TypeUint64, Nullable: true},
|
||||
{Name: "player_stats", Type: field.TypeUint64, Nullable: true},
|
||||
}
|
||||
// StatsTable holds the schema information for the "stats" table.
|
||||
StatsTable = &schema.Table{
|
||||
@@ -88,8 +86,8 @@ var (
|
||||
}
|
||||
// PlayerMatchesColumns holds the columns for the "player_matches" table.
|
||||
PlayerMatchesColumns = []*schema.Column{
|
||||
{Name: "player_id", Type: field.TypeInt},
|
||||
{Name: "match_id", Type: field.TypeInt},
|
||||
{Name: "player_id", Type: field.TypeUint64},
|
||||
{Name: "match_id", Type: field.TypeUint64},
|
||||
}
|
||||
// PlayerMatchesTable holds the schema information for the "player_matches" table.
|
||||
PlayerMatchesTable = &schema.Table{
|
||||
|
250
ent/mutation.go
250
ent/mutation.go
@@ -34,9 +34,7 @@ type MatchMutation struct {
|
||||
config
|
||||
op Op
|
||||
typ string
|
||||
id *int
|
||||
match_id *uint64
|
||||
addmatch_id *uint64
|
||||
id *uint64
|
||||
share_code *string
|
||||
_map *string
|
||||
date *time.Time
|
||||
@@ -64,8 +62,8 @@ type MatchMutation struct {
|
||||
stats map[int]struct{}
|
||||
removedstats map[int]struct{}
|
||||
clearedstats bool
|
||||
players map[int]struct{}
|
||||
removedplayers map[int]struct{}
|
||||
players map[uint64]struct{}
|
||||
removedplayers map[uint64]struct{}
|
||||
clearedplayers bool
|
||||
done bool
|
||||
oldValue func(context.Context) (*Match, error)
|
||||
@@ -92,7 +90,7 @@ func newMatchMutation(c config, op Op, opts ...matchOption) *MatchMutation {
|
||||
}
|
||||
|
||||
// withMatchID sets the ID field of the mutation.
|
||||
func withMatchID(id int) matchOption {
|
||||
func withMatchID(id uint64) matchOption {
|
||||
return func(m *MatchMutation) {
|
||||
var (
|
||||
err error
|
||||
@@ -142,71 +140,21 @@ func (m MatchMutation) Tx() (*Tx, error) {
|
||||
return tx, nil
|
||||
}
|
||||
|
||||
// SetID sets the value of the id field. Note that this
|
||||
// operation is only accepted on creation of Match entities.
|
||||
func (m *MatchMutation) SetID(id uint64) {
|
||||
m.id = &id
|
||||
}
|
||||
|
||||
// ID returns the ID value in the mutation. Note that the ID is only available
|
||||
// if it was provided to the builder or after it was returned from the database.
|
||||
func (m *MatchMutation) ID() (id int, exists bool) {
|
||||
func (m *MatchMutation) ID() (id uint64, exists bool) {
|
||||
if m.id == nil {
|
||||
return
|
||||
}
|
||||
return *m.id, true
|
||||
}
|
||||
|
||||
// SetMatchID sets the "match_id" field.
|
||||
func (m *MatchMutation) SetMatchID(u uint64) {
|
||||
m.match_id = &u
|
||||
m.addmatch_id = nil
|
||||
}
|
||||
|
||||
// MatchID returns the value of the "match_id" field in the mutation.
|
||||
func (m *MatchMutation) MatchID() (r uint64, exists bool) {
|
||||
v := m.match_id
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldMatchID returns the old "match_id" 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) OldMatchID(ctx context.Context) (v uint64, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, fmt.Errorf("OldMatchID is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, fmt.Errorf("OldMatchID requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldMatchID: %w", err)
|
||||
}
|
||||
return oldValue.MatchID, nil
|
||||
}
|
||||
|
||||
// AddMatchID adds u to the "match_id" field.
|
||||
func (m *MatchMutation) AddMatchID(u uint64) {
|
||||
if m.addmatch_id != nil {
|
||||
*m.addmatch_id += u
|
||||
} else {
|
||||
m.addmatch_id = &u
|
||||
}
|
||||
}
|
||||
|
||||
// AddedMatchID returns the value that was added to the "match_id" field in this mutation.
|
||||
func (m *MatchMutation) AddedMatchID() (r uint64, exists bool) {
|
||||
v := m.addmatch_id
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// ResetMatchID resets all changes to the "match_id" field.
|
||||
func (m *MatchMutation) ResetMatchID() {
|
||||
m.match_id = nil
|
||||
m.addmatch_id = nil
|
||||
}
|
||||
|
||||
// SetShareCode sets the "share_code" field.
|
||||
func (m *MatchMutation) SetShareCode(s string) {
|
||||
m.share_code = &s
|
||||
@@ -851,9 +799,9 @@ func (m *MatchMutation) ResetStats() {
|
||||
}
|
||||
|
||||
// AddPlayerIDs adds the "players" edge to the Player entity by ids.
|
||||
func (m *MatchMutation) AddPlayerIDs(ids ...int) {
|
||||
func (m *MatchMutation) AddPlayerIDs(ids ...uint64) {
|
||||
if m.players == nil {
|
||||
m.players = make(map[int]struct{})
|
||||
m.players = make(map[uint64]struct{})
|
||||
}
|
||||
for i := range ids {
|
||||
m.players[ids[i]] = struct{}{}
|
||||
@@ -871,9 +819,9 @@ func (m *MatchMutation) PlayersCleared() bool {
|
||||
}
|
||||
|
||||
// RemovePlayerIDs removes the "players" edge to the Player entity by IDs.
|
||||
func (m *MatchMutation) RemovePlayerIDs(ids ...int) {
|
||||
func (m *MatchMutation) RemovePlayerIDs(ids ...uint64) {
|
||||
if m.removedplayers == nil {
|
||||
m.removedplayers = make(map[int]struct{})
|
||||
m.removedplayers = make(map[uint64]struct{})
|
||||
}
|
||||
for i := range ids {
|
||||
delete(m.players, ids[i])
|
||||
@@ -882,7 +830,7 @@ func (m *MatchMutation) RemovePlayerIDs(ids ...int) {
|
||||
}
|
||||
|
||||
// RemovedPlayers returns the removed IDs of the "players" edge to the Player entity.
|
||||
func (m *MatchMutation) RemovedPlayersIDs() (ids []int) {
|
||||
func (m *MatchMutation) RemovedPlayersIDs() (ids []uint64) {
|
||||
for id := range m.removedplayers {
|
||||
ids = append(ids, id)
|
||||
}
|
||||
@@ -890,7 +838,7 @@ func (m *MatchMutation) RemovedPlayersIDs() (ids []int) {
|
||||
}
|
||||
|
||||
// PlayersIDs returns the "players" edge IDs in the mutation.
|
||||
func (m *MatchMutation) PlayersIDs() (ids []int) {
|
||||
func (m *MatchMutation) PlayersIDs() (ids []uint64) {
|
||||
for id := range m.players {
|
||||
ids = append(ids, id)
|
||||
}
|
||||
@@ -923,10 +871,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, 13)
|
||||
if m.match_id != nil {
|
||||
fields = append(fields, match.FieldMatchID)
|
||||
}
|
||||
fields := make([]string, 0, 12)
|
||||
if m.share_code != nil {
|
||||
fields = append(fields, match.FieldShareCode)
|
||||
}
|
||||
@@ -971,8 +916,6 @@ func (m *MatchMutation) Fields() []string {
|
||||
// schema.
|
||||
func (m *MatchMutation) Field(name string) (ent.Value, bool) {
|
||||
switch name {
|
||||
case match.FieldMatchID:
|
||||
return m.MatchID()
|
||||
case match.FieldShareCode:
|
||||
return m.ShareCode()
|
||||
case match.FieldMap:
|
||||
@@ -1006,8 +949,6 @@ func (m *MatchMutation) Field(name string) (ent.Value, bool) {
|
||||
// database failed.
|
||||
func (m *MatchMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
||||
switch name {
|
||||
case match.FieldMatchID:
|
||||
return m.OldMatchID(ctx)
|
||||
case match.FieldShareCode:
|
||||
return m.OldShareCode(ctx)
|
||||
case match.FieldMap:
|
||||
@@ -1041,13 +982,6 @@ func (m *MatchMutation) OldField(ctx context.Context, name string) (ent.Value, e
|
||||
// type.
|
||||
func (m *MatchMutation) SetField(name string, value ent.Value) error {
|
||||
switch name {
|
||||
case match.FieldMatchID:
|
||||
v, ok := value.(uint64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetMatchID(v)
|
||||
return nil
|
||||
case match.FieldShareCode:
|
||||
v, ok := value.(string)
|
||||
if !ok {
|
||||
@@ -1146,9 +1080,6 @@ func (m *MatchMutation) SetField(name string, value ent.Value) error {
|
||||
// this mutation.
|
||||
func (m *MatchMutation) AddedFields() []string {
|
||||
var fields []string
|
||||
if m.addmatch_id != nil {
|
||||
fields = append(fields, match.FieldMatchID)
|
||||
}
|
||||
if m.addscore_team_a != nil {
|
||||
fields = append(fields, match.FieldScoreTeamA)
|
||||
}
|
||||
@@ -1172,8 +1103,6 @@ func (m *MatchMutation) AddedFields() []string {
|
||||
// was not set, or was not defined in the schema.
|
||||
func (m *MatchMutation) AddedField(name string) (ent.Value, bool) {
|
||||
switch name {
|
||||
case match.FieldMatchID:
|
||||
return m.AddedMatchID()
|
||||
case match.FieldScoreTeamA:
|
||||
return m.AddedScoreTeamA()
|
||||
case match.FieldScoreTeamB:
|
||||
@@ -1193,13 +1122,6 @@ func (m *MatchMutation) AddedField(name string) (ent.Value, bool) {
|
||||
// type.
|
||||
func (m *MatchMutation) AddField(name string, value ent.Value) error {
|
||||
switch name {
|
||||
case match.FieldMatchID:
|
||||
v, ok := value.(uint64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.AddMatchID(v)
|
||||
return nil
|
||||
case match.FieldScoreTeamA:
|
||||
v, ok := value.(int)
|
||||
if !ok {
|
||||
@@ -1283,9 +1205,6 @@ func (m *MatchMutation) ClearField(name string) error {
|
||||
// It returns an error if the field is not defined in the schema.
|
||||
func (m *MatchMutation) ResetField(name string) error {
|
||||
switch name {
|
||||
case match.FieldMatchID:
|
||||
m.ResetMatchID()
|
||||
return nil
|
||||
case match.FieldShareCode:
|
||||
m.ResetShareCode()
|
||||
return nil
|
||||
@@ -1441,9 +1360,7 @@ type PlayerMutation struct {
|
||||
config
|
||||
op Op
|
||||
typ string
|
||||
id *int
|
||||
steamid *uint64
|
||||
addsteamid *uint64
|
||||
id *uint64
|
||||
name *string
|
||||
avatar_url *string
|
||||
vanity_url *string
|
||||
@@ -1459,8 +1376,8 @@ type PlayerMutation struct {
|
||||
stats map[int]struct{}
|
||||
removedstats map[int]struct{}
|
||||
clearedstats bool
|
||||
matches map[int]struct{}
|
||||
removedmatches map[int]struct{}
|
||||
matches map[uint64]struct{}
|
||||
removedmatches map[uint64]struct{}
|
||||
clearedmatches bool
|
||||
done bool
|
||||
oldValue func(context.Context) (*Player, error)
|
||||
@@ -1487,7 +1404,7 @@ func newPlayerMutation(c config, op Op, opts ...playerOption) *PlayerMutation {
|
||||
}
|
||||
|
||||
// withPlayerID sets the ID field of the mutation.
|
||||
func withPlayerID(id int) playerOption {
|
||||
func withPlayerID(id uint64) playerOption {
|
||||
return func(m *PlayerMutation) {
|
||||
var (
|
||||
err error
|
||||
@@ -1537,71 +1454,21 @@ func (m PlayerMutation) Tx() (*Tx, error) {
|
||||
return tx, nil
|
||||
}
|
||||
|
||||
// SetID sets the value of the id field. Note that this
|
||||
// operation is only accepted on creation of Player entities.
|
||||
func (m *PlayerMutation) SetID(id uint64) {
|
||||
m.id = &id
|
||||
}
|
||||
|
||||
// ID returns the ID value in the mutation. Note that the ID is only available
|
||||
// if it was provided to the builder or after it was returned from the database.
|
||||
func (m *PlayerMutation) ID() (id int, exists bool) {
|
||||
func (m *PlayerMutation) ID() (id uint64, exists bool) {
|
||||
if m.id == nil {
|
||||
return
|
||||
}
|
||||
return *m.id, true
|
||||
}
|
||||
|
||||
// SetSteamid sets the "steamid" field.
|
||||
func (m *PlayerMutation) SetSteamid(u uint64) {
|
||||
m.steamid = &u
|
||||
m.addsteamid = nil
|
||||
}
|
||||
|
||||
// Steamid returns the value of the "steamid" field in the mutation.
|
||||
func (m *PlayerMutation) Steamid() (r uint64, exists bool) {
|
||||
v := m.steamid
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldSteamid returns the old "steamid" 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) OldSteamid(ctx context.Context) (v uint64, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, fmt.Errorf("OldSteamid is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, fmt.Errorf("OldSteamid requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldSteamid: %w", err)
|
||||
}
|
||||
return oldValue.Steamid, nil
|
||||
}
|
||||
|
||||
// AddSteamid adds u to the "steamid" field.
|
||||
func (m *PlayerMutation) AddSteamid(u uint64) {
|
||||
if m.addsteamid != nil {
|
||||
*m.addsteamid += u
|
||||
} else {
|
||||
m.addsteamid = &u
|
||||
}
|
||||
}
|
||||
|
||||
// AddedSteamid returns the value that was added to the "steamid" field in this mutation.
|
||||
func (m *PlayerMutation) AddedSteamid() (r uint64, exists bool) {
|
||||
v := m.addsteamid
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// ResetSteamid resets all changes to the "steamid" field.
|
||||
func (m *PlayerMutation) ResetSteamid() {
|
||||
m.steamid = nil
|
||||
m.addsteamid = nil
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (m *PlayerMutation) SetName(s string) {
|
||||
m.name = &s
|
||||
@@ -2142,9 +2009,9 @@ func (m *PlayerMutation) ResetStats() {
|
||||
}
|
||||
|
||||
// AddMatchIDs adds the "matches" edge to the Match entity by ids.
|
||||
func (m *PlayerMutation) AddMatchIDs(ids ...int) {
|
||||
func (m *PlayerMutation) AddMatchIDs(ids ...uint64) {
|
||||
if m.matches == nil {
|
||||
m.matches = make(map[int]struct{})
|
||||
m.matches = make(map[uint64]struct{})
|
||||
}
|
||||
for i := range ids {
|
||||
m.matches[ids[i]] = struct{}{}
|
||||
@@ -2162,9 +2029,9 @@ func (m *PlayerMutation) MatchesCleared() bool {
|
||||
}
|
||||
|
||||
// RemoveMatchIDs removes the "matches" edge to the Match entity by IDs.
|
||||
func (m *PlayerMutation) RemoveMatchIDs(ids ...int) {
|
||||
func (m *PlayerMutation) RemoveMatchIDs(ids ...uint64) {
|
||||
if m.removedmatches == nil {
|
||||
m.removedmatches = make(map[int]struct{})
|
||||
m.removedmatches = make(map[uint64]struct{})
|
||||
}
|
||||
for i := range ids {
|
||||
delete(m.matches, ids[i])
|
||||
@@ -2173,7 +2040,7 @@ func (m *PlayerMutation) RemoveMatchIDs(ids ...int) {
|
||||
}
|
||||
|
||||
// RemovedMatches returns the removed IDs of the "matches" edge to the Match entity.
|
||||
func (m *PlayerMutation) RemovedMatchesIDs() (ids []int) {
|
||||
func (m *PlayerMutation) RemovedMatchesIDs() (ids []uint64) {
|
||||
for id := range m.removedmatches {
|
||||
ids = append(ids, id)
|
||||
}
|
||||
@@ -2181,7 +2048,7 @@ func (m *PlayerMutation) RemovedMatchesIDs() (ids []int) {
|
||||
}
|
||||
|
||||
// MatchesIDs returns the "matches" edge IDs in the mutation.
|
||||
func (m *PlayerMutation) MatchesIDs() (ids []int) {
|
||||
func (m *PlayerMutation) MatchesIDs() (ids []uint64) {
|
||||
for id := range m.matches {
|
||||
ids = append(ids, id)
|
||||
}
|
||||
@@ -2214,10 +2081,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)
|
||||
if m.steamid != nil {
|
||||
fields = append(fields, player.FieldSteamid)
|
||||
}
|
||||
fields := make([]string, 0, 10)
|
||||
if m.name != nil {
|
||||
fields = append(fields, player.FieldName)
|
||||
}
|
||||
@@ -2256,8 +2120,6 @@ func (m *PlayerMutation) Fields() []string {
|
||||
// schema.
|
||||
func (m *PlayerMutation) Field(name string) (ent.Value, bool) {
|
||||
switch name {
|
||||
case player.FieldSteamid:
|
||||
return m.Steamid()
|
||||
case player.FieldName:
|
||||
return m.Name()
|
||||
case player.FieldAvatarURL:
|
||||
@@ -2287,8 +2149,6 @@ func (m *PlayerMutation) Field(name string) (ent.Value, bool) {
|
||||
// database failed.
|
||||
func (m *PlayerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
||||
switch name {
|
||||
case player.FieldSteamid:
|
||||
return m.OldSteamid(ctx)
|
||||
case player.FieldName:
|
||||
return m.OldName(ctx)
|
||||
case player.FieldAvatarURL:
|
||||
@@ -2318,13 +2178,6 @@ func (m *PlayerMutation) OldField(ctx context.Context, name string) (ent.Value,
|
||||
// type.
|
||||
func (m *PlayerMutation) SetField(name string, value ent.Value) error {
|
||||
switch name {
|
||||
case player.FieldSteamid:
|
||||
v, ok := value.(uint64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetSteamid(v)
|
||||
return nil
|
||||
case player.FieldName:
|
||||
v, ok := value.(string)
|
||||
if !ok {
|
||||
@@ -2403,9 +2256,6 @@ func (m *PlayerMutation) SetField(name string, value ent.Value) error {
|
||||
// this mutation.
|
||||
func (m *PlayerMutation) AddedFields() []string {
|
||||
var fields []string
|
||||
if m.addsteamid != nil {
|
||||
fields = append(fields, player.FieldSteamid)
|
||||
}
|
||||
if m.addvac_count != nil {
|
||||
fields = append(fields, player.FieldVacCount)
|
||||
}
|
||||
@@ -2417,8 +2267,6 @@ func (m *PlayerMutation) AddedFields() []string {
|
||||
// was not set, or was not defined in the schema.
|
||||
func (m *PlayerMutation) AddedField(name string) (ent.Value, bool) {
|
||||
switch name {
|
||||
case player.FieldSteamid:
|
||||
return m.AddedSteamid()
|
||||
case player.FieldVacCount:
|
||||
return m.AddedVacCount()
|
||||
}
|
||||
@@ -2430,13 +2278,6 @@ func (m *PlayerMutation) AddedField(name string) (ent.Value, bool) {
|
||||
// type.
|
||||
func (m *PlayerMutation) AddField(name string, value ent.Value) error {
|
||||
switch name {
|
||||
case player.FieldSteamid:
|
||||
v, ok := value.(uint64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.AddSteamid(v)
|
||||
return nil
|
||||
case player.FieldVacCount:
|
||||
v, ok := value.(int)
|
||||
if !ok {
|
||||
@@ -2522,9 +2363,6 @@ func (m *PlayerMutation) ClearField(name string) error {
|
||||
// It returns an error if the field is not defined in the schema.
|
||||
func (m *PlayerMutation) ResetField(name string) error {
|
||||
switch name {
|
||||
case player.FieldSteamid:
|
||||
m.ResetSteamid()
|
||||
return nil
|
||||
case player.FieldName:
|
||||
m.ResetName()
|
||||
return nil
|
||||
@@ -2738,9 +2576,9 @@ type StatsMutation struct {
|
||||
} "json:\"flash,omitempty\""
|
||||
}
|
||||
clearedFields map[string]struct{}
|
||||
matches *int
|
||||
matches *uint64
|
||||
clearedmatches bool
|
||||
players *int
|
||||
players *uint64
|
||||
clearedplayers bool
|
||||
done bool
|
||||
oldValue func(context.Context) (*Stats, error)
|
||||
@@ -3409,7 +3247,7 @@ func (m *StatsMutation) ResetExtended() {
|
||||
}
|
||||
|
||||
// SetMatchesID sets the "matches" edge to the Match entity by id.
|
||||
func (m *StatsMutation) SetMatchesID(id int) {
|
||||
func (m *StatsMutation) SetMatchesID(id uint64) {
|
||||
m.matches = &id
|
||||
}
|
||||
|
||||
@@ -3424,7 +3262,7 @@ func (m *StatsMutation) MatchesCleared() bool {
|
||||
}
|
||||
|
||||
// MatchesID returns the "matches" edge ID in the mutation.
|
||||
func (m *StatsMutation) MatchesID() (id int, exists bool) {
|
||||
func (m *StatsMutation) MatchesID() (id uint64, exists bool) {
|
||||
if m.matches != nil {
|
||||
return *m.matches, true
|
||||
}
|
||||
@@ -3434,7 +3272,7 @@ func (m *StatsMutation) MatchesID() (id int, exists bool) {
|
||||
// MatchesIDs returns the "matches" edge IDs in the mutation.
|
||||
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
|
||||
// MatchesID instead. It exists only for internal usage by the builders.
|
||||
func (m *StatsMutation) MatchesIDs() (ids []int) {
|
||||
func (m *StatsMutation) MatchesIDs() (ids []uint64) {
|
||||
if id := m.matches; id != nil {
|
||||
ids = append(ids, *id)
|
||||
}
|
||||
@@ -3448,7 +3286,7 @@ func (m *StatsMutation) ResetMatches() {
|
||||
}
|
||||
|
||||
// SetPlayersID sets the "players" edge to the Player entity by id.
|
||||
func (m *StatsMutation) SetPlayersID(id int) {
|
||||
func (m *StatsMutation) SetPlayersID(id uint64) {
|
||||
m.players = &id
|
||||
}
|
||||
|
||||
@@ -3463,7 +3301,7 @@ func (m *StatsMutation) PlayersCleared() bool {
|
||||
}
|
||||
|
||||
// PlayersID returns the "players" edge ID in the mutation.
|
||||
func (m *StatsMutation) PlayersID() (id int, exists bool) {
|
||||
func (m *StatsMutation) PlayersID() (id uint64, exists bool) {
|
||||
if m.players != nil {
|
||||
return *m.players, true
|
||||
}
|
||||
@@ -3473,7 +3311,7 @@ func (m *StatsMutation) PlayersID() (id int, exists bool) {
|
||||
// PlayersIDs returns the "players" edge IDs in the mutation.
|
||||
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
|
||||
// PlayersID instead. It exists only for internal usage by the builders.
|
||||
func (m *StatsMutation) PlayersIDs() (ids []int) {
|
||||
func (m *StatsMutation) PlayersIDs() (ids []uint64) {
|
||||
if id := m.players; id != nil {
|
||||
ids = append(ids, *id)
|
||||
}
|
||||
|
@@ -15,9 +15,7 @@ import (
|
||||
type Player struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int `json:"id,omitempty"`
|
||||
// Steamid holds the value of the "steamid" field.
|
||||
Steamid uint64 `json:",string"`
|
||||
ID uint64 `json:"steamid,string"`
|
||||
// Name holds the value of the "name" field.
|
||||
Name string `json:"name,omitempty"`
|
||||
// AvatarURL holds the value of the "avatar_url" field.
|
||||
@@ -79,7 +77,7 @@ func (*Player) scanValues(columns []string) ([]interface{}, error) {
|
||||
switch columns[i] {
|
||||
case player.FieldVac:
|
||||
values[i] = new(sql.NullBool)
|
||||
case player.FieldID, player.FieldSteamid, player.FieldVacCount:
|
||||
case player.FieldID, player.FieldVacCount:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case player.FieldName, player.FieldAvatarURL, player.FieldVanityURL, player.FieldVanityURLReal, player.FieldAuthCode:
|
||||
values[i] = new(sql.NullString)
|
||||
@@ -105,13 +103,7 @@ func (pl *Player) assignValues(columns []string, values []interface{}) error {
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
pl.ID = int(value.Int64)
|
||||
case player.FieldSteamid:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field steamid", values[i])
|
||||
} else if value.Valid {
|
||||
pl.Steamid = uint64(value.Int64)
|
||||
}
|
||||
pl.ID = uint64(value.Int64)
|
||||
case player.FieldName:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field name", values[i])
|
||||
@@ -210,8 +202,6 @@ func (pl *Player) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Player(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v", pl.ID))
|
||||
builder.WriteString(", steamid=")
|
||||
builder.WriteString(fmt.Sprintf("%v", pl.Steamid))
|
||||
builder.WriteString(", name=")
|
||||
builder.WriteString(pl.Name)
|
||||
builder.WriteString(", avatar_url=")
|
||||
|
@@ -11,8 +11,6 @@ const (
|
||||
Label = "player"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldSteamid holds the string denoting the steamid field in the database.
|
||||
FieldSteamid = "steamid"
|
||||
// FieldName holds the string denoting the name field in the database.
|
||||
FieldName = "name"
|
||||
// FieldAvatarURL holds the string denoting the avatar_url field in the database.
|
||||
@@ -56,7 +54,6 @@ const (
|
||||
// Columns holds all SQL columns for player fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldSteamid,
|
||||
FieldName,
|
||||
FieldAvatarURL,
|
||||
FieldVanityURL,
|
||||
|
@@ -11,28 +11,28 @@ import (
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
func ID(id int) predicate.Player {
|
||||
func ID(id uint64) predicate.Player {
|
||||
return predicate.Player(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id int) predicate.Player {
|
||||
func IDEQ(id uint64) predicate.Player {
|
||||
return predicate.Player(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id int) predicate.Player {
|
||||
func IDNEQ(id uint64) predicate.Player {
|
||||
return predicate.Player(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...int) predicate.Player {
|
||||
func IDIn(ids ...uint64) predicate.Player {
|
||||
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.
|
||||
@@ -49,7 +49,7 @@ func IDIn(ids ...int) predicate.Player {
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...int) predicate.Player {
|
||||
func IDNotIn(ids ...uint64) predicate.Player {
|
||||
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.
|
||||
@@ -66,40 +66,33 @@ func IDNotIn(ids ...int) predicate.Player {
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id int) predicate.Player {
|
||||
func IDGT(id uint64) predicate.Player {
|
||||
return predicate.Player(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id int) predicate.Player {
|
||||
func IDGTE(id uint64) predicate.Player {
|
||||
return predicate.Player(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id int) predicate.Player {
|
||||
func IDLT(id uint64) predicate.Player {
|
||||
return predicate.Player(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id int) predicate.Player {
|
||||
func IDLTE(id uint64) predicate.Player {
|
||||
return predicate.Player(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// Steamid applies equality check predicate on the "steamid" field. It's identical to SteamidEQ.
|
||||
func Steamid(v uint64) predicate.Player {
|
||||
return predicate.Player(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldSteamid), v))
|
||||
})
|
||||
}
|
||||
|
||||
// Name applies equality check predicate on the "name" field. It's identical to NameEQ.
|
||||
func Name(v string) predicate.Player {
|
||||
return predicate.Player(func(s *sql.Selector) {
|
||||
@@ -170,82 +163,6 @@ func AuthCode(v string) predicate.Player {
|
||||
})
|
||||
}
|
||||
|
||||
// SteamidEQ applies the EQ predicate on the "steamid" field.
|
||||
func SteamidEQ(v uint64) predicate.Player {
|
||||
return predicate.Player(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldSteamid), v))
|
||||
})
|
||||
}
|
||||
|
||||
// SteamidNEQ applies the NEQ predicate on the "steamid" field.
|
||||
func SteamidNEQ(v uint64) predicate.Player {
|
||||
return predicate.Player(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldSteamid), v))
|
||||
})
|
||||
}
|
||||
|
||||
// SteamidIn applies the In predicate on the "steamid" field.
|
||||
func SteamidIn(vs ...uint64) 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(FieldSteamid), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// SteamidNotIn applies the NotIn predicate on the "steamid" field.
|
||||
func SteamidNotIn(vs ...uint64) 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(FieldSteamid), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// SteamidGT applies the GT predicate on the "steamid" field.
|
||||
func SteamidGT(v uint64) predicate.Player {
|
||||
return predicate.Player(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldSteamid), v))
|
||||
})
|
||||
}
|
||||
|
||||
// SteamidGTE applies the GTE predicate on the "steamid" field.
|
||||
func SteamidGTE(v uint64) predicate.Player {
|
||||
return predicate.Player(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldSteamid), v))
|
||||
})
|
||||
}
|
||||
|
||||
// SteamidLT applies the LT predicate on the "steamid" field.
|
||||
func SteamidLT(v uint64) predicate.Player {
|
||||
return predicate.Player(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldSteamid), v))
|
||||
})
|
||||
}
|
||||
|
||||
// SteamidLTE applies the LTE predicate on the "steamid" field.
|
||||
func SteamidLTE(v uint64) predicate.Player {
|
||||
return predicate.Player(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldSteamid), v))
|
||||
})
|
||||
}
|
||||
|
||||
// NameEQ applies the EQ predicate on the "name" field.
|
||||
func NameEQ(v string) predicate.Player {
|
||||
return predicate.Player(func(s *sql.Selector) {
|
||||
|
@@ -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
|
||||
})
|
||||
|
@@ -72,7 +72,7 @@ func (pd *PlayerDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
Node: &sqlgraph.NodeSpec{
|
||||
Table: player.Table,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Type: field.TypeUint64,
|
||||
Column: player.FieldID,
|
||||
},
|
||||
},
|
||||
|
@@ -30,6 +30,7 @@ type PlayerQuery struct {
|
||||
// eager-loading edges.
|
||||
withStats *StatsQuery
|
||||
withMatches *MatchQuery
|
||||
modifiers []func(s *sql.Selector)
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
@@ -134,8 +135,8 @@ func (pq *PlayerQuery) FirstX(ctx context.Context) *Player {
|
||||
|
||||
// FirstID returns the first Player ID from the query.
|
||||
// Returns a *NotFoundError when no Player ID was found.
|
||||
func (pq *PlayerQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
func (pq *PlayerQuery) FirstID(ctx context.Context) (id uint64, err error) {
|
||||
var ids []uint64
|
||||
if ids, err = pq.Limit(1).IDs(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
@@ -147,7 +148,7 @@ func (pq *PlayerQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (pq *PlayerQuery) FirstIDX(ctx context.Context) int {
|
||||
func (pq *PlayerQuery) FirstIDX(ctx context.Context) uint64 {
|
||||
id, err := pq.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
@@ -185,8 +186,8 @@ func (pq *PlayerQuery) OnlyX(ctx context.Context) *Player {
|
||||
// OnlyID is like Only, but returns the only Player ID in the query.
|
||||
// Returns a *NotSingularError when exactly one Player ID is not found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (pq *PlayerQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
func (pq *PlayerQuery) OnlyID(ctx context.Context) (id uint64, err error) {
|
||||
var ids []uint64
|
||||
if ids, err = pq.Limit(2).IDs(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
@@ -202,7 +203,7 @@ func (pq *PlayerQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (pq *PlayerQuery) OnlyIDX(ctx context.Context) int {
|
||||
func (pq *PlayerQuery) OnlyIDX(ctx context.Context) uint64 {
|
||||
id, err := pq.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -228,8 +229,8 @@ func (pq *PlayerQuery) AllX(ctx context.Context) []*Player {
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of Player IDs.
|
||||
func (pq *PlayerQuery) IDs(ctx context.Context) ([]int, error) {
|
||||
var ids []int
|
||||
func (pq *PlayerQuery) IDs(ctx context.Context) ([]uint64, error) {
|
||||
var ids []uint64
|
||||
if err := pq.Select(player.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -237,7 +238,7 @@ func (pq *PlayerQuery) IDs(ctx context.Context) ([]int, error) {
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (pq *PlayerQuery) IDsX(ctx context.Context) []int {
|
||||
func (pq *PlayerQuery) IDsX(ctx context.Context) []uint64 {
|
||||
ids, err := pq.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -327,12 +328,12 @@ func (pq *PlayerQuery) WithMatches(opts ...func(*MatchQuery)) *PlayerQuery {
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// Steamid uint64 `json:",string"`
|
||||
// Name string `json:"name,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Player.Query().
|
||||
// GroupBy(player.FieldSteamid).
|
||||
// GroupBy(player.FieldName).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
//
|
||||
@@ -354,11 +355,11 @@ func (pq *PlayerQuery) GroupBy(field string, fields ...string) *PlayerGroupBy {
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// Steamid uint64 `json:",string"`
|
||||
// Name string `json:"name,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Player.Query().
|
||||
// Select(player.FieldSteamid).
|
||||
// Select(player.FieldName).
|
||||
// Scan(ctx, &v)
|
||||
//
|
||||
func (pq *PlayerQuery) Select(fields ...string) *PlayerSelect {
|
||||
@@ -404,6 +405,9 @@ func (pq *PlayerQuery) sqlAll(ctx context.Context) ([]*Player, error) {
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
if len(pq.modifiers) > 0 {
|
||||
_spec.Modifiers = pq.modifiers
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, pq.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -413,7 +417,7 @@ func (pq *PlayerQuery) sqlAll(ctx context.Context) ([]*Player, error) {
|
||||
|
||||
if query := pq.withStats; query != nil {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[int]*Player)
|
||||
nodeids := make(map[uint64]*Player)
|
||||
for i := range nodes {
|
||||
fks = append(fks, nodes[i].ID)
|
||||
nodeids[nodes[i].ID] = nodes[i]
|
||||
@@ -442,15 +446,15 @@ func (pq *PlayerQuery) sqlAll(ctx context.Context) ([]*Player, error) {
|
||||
|
||||
if query := pq.withMatches; query != nil {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
ids := make(map[int]*Player, len(nodes))
|
||||
ids := make(map[uint64]*Player, len(nodes))
|
||||
for _, node := range nodes {
|
||||
ids[node.ID] = node
|
||||
fks = append(fks, node.ID)
|
||||
node.Edges.Matches = []*Match{}
|
||||
}
|
||||
var (
|
||||
edgeids []int
|
||||
edges = make(map[int][]*Player)
|
||||
edgeids []uint64
|
||||
edges = make(map[uint64][]*Player)
|
||||
)
|
||||
_spec := &sqlgraph.EdgeQuerySpec{
|
||||
Edge: &sqlgraph.EdgeSpec{
|
||||
@@ -473,8 +477,8 @@ func (pq *PlayerQuery) sqlAll(ctx context.Context) ([]*Player, error) {
|
||||
if !ok || ein == nil {
|
||||
return fmt.Errorf("unexpected id value for edge-in")
|
||||
}
|
||||
outValue := int(eout.Int64)
|
||||
inValue := int(ein.Int64)
|
||||
outValue := uint64(eout.Int64)
|
||||
inValue := uint64(ein.Int64)
|
||||
node, ok := ids[outValue]
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected node id in edges: %v", outValue)
|
||||
@@ -510,6 +514,9 @@ func (pq *PlayerQuery) sqlAll(ctx context.Context) ([]*Player, error) {
|
||||
|
||||
func (pq *PlayerQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := pq.querySpec()
|
||||
if len(pq.modifiers) > 0 {
|
||||
_spec.Modifiers = pq.modifiers
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, pq.driver, _spec)
|
||||
}
|
||||
|
||||
@@ -527,7 +534,7 @@ func (pq *PlayerQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
Table: player.Table,
|
||||
Columns: player.Columns,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Type: field.TypeUint64,
|
||||
Column: player.FieldID,
|
||||
},
|
||||
},
|
||||
@@ -581,6 +588,9 @@ func (pq *PlayerQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
selector = pq.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
for _, m := range pq.modifiers {
|
||||
m(selector)
|
||||
}
|
||||
for _, p := range pq.predicates {
|
||||
p(selector)
|
||||
}
|
||||
@@ -598,6 +608,12 @@ func (pq *PlayerQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
return selector
|
||||
}
|
||||
|
||||
// Modify adds a query modifier for attaching custom logic to queries.
|
||||
func (pq *PlayerQuery) Modify(modifiers ...func(s *sql.Selector)) *PlayerSelect {
|
||||
pq.modifiers = append(pq.modifiers, modifiers...)
|
||||
return pq.Select()
|
||||
}
|
||||
|
||||
// PlayerGroupBy is the group-by builder for Player entities.
|
||||
type PlayerGroupBy struct {
|
||||
config
|
||||
@@ -1087,3 +1103,9 @@ func (ps *PlayerSelect) sqlScan(ctx context.Context, v interface{}) error {
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
// Modify adds a query modifier for attaching custom logic to queries.
|
||||
func (ps *PlayerSelect) Modify(modifiers ...func(s *sql.Selector)) *PlayerSelect {
|
||||
ps.modifiers = append(ps.modifiers, modifiers...)
|
||||
return ps
|
||||
}
|
||||
|
@@ -240,14 +240,14 @@ func (pu *PlayerUpdate) AddStats(s ...*Stats) *PlayerUpdate {
|
||||
}
|
||||
|
||||
// AddMatchIDs adds the "matches" edge to the Match entity by IDs.
|
||||
func (pu *PlayerUpdate) AddMatchIDs(ids ...int) *PlayerUpdate {
|
||||
func (pu *PlayerUpdate) AddMatchIDs(ids ...uint64) *PlayerUpdate {
|
||||
pu.mutation.AddMatchIDs(ids...)
|
||||
return pu
|
||||
}
|
||||
|
||||
// AddMatches adds the "matches" edges to the Match entity.
|
||||
func (pu *PlayerUpdate) AddMatches(m ...*Match) *PlayerUpdate {
|
||||
ids := make([]int, len(m))
|
||||
ids := make([]uint64, len(m))
|
||||
for i := range m {
|
||||
ids[i] = m[i].ID
|
||||
}
|
||||
@@ -287,14 +287,14 @@ func (pu *PlayerUpdate) ClearMatches() *PlayerUpdate {
|
||||
}
|
||||
|
||||
// RemoveMatchIDs removes the "matches" edge to Match entities by IDs.
|
||||
func (pu *PlayerUpdate) RemoveMatchIDs(ids ...int) *PlayerUpdate {
|
||||
func (pu *PlayerUpdate) RemoveMatchIDs(ids ...uint64) *PlayerUpdate {
|
||||
pu.mutation.RemoveMatchIDs(ids...)
|
||||
return pu
|
||||
}
|
||||
|
||||
// RemoveMatches removes "matches" edges to Match entities.
|
||||
func (pu *PlayerUpdate) RemoveMatches(m ...*Match) *PlayerUpdate {
|
||||
ids := make([]int, len(m))
|
||||
ids := make([]uint64, len(m))
|
||||
for i := range m {
|
||||
ids[i] = m[i].ID
|
||||
}
|
||||
@@ -361,7 +361,7 @@ func (pu *PlayerUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
Table: player.Table,
|
||||
Columns: player.Columns,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Type: field.TypeUint64,
|
||||
Column: player.FieldID,
|
||||
},
|
||||
},
|
||||
@@ -561,7 +561,7 @@ func (pu *PlayerUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Type: field.TypeUint64,
|
||||
Column: match.FieldID,
|
||||
},
|
||||
},
|
||||
@@ -577,7 +577,7 @@ func (pu *PlayerUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Type: field.TypeUint64,
|
||||
Column: match.FieldID,
|
||||
},
|
||||
},
|
||||
@@ -596,7 +596,7 @@ func (pu *PlayerUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Type: field.TypeUint64,
|
||||
Column: match.FieldID,
|
||||
},
|
||||
},
|
||||
@@ -836,14 +836,14 @@ func (puo *PlayerUpdateOne) AddStats(s ...*Stats) *PlayerUpdateOne {
|
||||
}
|
||||
|
||||
// AddMatchIDs adds the "matches" edge to the Match entity by IDs.
|
||||
func (puo *PlayerUpdateOne) AddMatchIDs(ids ...int) *PlayerUpdateOne {
|
||||
func (puo *PlayerUpdateOne) AddMatchIDs(ids ...uint64) *PlayerUpdateOne {
|
||||
puo.mutation.AddMatchIDs(ids...)
|
||||
return puo
|
||||
}
|
||||
|
||||
// AddMatches adds the "matches" edges to the Match entity.
|
||||
func (puo *PlayerUpdateOne) AddMatches(m ...*Match) *PlayerUpdateOne {
|
||||
ids := make([]int, len(m))
|
||||
ids := make([]uint64, len(m))
|
||||
for i := range m {
|
||||
ids[i] = m[i].ID
|
||||
}
|
||||
@@ -883,14 +883,14 @@ func (puo *PlayerUpdateOne) ClearMatches() *PlayerUpdateOne {
|
||||
}
|
||||
|
||||
// RemoveMatchIDs removes the "matches" edge to Match entities by IDs.
|
||||
func (puo *PlayerUpdateOne) RemoveMatchIDs(ids ...int) *PlayerUpdateOne {
|
||||
func (puo *PlayerUpdateOne) RemoveMatchIDs(ids ...uint64) *PlayerUpdateOne {
|
||||
puo.mutation.RemoveMatchIDs(ids...)
|
||||
return puo
|
||||
}
|
||||
|
||||
// RemoveMatches removes "matches" edges to Match entities.
|
||||
func (puo *PlayerUpdateOne) RemoveMatches(m ...*Match) *PlayerUpdateOne {
|
||||
ids := make([]int, len(m))
|
||||
ids := make([]uint64, len(m))
|
||||
for i := range m {
|
||||
ids[i] = m[i].ID
|
||||
}
|
||||
@@ -964,7 +964,7 @@ func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err err
|
||||
Table: player.Table,
|
||||
Columns: player.Columns,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Type: field.TypeUint64,
|
||||
Column: player.FieldID,
|
||||
},
|
||||
},
|
||||
@@ -1181,7 +1181,7 @@ func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err err
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Type: field.TypeUint64,
|
||||
Column: match.FieldID,
|
||||
},
|
||||
},
|
||||
@@ -1197,7 +1197,7 @@ func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err err
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Type: field.TypeUint64,
|
||||
Column: match.FieldID,
|
||||
},
|
||||
},
|
||||
@@ -1216,7 +1216,7 @@ func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err err
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Type: field.TypeUint64,
|
||||
Column: match.FieldID,
|
||||
},
|
||||
},
|
||||
|
@@ -14,7 +14,7 @@ type Match struct {
|
||||
// Fields of the Match.
|
||||
func (Match) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Uint64("match_id").Unique().Immutable().StructTag(`json:"match_id,string"`),
|
||||
field.Uint64("id").Unique().Immutable().StructTag(`json:"match_id,string"`),
|
||||
field.String("share_code"),
|
||||
field.String("map").Optional(),
|
||||
field.Time("date"),
|
||||
|
@@ -15,7 +15,7 @@ type Player struct {
|
||||
// Fields of the Player.
|
||||
func (Player) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Uint64("steamid").Unique().Immutable().StructTag(`json:",string"`),
|
||||
field.Uint64("id").Unique().Immutable().StructTag(`json:"steamid,string"`),
|
||||
field.String("name").Optional(),
|
||||
field.String("avatar_url").Optional(),
|
||||
field.String("vanity_url").Optional(),
|
||||
|
12
ent/stats.go
12
ent/stats.go
@@ -84,8 +84,8 @@ type Stats struct {
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
// The values are being populated by the StatsQuery when eager-loading is set.
|
||||
Edges StatsEdges `json:"edges"`
|
||||
match_stats *int
|
||||
player_stats *int
|
||||
match_stats *uint64
|
||||
player_stats *uint64
|
||||
}
|
||||
|
||||
// StatsEdges holds the relations/edges for other nodes in the graph.
|
||||
@@ -215,15 +215,15 @@ func (s *Stats) assignValues(columns []string, values []interface{}) error {
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for edge-field match_stats", value)
|
||||
} else if value.Valid {
|
||||
s.match_stats = new(int)
|
||||
*s.match_stats = int(value.Int64)
|
||||
s.match_stats = new(uint64)
|
||||
*s.match_stats = uint64(value.Int64)
|
||||
}
|
||||
case stats.ForeignKeys[1]:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for edge-field player_stats", value)
|
||||
} else if value.Valid {
|
||||
s.player_stats = new(int)
|
||||
*s.player_stats = int(value.Int64)
|
||||
s.player_stats = new(uint64)
|
||||
*s.player_stats = uint64(value.Int64)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -172,13 +172,13 @@ func (sc *StatsCreate) SetNillableExtended(skkgaaaallllg *struct {
|
||||
}
|
||||
|
||||
// SetMatchesID sets the "matches" edge to the Match entity by ID.
|
||||
func (sc *StatsCreate) SetMatchesID(id int) *StatsCreate {
|
||||
func (sc *StatsCreate) SetMatchesID(id uint64) *StatsCreate {
|
||||
sc.mutation.SetMatchesID(id)
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetNillableMatchesID sets the "matches" edge to the Match entity by ID if the given value is not nil.
|
||||
func (sc *StatsCreate) SetNillableMatchesID(id *int) *StatsCreate {
|
||||
func (sc *StatsCreate) SetNillableMatchesID(id *uint64) *StatsCreate {
|
||||
if id != nil {
|
||||
sc = sc.SetMatchesID(*id)
|
||||
}
|
||||
@@ -191,13 +191,13 @@ func (sc *StatsCreate) SetMatches(m *Match) *StatsCreate {
|
||||
}
|
||||
|
||||
// SetPlayersID sets the "players" edge to the Player entity by ID.
|
||||
func (sc *StatsCreate) SetPlayersID(id int) *StatsCreate {
|
||||
func (sc *StatsCreate) SetPlayersID(id uint64) *StatsCreate {
|
||||
sc.mutation.SetPlayersID(id)
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetNillablePlayersID sets the "players" edge to the Player entity by ID if the given value is not nil.
|
||||
func (sc *StatsCreate) SetNillablePlayersID(id *int) *StatsCreate {
|
||||
func (sc *StatsCreate) SetNillablePlayersID(id *uint64) *StatsCreate {
|
||||
if id != nil {
|
||||
sc = sc.SetPlayersID(*id)
|
||||
}
|
||||
@@ -400,7 +400,7 @@ func (sc *StatsCreate) createSpec() (*Stats, *sqlgraph.CreateSpec) {
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Type: field.TypeUint64,
|
||||
Column: match.FieldID,
|
||||
},
|
||||
},
|
||||
@@ -420,7 +420,7 @@ func (sc *StatsCreate) createSpec() (*Stats, *sqlgraph.CreateSpec) {
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Type: field.TypeUint64,
|
||||
Column: player.FieldID,
|
||||
},
|
||||
},
|
||||
|
@@ -30,6 +30,7 @@ type StatsQuery struct {
|
||||
withMatches *MatchQuery
|
||||
withPlayers *PlayerQuery
|
||||
withFKs bool
|
||||
modifiers []func(s *sql.Selector)
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
@@ -411,6 +412,9 @@ func (sq *StatsQuery) sqlAll(ctx context.Context) ([]*Stats, error) {
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
if len(sq.modifiers) > 0 {
|
||||
_spec.Modifiers = sq.modifiers
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, sq.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -419,8 +423,8 @@ func (sq *StatsQuery) sqlAll(ctx context.Context) ([]*Stats, error) {
|
||||
}
|
||||
|
||||
if query := sq.withMatches; query != nil {
|
||||
ids := make([]int, 0, len(nodes))
|
||||
nodeids := make(map[int][]*Stats)
|
||||
ids := make([]uint64, 0, len(nodes))
|
||||
nodeids := make(map[uint64][]*Stats)
|
||||
for i := range nodes {
|
||||
if nodes[i].match_stats == nil {
|
||||
continue
|
||||
@@ -448,8 +452,8 @@ func (sq *StatsQuery) sqlAll(ctx context.Context) ([]*Stats, error) {
|
||||
}
|
||||
|
||||
if query := sq.withPlayers; query != nil {
|
||||
ids := make([]int, 0, len(nodes))
|
||||
nodeids := make(map[int][]*Stats)
|
||||
ids := make([]uint64, 0, len(nodes))
|
||||
nodeids := make(map[uint64][]*Stats)
|
||||
for i := range nodes {
|
||||
if nodes[i].player_stats == nil {
|
||||
continue
|
||||
@@ -481,6 +485,9 @@ func (sq *StatsQuery) sqlAll(ctx context.Context) ([]*Stats, error) {
|
||||
|
||||
func (sq *StatsQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := sq.querySpec()
|
||||
if len(sq.modifiers) > 0 {
|
||||
_spec.Modifiers = sq.modifiers
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, sq.driver, _spec)
|
||||
}
|
||||
|
||||
@@ -552,6 +559,9 @@ func (sq *StatsQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
selector = sq.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
for _, m := range sq.modifiers {
|
||||
m(selector)
|
||||
}
|
||||
for _, p := range sq.predicates {
|
||||
p(selector)
|
||||
}
|
||||
@@ -569,6 +579,12 @@ func (sq *StatsQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
return selector
|
||||
}
|
||||
|
||||
// Modify adds a query modifier for attaching custom logic to queries.
|
||||
func (sq *StatsQuery) Modify(modifiers ...func(s *sql.Selector)) *StatsSelect {
|
||||
sq.modifiers = append(sq.modifiers, modifiers...)
|
||||
return sq.Select()
|
||||
}
|
||||
|
||||
// StatsGroupBy is the group-by builder for Stats entities.
|
||||
type StatsGroupBy struct {
|
||||
config
|
||||
@@ -1058,3 +1074,9 @@ func (ss *StatsSelect) sqlScan(ctx context.Context, v interface{}) error {
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
// Modify adds a query modifier for attaching custom logic to queries.
|
||||
func (ss *StatsSelect) Modify(modifiers ...func(s *sql.Selector)) *StatsSelect {
|
||||
ss.modifiers = append(ss.modifiers, modifiers...)
|
||||
return ss
|
||||
}
|
||||
|
@@ -234,13 +234,13 @@ func (su *StatsUpdate) ClearExtended() *StatsUpdate {
|
||||
}
|
||||
|
||||
// SetMatchesID sets the "matches" edge to the Match entity by ID.
|
||||
func (su *StatsUpdate) SetMatchesID(id int) *StatsUpdate {
|
||||
func (su *StatsUpdate) SetMatchesID(id uint64) *StatsUpdate {
|
||||
su.mutation.SetMatchesID(id)
|
||||
return su
|
||||
}
|
||||
|
||||
// SetNillableMatchesID sets the "matches" edge to the Match entity by ID if the given value is not nil.
|
||||
func (su *StatsUpdate) SetNillableMatchesID(id *int) *StatsUpdate {
|
||||
func (su *StatsUpdate) SetNillableMatchesID(id *uint64) *StatsUpdate {
|
||||
if id != nil {
|
||||
su = su.SetMatchesID(*id)
|
||||
}
|
||||
@@ -253,13 +253,13 @@ func (su *StatsUpdate) SetMatches(m *Match) *StatsUpdate {
|
||||
}
|
||||
|
||||
// SetPlayersID sets the "players" edge to the Player entity by ID.
|
||||
func (su *StatsUpdate) SetPlayersID(id int) *StatsUpdate {
|
||||
func (su *StatsUpdate) SetPlayersID(id uint64) *StatsUpdate {
|
||||
su.mutation.SetPlayersID(id)
|
||||
return su
|
||||
}
|
||||
|
||||
// SetNillablePlayersID sets the "players" edge to the Player entity by ID if the given value is not nil.
|
||||
func (su *StatsUpdate) SetNillablePlayersID(id *int) *StatsUpdate {
|
||||
func (su *StatsUpdate) SetNillablePlayersID(id *uint64) *StatsUpdate {
|
||||
if id != nil {
|
||||
su = su.SetPlayersID(*id)
|
||||
}
|
||||
@@ -480,7 +480,7 @@ func (su *StatsUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Type: field.TypeUint64,
|
||||
Column: match.FieldID,
|
||||
},
|
||||
},
|
||||
@@ -496,7 +496,7 @@ func (su *StatsUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Type: field.TypeUint64,
|
||||
Column: match.FieldID,
|
||||
},
|
||||
},
|
||||
@@ -515,7 +515,7 @@ func (su *StatsUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Type: field.TypeUint64,
|
||||
Column: player.FieldID,
|
||||
},
|
||||
},
|
||||
@@ -531,7 +531,7 @@ func (su *StatsUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Type: field.TypeUint64,
|
||||
Column: player.FieldID,
|
||||
},
|
||||
},
|
||||
@@ -766,13 +766,13 @@ func (suo *StatsUpdateOne) ClearExtended() *StatsUpdateOne {
|
||||
}
|
||||
|
||||
// SetMatchesID sets the "matches" edge to the Match entity by ID.
|
||||
func (suo *StatsUpdateOne) SetMatchesID(id int) *StatsUpdateOne {
|
||||
func (suo *StatsUpdateOne) SetMatchesID(id uint64) *StatsUpdateOne {
|
||||
suo.mutation.SetMatchesID(id)
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetNillableMatchesID sets the "matches" edge to the Match entity by ID if the given value is not nil.
|
||||
func (suo *StatsUpdateOne) SetNillableMatchesID(id *int) *StatsUpdateOne {
|
||||
func (suo *StatsUpdateOne) SetNillableMatchesID(id *uint64) *StatsUpdateOne {
|
||||
if id != nil {
|
||||
suo = suo.SetMatchesID(*id)
|
||||
}
|
||||
@@ -785,13 +785,13 @@ func (suo *StatsUpdateOne) SetMatches(m *Match) *StatsUpdateOne {
|
||||
}
|
||||
|
||||
// SetPlayersID sets the "players" edge to the Player entity by ID.
|
||||
func (suo *StatsUpdateOne) SetPlayersID(id int) *StatsUpdateOne {
|
||||
func (suo *StatsUpdateOne) SetPlayersID(id uint64) *StatsUpdateOne {
|
||||
suo.mutation.SetPlayersID(id)
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetNillablePlayersID sets the "players" edge to the Player entity by ID if the given value is not nil.
|
||||
func (suo *StatsUpdateOne) SetNillablePlayersID(id *int) *StatsUpdateOne {
|
||||
func (suo *StatsUpdateOne) SetNillablePlayersID(id *uint64) *StatsUpdateOne {
|
||||
if id != nil {
|
||||
suo = suo.SetPlayersID(*id)
|
||||
}
|
||||
@@ -1036,7 +1036,7 @@ func (suo *StatsUpdateOne) sqlSave(ctx context.Context) (_node *Stats, err error
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Type: field.TypeUint64,
|
||||
Column: match.FieldID,
|
||||
},
|
||||
},
|
||||
@@ -1052,7 +1052,7 @@ func (suo *StatsUpdateOne) sqlSave(ctx context.Context) (_node *Stats, err error
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Type: field.TypeUint64,
|
||||
Column: match.FieldID,
|
||||
},
|
||||
},
|
||||
@@ -1071,7 +1071,7 @@ func (suo *StatsUpdateOne) sqlSave(ctx context.Context) (_node *Stats, err error
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Type: field.TypeUint64,
|
||||
Column: player.FieldID,
|
||||
},
|
||||
},
|
||||
@@ -1087,7 +1087,7 @@ func (suo *StatsUpdateOne) sqlSave(ctx context.Context) (_node *Stats, err error
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Type: field.TypeUint64,
|
||||
Column: player.FieldID,
|
||||
},
|
||||
},
|
||||
|
7
go.sum
7
go.sum
@@ -66,6 +66,7 @@ github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||
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-sql-driver/mysql v1.5.1-0.20200311113236-681ffa848bae/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
@@ -180,6 +181,7 @@ github.com/markus-wa/quickhull-go/v2 v2.1.0 h1:DA2pzEzH0k5CEnlUsouRqNdD+jzNFb4DB
|
||||
github.com/markus-wa/quickhull-go/v2 v2.1.0/go.mod h1:bOlBUpIzGSMMhHX0f9N8CQs0VZD4nnPeta0OocH7m4o=
|
||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
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 h1:gDp86IdQsN/xWjIEmr9MF6o9mpksUgh0fu+9ByFxzIU=
|
||||
github.com/mattn/go-sqlite3 v1.14.8/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
||||
@@ -200,6 +202,7 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
|
||||
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/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
@@ -234,9 +237,11 @@ github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4k
|
||||
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||
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 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.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/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
@@ -297,6 +302,7 @@ golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKG
|
||||
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
|
||||
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 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
|
||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
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=
|
||||
@@ -375,6 +381,7 @@ golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtn
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
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-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
|
22
main.go
22
main.go
@@ -50,10 +50,10 @@ type PlayerResponse struct {
|
||||
Tracked bool `json:"tracked"`
|
||||
VanityURL string `json:"vanity_url,omitempty"`
|
||||
MatchStats struct {
|
||||
Win int
|
||||
Tie int
|
||||
Loss int
|
||||
} `json:"match_stats"`
|
||||
Win int `json:"win,omitempty"`
|
||||
Tie int `json:"tie,omitempty"`
|
||||
Loss int `json:"loss,omitempty"`
|
||||
} `json:"match_stats,omitempty"`
|
||||
Matches []*MatchResponse `json:"matches,omitempty"`
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ func getPlayer(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
response := PlayerResponse{
|
||||
SteamID64: tPlayer.Steamid,
|
||||
SteamID64: tPlayer.ID,
|
||||
Name: tPlayer.Name,
|
||||
Avatar: tPlayer.AvatarURL,
|
||||
VAC: tPlayer.Vac,
|
||||
@@ -185,7 +185,7 @@ func getPlayer(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
for _, iMatch := range tMatches {
|
||||
mResponse := &MatchResponse{
|
||||
MatchId: iMatch.MatchID,
|
||||
MatchId: iMatch.ID,
|
||||
ShareCode: iMatch.ShareCode,
|
||||
Map: iMatch.Map,
|
||||
Date: iMatch.Date,
|
||||
@@ -198,7 +198,7 @@ func getPlayer(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
db.Lock.RLock()
|
||||
tStats, err := iMatch.QueryStats().Where(stats.HasPlayersWith(player.Steamid(tPlayer.Steamid))).WithPlayers().All(context.Background())
|
||||
tStats, err := iMatch.QueryStats().Where(stats.HasPlayersWith(player.ID(tPlayer.ID))).WithPlayers().All(context.Background())
|
||||
db.Lock.RUnlock()
|
||||
if err != nil {
|
||||
response.Matches = append(response.Matches, mResponse)
|
||||
@@ -312,7 +312,7 @@ func getMatch(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
db.Lock.RLock()
|
||||
tMatch, err := db.Client.Match.Query().Where(match.MatchID(matchId)).Only(context.Background())
|
||||
tMatch, err := db.Client.Match.Query().Where(match.ID(matchId)).Only(context.Background())
|
||||
db.Lock.RUnlock()
|
||||
if err != nil {
|
||||
log.Warningf("[GM] match %d not found: %+v", matchId, err)
|
||||
@@ -320,7 +320,7 @@ func getMatch(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
mResponse := &MatchResponse{
|
||||
MatchId: tMatch.MatchID,
|
||||
MatchId: tMatch.ID,
|
||||
ShareCode: tMatch.ShareCode,
|
||||
Map: tMatch.Map,
|
||||
Date: tMatch.Date,
|
||||
@@ -336,13 +336,13 @@ func getMatch(w http.ResponseWriter, r *http.Request) {
|
||||
tStats, err := tMatch.QueryStats().WithPlayers().All(context.Background())
|
||||
db.Lock.RUnlock()
|
||||
if err != nil {
|
||||
log.Errorf("[GM] can't find stats for match %d: %v", tMatch.MatchID, err)
|
||||
log.Errorf("[GM] can't find stats for match %d: %v", tMatch.ID, err)
|
||||
}
|
||||
|
||||
for _, iStats := range tStats {
|
||||
sResponse := &StatsResponse{
|
||||
Player: PlayerResponse{
|
||||
SteamID64: iStats.Edges.Players.Steamid,
|
||||
SteamID64: iStats.Edges.Players.ID,
|
||||
Name: iStats.Edges.Players.Name,
|
||||
Avatar: iStats.Edges.Players.AvatarURL,
|
||||
VAC: iStats.Edges.Players.Vac,
|
||||
|
@@ -9,6 +9,7 @@ import (
|
||||
"csgowtfd/ent/stats"
|
||||
"encoding/json"
|
||||
"encoding/xml"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"fmt"
|
||||
"github.com/Philipp15b/go-steamapi"
|
||||
log "github.com/sirupsen/logrus"
|
||||
@@ -99,52 +100,51 @@ func SendJSON(data interface{}, w http.ResponseWriter) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetMatchStats(db *ent.Client, lock *sync.RWMutex, player *ent.Player) (int, int, int, error) {
|
||||
var v []struct {
|
||||
Wins int `json:"wins"`
|
||||
Ties int `json:"ties"`
|
||||
Total int `json:"total"`
|
||||
func GetMatchStats(db *ent.Client, lock *sync.RWMutex, dbPlayer *ent.Player) (int, int, int, error) {
|
||||
var res []struct {
|
||||
MatchResult int `json:"match_result"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
err := player.QueryMatches().
|
||||
WithStats().
|
||||
Where(
|
||||
match.Or(
|
||||
match.And(
|
||||
match.HasStatsWith(stats.TeamIDEQ(1)),
|
||||
match.MatchResultEQ(1)),
|
||||
match.And(
|
||||
match.HasStatsWith(stats.TeamIDEQ(2)),
|
||||
match.MatchResultEQ(2))),
|
||||
).
|
||||
GroupBy(match.FieldMatchID).
|
||||
Aggregate(ent.As(ent.Count(), "wins")).
|
||||
Scan(context.Background(), &v)
|
||||
|
||||
lock.RLock()
|
||||
err := dbPlayer.QueryMatches().GroupBy(match.FieldMatchResult).Aggregate(func(s *sql.Selector) string {
|
||||
sT := sql.Table(stats.Table)
|
||||
s.Join(sT).On(s.C(match.FieldID), sT.C(stats.MatchesColumn))
|
||||
s.Where(sql.And(sql.Or(sql.ColumnsEQ(match.FieldMatchResult, stats.FieldTeamID), sql.EQ(s.C(match.FieldMatchResult), 0)), sql.EQ(sT.C(stats.PlayersColumn), dbPlayer.ID)))
|
||||
return sql.Count("*")
|
||||
}).Scan(context.Background(), &res)
|
||||
lock.RUnlock()
|
||||
if err != nil {
|
||||
return 0, 0, 0, err
|
||||
}
|
||||
|
||||
err = player.QueryMatches().
|
||||
Where(match.MatchResultEQ(0)).
|
||||
GroupBy(match.FieldMatchID).
|
||||
Aggregate(ent.As(ent.Count(), "ties")).
|
||||
Scan(context.Background(), &v)
|
||||
lock.RLock()
|
||||
total, err := dbPlayer.QueryMatches().Modify(func(s *sql.Selector) {
|
||||
s.Select("COUNT(*)")
|
||||
}).Int(context.Background())
|
||||
lock.RUnlock()
|
||||
if err != nil {
|
||||
return 0, 0, 0, err
|
||||
}
|
||||
|
||||
err = player.QueryMatches().
|
||||
GroupBy(match.FieldMatchID).
|
||||
Aggregate(ent.As(ent.Count(), "total")).
|
||||
Scan(context.Background(), &v)
|
||||
if err != nil {
|
||||
return 0, 0, 0, err
|
||||
}
|
||||
|
||||
if len(v) < 1 {
|
||||
if len(res) < 1 {
|
||||
return 0, 0, 0, nil
|
||||
}
|
||||
var (
|
||||
wins int
|
||||
ties int
|
||||
)
|
||||
|
||||
return v[0].Wins, v[0].Ties, v[0].Total - v[0].Wins - v[0].Ties, nil
|
||||
for _, r := range res {
|
||||
switch r.MatchResult {
|
||||
case 0:
|
||||
ties = r.Count
|
||||
case 1, 2:
|
||||
wins += r.Count
|
||||
}
|
||||
}
|
||||
|
||||
return wins, ties, total - wins - ties, nil
|
||||
}
|
||||
|
||||
func IsAuthCodeValid(player *ent.Player, lock *sync.RWMutex, apiKey string, shareCode string, authCode string, rl ratelimit.Limiter) (bool, error) {
|
||||
@@ -158,13 +158,13 @@ func IsAuthCodeValid(player *ent.Player, lock *sync.RWMutex, apiKey string, shar
|
||||
return false, err
|
||||
}
|
||||
|
||||
_, err := getNextShareCode(tMatch.ShareCode, apiKey, authCode, player.Steamid, rl)
|
||||
_, err := getNextShareCode(tMatch.ShareCode, apiKey, authCode, player.ID, rl)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
} else {
|
||||
_, err := getNextShareCode(shareCode, apiKey, authCode, player.Steamid, rl)
|
||||
_, err := getNextShareCode(shareCode, apiKey, authCode, player.ID, rl)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -180,14 +180,14 @@ func GetNewShareCodesForPlayer(player *ent.Player, lock *sync.RWMutex, apiKey st
|
||||
return nil, err
|
||||
}
|
||||
var rCodes []string
|
||||
newShareCode, err := getNextShareCode(tMatch.ShareCode, apiKey, player.AuthCode, player.Steamid, rl)
|
||||
newShareCode, err := getNextShareCode(tMatch.ShareCode, apiKey, player.AuthCode, player.ID, rl)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for newShareCode != "n/a" {
|
||||
rCodes = append(rCodes, newShareCode)
|
||||
newShareCode, err = getNextShareCode(rCodes[len(rCodes)-1], apiKey, player.AuthCode, player.Steamid, rl)
|
||||
newShareCode, err = getNextShareCode(rCodes[len(rCodes)-1], apiKey, player.AuthCode, player.ID, rl)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -278,7 +278,7 @@ func GetPlayerFromVanityURL(db *DBWithLock, id string) (*ent.Player, error) {
|
||||
}
|
||||
|
||||
db.Lock.Lock()
|
||||
nPlayer, err := db.Client.Player.Create().SetSteamid(profile.SteamID64).SetVanityURL(strings.ToLower(profile.VanityURL)).SetVac(profile.VacBanned).SetAvatarURL(profile.AvatarURL).SetName(profile.ProfileName).Save(context.Background())
|
||||
nPlayer, err := db.Client.Player.Create().SetID(profile.SteamID64).SetVanityURL(strings.ToLower(profile.VanityURL)).SetVac(profile.VacBanned).SetAvatarURL(profile.AvatarURL).SetName(profile.ProfileName).Save(context.Background())
|
||||
db.Lock.Unlock()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -289,13 +289,13 @@ func GetPlayerFromVanityURL(db *DBWithLock, id string) (*ent.Player, error) {
|
||||
|
||||
func GetPlayerFromSteamID64(db *DBWithLock, steamID uint64, apiKey string, rl ratelimit.Limiter) (*ent.Player, error) {
|
||||
db.Lock.RLock()
|
||||
tPlayer, err := db.Client.Player.Query().Where(player.Steamid(steamID)).Only(context.Background())
|
||||
tPlayer, err := db.Client.Player.Query().Where(player.ID(steamID)).Only(context.Background())
|
||||
db.Lock.RUnlock()
|
||||
if err == nil {
|
||||
return tPlayer, nil
|
||||
} else {
|
||||
db.Lock.Lock()
|
||||
nPlayer, err := db.Client.Player.Create().SetSteamid(steamID).Save(context.Background())
|
||||
nPlayer, err := db.Client.Player.Create().SetID(steamID).Save(context.Background())
|
||||
db.Lock.Unlock()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -326,7 +326,7 @@ func GCInfoParser(channel chan *csgo.Demo, dl *csgo.DemoMatchLoader, dp *csgo.De
|
||||
}
|
||||
|
||||
db.Lock.RLock()
|
||||
iMatch, err := db.Client.Match.Query().Where(match.MatchID(matchId)).Only(context.Background())
|
||||
iMatch, err := db.Client.Match.Query().Where(match.ID(matchId)).Only(context.Background())
|
||||
db.Lock.RUnlock()
|
||||
if err != nil {
|
||||
switch e := err.(type) {
|
||||
@@ -365,7 +365,7 @@ func GCInfoParser(channel chan *csgo.Demo, dl *csgo.DemoMatchLoader, dp *csgo.De
|
||||
|
||||
db.Lock.Lock()
|
||||
tMatch, err := db.Client.Match.Create().
|
||||
SetMatchID(matchZero.GetMatchid()).
|
||||
SetID(matchZero.GetMatchid()).
|
||||
AddPlayers(players...).
|
||||
SetDate(time.Unix(int64(matchZero.GetMatchtime()), 0).UTC()).
|
||||
SetMaxRounds(int(lastRound.GetMaxRounds())).
|
||||
@@ -435,7 +435,7 @@ func SteamProfile2XML(id string, steamID64 uint64) (*CommunityXML, error) {
|
||||
}
|
||||
|
||||
func UpdatePlayerFromSteam(player *ent.Player, apiKey string, lock *sync.RWMutex, rl ratelimit.Limiter) (*ent.Player, error) {
|
||||
profile, err := SteamProfile2XML("", player.Steamid)
|
||||
profile, err := SteamProfile2XML("", player.ID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user