updated deps; switched sitemap lib; ent regen

This commit is contained in:
2023-03-03 20:10:31 +01:00
parent e9a5daa9e3
commit 727d530378
52 changed files with 2626 additions and 5665 deletions

View File

@@ -18,11 +18,9 @@ import (
// RoundStatsQuery is the builder for querying RoundStats entities.
type RoundStatsQuery struct {
config
limit *int
offset *int
unique *bool
ctx *QueryContext
order []OrderFunc
fields []string
inters []Interceptor
predicates []predicate.RoundStats
withMatchPlayer *MatchPlayerQuery
withFKs bool
@@ -38,26 +36,26 @@ func (rsq *RoundStatsQuery) Where(ps ...predicate.RoundStats) *RoundStatsQuery {
return rsq
}
// Limit adds a limit step to the query.
// Limit the number of records to be returned by this query.
func (rsq *RoundStatsQuery) Limit(limit int) *RoundStatsQuery {
rsq.limit = &limit
rsq.ctx.Limit = &limit
return rsq
}
// Offset adds an offset step to the query.
// Offset to start from.
func (rsq *RoundStatsQuery) Offset(offset int) *RoundStatsQuery {
rsq.offset = &offset
rsq.ctx.Offset = &offset
return rsq
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (rsq *RoundStatsQuery) Unique(unique bool) *RoundStatsQuery {
rsq.unique = &unique
rsq.ctx.Unique = &unique
return rsq
}
// Order adds an order step to the query.
// Order specifies how the records should be ordered.
func (rsq *RoundStatsQuery) Order(o ...OrderFunc) *RoundStatsQuery {
rsq.order = append(rsq.order, o...)
return rsq
@@ -65,7 +63,7 @@ func (rsq *RoundStatsQuery) Order(o ...OrderFunc) *RoundStatsQuery {
// QueryMatchPlayer chains the current query on the "match_player" edge.
func (rsq *RoundStatsQuery) QueryMatchPlayer() *MatchPlayerQuery {
query := &MatchPlayerQuery{config: rsq.config}
query := (&MatchPlayerClient{config: rsq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := rsq.prepareQuery(ctx); err != nil {
return nil, err
@@ -88,7 +86,7 @@ func (rsq *RoundStatsQuery) QueryMatchPlayer() *MatchPlayerQuery {
// First returns the first RoundStats entity from the query.
// Returns a *NotFoundError when no RoundStats was found.
func (rsq *RoundStatsQuery) First(ctx context.Context) (*RoundStats, error) {
nodes, err := rsq.Limit(1).All(ctx)
nodes, err := rsq.Limit(1).All(setContextOp(ctx, rsq.ctx, "First"))
if err != nil {
return nil, err
}
@@ -111,7 +109,7 @@ func (rsq *RoundStatsQuery) FirstX(ctx context.Context) *RoundStats {
// Returns a *NotFoundError when no RoundStats ID was found.
func (rsq *RoundStatsQuery) FirstID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = rsq.Limit(1).IDs(ctx); err != nil {
if ids, err = rsq.Limit(1).IDs(setContextOp(ctx, rsq.ctx, "FirstID")); err != nil {
return
}
if len(ids) == 0 {
@@ -134,7 +132,7 @@ func (rsq *RoundStatsQuery) FirstIDX(ctx context.Context) int {
// Returns a *NotSingularError when more than one RoundStats entity is found.
// Returns a *NotFoundError when no RoundStats entities are found.
func (rsq *RoundStatsQuery) Only(ctx context.Context) (*RoundStats, error) {
nodes, err := rsq.Limit(2).All(ctx)
nodes, err := rsq.Limit(2).All(setContextOp(ctx, rsq.ctx, "Only"))
if err != nil {
return nil, err
}
@@ -162,7 +160,7 @@ func (rsq *RoundStatsQuery) OnlyX(ctx context.Context) *RoundStats {
// Returns a *NotFoundError when no entities are found.
func (rsq *RoundStatsQuery) OnlyID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = rsq.Limit(2).IDs(ctx); err != nil {
if ids, err = rsq.Limit(2).IDs(setContextOp(ctx, rsq.ctx, "OnlyID")); err != nil {
return
}
switch len(ids) {
@@ -187,10 +185,12 @@ func (rsq *RoundStatsQuery) OnlyIDX(ctx context.Context) int {
// All executes the query and returns a list of RoundStatsSlice.
func (rsq *RoundStatsQuery) All(ctx context.Context) ([]*RoundStats, error) {
ctx = setContextOp(ctx, rsq.ctx, "All")
if err := rsq.prepareQuery(ctx); err != nil {
return nil, err
}
return rsq.sqlAll(ctx)
qr := querierAll[[]*RoundStats, *RoundStatsQuery]()
return withInterceptors[[]*RoundStats](ctx, rsq, qr, rsq.inters)
}
// AllX is like All, but panics if an error occurs.
@@ -203,9 +203,12 @@ func (rsq *RoundStatsQuery) AllX(ctx context.Context) []*RoundStats {
}
// IDs executes the query and returns a list of RoundStats IDs.
func (rsq *RoundStatsQuery) IDs(ctx context.Context) ([]int, error) {
var ids []int
if err := rsq.Select(roundstats.FieldID).Scan(ctx, &ids); err != nil {
func (rsq *RoundStatsQuery) IDs(ctx context.Context) (ids []int, err error) {
if rsq.ctx.Unique == nil && rsq.path != nil {
rsq.Unique(true)
}
ctx = setContextOp(ctx, rsq.ctx, "IDs")
if err = rsq.Select(roundstats.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
@@ -222,10 +225,11 @@ func (rsq *RoundStatsQuery) IDsX(ctx context.Context) []int {
// Count returns the count of the given query.
func (rsq *RoundStatsQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, rsq.ctx, "Count")
if err := rsq.prepareQuery(ctx); err != nil {
return 0, err
}
return rsq.sqlCount(ctx)
return withInterceptors[int](ctx, rsq, querierCount[*RoundStatsQuery](), rsq.inters)
}
// CountX is like Count, but panics if an error occurs.
@@ -239,10 +243,15 @@ func (rsq *RoundStatsQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph.
func (rsq *RoundStatsQuery) Exist(ctx context.Context) (bool, error) {
if err := rsq.prepareQuery(ctx); err != nil {
return false, err
ctx = setContextOp(ctx, rsq.ctx, "Exist")
switch _, err := rsq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
return rsq.sqlExist(ctx)
}
// ExistX is like Exist, but panics if an error occurs.
@@ -262,22 +271,21 @@ func (rsq *RoundStatsQuery) Clone() *RoundStatsQuery {
}
return &RoundStatsQuery{
config: rsq.config,
limit: rsq.limit,
offset: rsq.offset,
ctx: rsq.ctx.Clone(),
order: append([]OrderFunc{}, rsq.order...),
inters: append([]Interceptor{}, rsq.inters...),
predicates: append([]predicate.RoundStats{}, rsq.predicates...),
withMatchPlayer: rsq.withMatchPlayer.Clone(),
// clone intermediate query.
sql: rsq.sql.Clone(),
path: rsq.path,
unique: rsq.unique,
sql: rsq.sql.Clone(),
path: rsq.path,
}
}
// WithMatchPlayer tells the query-builder to eager-load the nodes that are connected to
// the "match_player" edge. The optional arguments are used to configure the query builder of the edge.
func (rsq *RoundStatsQuery) WithMatchPlayer(opts ...func(*MatchPlayerQuery)) *RoundStatsQuery {
query := &MatchPlayerQuery{config: rsq.config}
query := (&MatchPlayerClient{config: rsq.config}).Query()
for _, opt := range opts {
opt(query)
}
@@ -300,16 +308,11 @@ func (rsq *RoundStatsQuery) WithMatchPlayer(opts ...func(*MatchPlayerQuery)) *Ro
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func (rsq *RoundStatsQuery) GroupBy(field string, fields ...string) *RoundStatsGroupBy {
grbuild := &RoundStatsGroupBy{config: rsq.config}
grbuild.fields = append([]string{field}, fields...)
grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) {
if err := rsq.prepareQuery(ctx); err != nil {
return nil, err
}
return rsq.sqlQuery(ctx), nil
}
rsq.ctx.Fields = append([]string{field}, fields...)
grbuild := &RoundStatsGroupBy{build: rsq}
grbuild.flds = &rsq.ctx.Fields
grbuild.label = roundstats.Label
grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan
grbuild.scan = grbuild.Scan
return grbuild
}
@@ -326,11 +329,11 @@ func (rsq *RoundStatsQuery) GroupBy(field string, fields ...string) *RoundStatsG
// Select(roundstats.FieldRound).
// Scan(ctx, &v)
func (rsq *RoundStatsQuery) Select(fields ...string) *RoundStatsSelect {
rsq.fields = append(rsq.fields, fields...)
selbuild := &RoundStatsSelect{RoundStatsQuery: rsq}
selbuild.label = roundstats.Label
selbuild.flds, selbuild.scan = &rsq.fields, selbuild.Scan
return selbuild
rsq.ctx.Fields = append(rsq.ctx.Fields, fields...)
sbuild := &RoundStatsSelect{RoundStatsQuery: rsq}
sbuild.label = roundstats.Label
sbuild.flds, sbuild.scan = &rsq.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a RoundStatsSelect configured with the given aggregations.
@@ -339,7 +342,17 @@ func (rsq *RoundStatsQuery) Aggregate(fns ...AggregateFunc) *RoundStatsSelect {
}
func (rsq *RoundStatsQuery) prepareQuery(ctx context.Context) error {
for _, f := range rsq.fields {
for _, inter := range rsq.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, rsq); err != nil {
return err
}
}
}
for _, f := range rsq.ctx.Fields {
if !roundstats.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
@@ -412,6 +425,9 @@ func (rsq *RoundStatsQuery) loadMatchPlayer(ctx context.Context, query *MatchPla
}
nodeids[fk] = append(nodeids[fk], nodes[i])
}
if len(ids) == 0 {
return nil
}
query.Where(matchplayer.IDIn(ids...))
neighbors, err := query.All(ctx)
if err != nil {
@@ -434,41 +450,22 @@ func (rsq *RoundStatsQuery) sqlCount(ctx context.Context) (int, error) {
if len(rsq.modifiers) > 0 {
_spec.Modifiers = rsq.modifiers
}
_spec.Node.Columns = rsq.fields
if len(rsq.fields) > 0 {
_spec.Unique = rsq.unique != nil && *rsq.unique
_spec.Node.Columns = rsq.ctx.Fields
if len(rsq.ctx.Fields) > 0 {
_spec.Unique = rsq.ctx.Unique != nil && *rsq.ctx.Unique
}
return sqlgraph.CountNodes(ctx, rsq.driver, _spec)
}
func (rsq *RoundStatsQuery) sqlExist(ctx context.Context) (bool, error) {
switch _, err := rsq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
func (rsq *RoundStatsQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{
Node: &sqlgraph.NodeSpec{
Table: roundstats.Table,
Columns: roundstats.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: roundstats.FieldID,
},
},
From: rsq.sql,
Unique: true,
}
if unique := rsq.unique; unique != nil {
_spec := sqlgraph.NewQuerySpec(roundstats.Table, roundstats.Columns, sqlgraph.NewFieldSpec(roundstats.FieldID, field.TypeInt))
_spec.From = rsq.sql
if unique := rsq.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if rsq.path != nil {
_spec.Unique = true
}
if fields := rsq.fields; len(fields) > 0 {
if fields := rsq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, roundstats.FieldID)
for i := range fields {
@@ -484,10 +481,10 @@ func (rsq *RoundStatsQuery) querySpec() *sqlgraph.QuerySpec {
}
}
}
if limit := rsq.limit; limit != nil {
if limit := rsq.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := rsq.offset; offset != nil {
if offset := rsq.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := rsq.order; len(ps) > 0 {
@@ -503,7 +500,7 @@ func (rsq *RoundStatsQuery) querySpec() *sqlgraph.QuerySpec {
func (rsq *RoundStatsQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(rsq.driver.Dialect())
t1 := builder.Table(roundstats.Table)
columns := rsq.fields
columns := rsq.ctx.Fields
if len(columns) == 0 {
columns = roundstats.Columns
}
@@ -512,7 +509,7 @@ func (rsq *RoundStatsQuery) sqlQuery(ctx context.Context) *sql.Selector {
selector = rsq.sql
selector.Select(selector.Columns(columns...)...)
}
if rsq.unique != nil && *rsq.unique {
if rsq.ctx.Unique != nil && *rsq.ctx.Unique {
selector.Distinct()
}
for _, m := range rsq.modifiers {
@@ -524,12 +521,12 @@ func (rsq *RoundStatsQuery) sqlQuery(ctx context.Context) *sql.Selector {
for _, p := range rsq.order {
p(selector)
}
if offset := rsq.offset; offset != nil {
if offset := rsq.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := rsq.limit; limit != nil {
if limit := rsq.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
@@ -543,13 +540,8 @@ func (rsq *RoundStatsQuery) Modify(modifiers ...func(s *sql.Selector)) *RoundSta
// RoundStatsGroupBy is the group-by builder for RoundStats entities.
type RoundStatsGroupBy struct {
config
selector
fields []string
fns []AggregateFunc
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
build *RoundStatsQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
@@ -558,58 +550,46 @@ func (rsgb *RoundStatsGroupBy) Aggregate(fns ...AggregateFunc) *RoundStatsGroupB
return rsgb
}
// Scan applies the group-by query and scans the result into the given value.
// Scan applies the selector query and scans the result into the given value.
func (rsgb *RoundStatsGroupBy) Scan(ctx context.Context, v any) error {
query, err := rsgb.path(ctx)
if err != nil {
ctx = setContextOp(ctx, rsgb.build.ctx, "GroupBy")
if err := rsgb.build.prepareQuery(ctx); err != nil {
return err
}
rsgb.sql = query
return rsgb.sqlScan(ctx, v)
return scanWithInterceptors[*RoundStatsQuery, *RoundStatsGroupBy](ctx, rsgb.build, rsgb, rsgb.build.inters, v)
}
func (rsgb *RoundStatsGroupBy) sqlScan(ctx context.Context, v any) error {
for _, f := range rsgb.fields {
if !roundstats.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)}
}
func (rsgb *RoundStatsGroupBy) sqlScan(ctx context.Context, root *RoundStatsQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(rsgb.fns))
for _, fn := range rsgb.fns {
aggregation = append(aggregation, fn(selector))
}
selector := rsgb.sqlQuery()
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*rsgb.flds)+len(rsgb.fns))
for _, f := range *rsgb.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*rsgb.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := rsgb.driver.Query(ctx, query, args, rows); err != nil {
if err := rsgb.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
func (rsgb *RoundStatsGroupBy) sqlQuery() *sql.Selector {
selector := rsgb.sql.Select()
aggregation := make([]string, 0, len(rsgb.fns))
for _, fn := range rsgb.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(rsgb.fields)+len(rsgb.fns))
for _, f := range rsgb.fields {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
return selector.GroupBy(selector.Columns(rsgb.fields...)...)
}
// RoundStatsSelect is the builder for selecting fields of RoundStats entities.
type RoundStatsSelect struct {
*RoundStatsQuery
selector
// intermediate query (i.e. traversal path).
sql *sql.Selector
}
// Aggregate adds the given aggregation functions to the selector query.
@@ -620,26 +600,27 @@ func (rss *RoundStatsSelect) Aggregate(fns ...AggregateFunc) *RoundStatsSelect {
// Scan applies the selector query and scans the result into the given value.
func (rss *RoundStatsSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, rss.ctx, "Select")
if err := rss.prepareQuery(ctx); err != nil {
return err
}
rss.sql = rss.RoundStatsQuery.sqlQuery(ctx)
return rss.sqlScan(ctx, v)
return scanWithInterceptors[*RoundStatsQuery, *RoundStatsSelect](ctx, rss.RoundStatsQuery, rss, rss.inters, v)
}
func (rss *RoundStatsSelect) sqlScan(ctx context.Context, v any) error {
func (rss *RoundStatsSelect) sqlScan(ctx context.Context, root *RoundStatsQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(rss.fns))
for _, fn := range rss.fns {
aggregation = append(aggregation, fn(rss.sql))
aggregation = append(aggregation, fn(selector))
}
switch n := len(*rss.selector.flds); {
case n == 0 && len(aggregation) > 0:
rss.sql.Select(aggregation...)
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
rss.sql.AppendSelect(aggregation...)
selector.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := rss.sql.Query()
query, args := selector.Query()
if err := rss.driver.Query(ctx, query, args, rows); err != nil {
return err
}