fixed match win/loss/ties
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user