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