added roundstats with eco info, switched to avatar hash
This commit is contained in:
@@ -150,12 +150,17 @@ func (p *DemoParser) parseWorker() {
|
|||||||
Dmg uint
|
Dmg uint
|
||||||
To uint64
|
To uint64
|
||||||
})
|
})
|
||||||
gameStarted := false
|
ecoMap := make(map[uint64][]*struct {
|
||||||
|
Round int
|
||||||
|
EqV int
|
||||||
|
Bank int
|
||||||
|
Spent int
|
||||||
|
}, 0)
|
||||||
demoParser := demoinfocs.NewParser(fDemo)
|
demoParser := demoinfocs.NewParser(fDemo)
|
||||||
|
|
||||||
// onPlayerHurt
|
// onPlayerHurt
|
||||||
demoParser.RegisterEventHandler(func(e events.PlayerHurt) {
|
demoParser.RegisterEventHandler(func(e events.PlayerHurt) {
|
||||||
if e.Attacker == nil || e.Player == nil || e.Weapon == nil || !gameStarted {
|
if e.Attacker == nil || e.Player == nil || e.Weapon == nil || !demoParser.GameState().IsMatchStarted() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,19 +198,26 @@ func (p *DemoParser) parseWorker() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// onKill
|
|
||||||
demoParser.RegisterEventHandler(func(e events.Kill) {
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
// onFreezeTimeEnd
|
// onFreezeTimeEnd
|
||||||
demoParser.RegisterEventHandler(func(e events.RoundFreezetimeEnd) {
|
demoParser.RegisterEventHandler(func(e events.RoundEnd) {
|
||||||
|
gs := demoParser.GameState()
|
||||||
|
if !gs.IsMatchStarted() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, p := range gs.Participants().Playing() {
|
||||||
|
ecoMap[p.SteamID64] = append(ecoMap[p.SteamID64], &struct {
|
||||||
|
Round int
|
||||||
|
EqV int
|
||||||
|
Bank int
|
||||||
|
Spent int
|
||||||
|
}{Round: gs.TotalRoundsPlayed(), EqV: p.EquipmentValueCurrent(), Bank: p.Money(), Spent: p.MoneySpentThisRound()})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// onRoundEnd
|
// onRoundEnd
|
||||||
demoParser.RegisterEventHandler(func(e events.RoundEnd) {
|
demoParser.RegisterEventHandler(func(e events.RoundEnd) {
|
||||||
if gameStarted {
|
if demoParser.GameState().IsMatchStarted() {
|
||||||
for _, IGP := range demoParser.GameState().Participants().Playing() {
|
for _, IGP := range demoParser.GameState().Participants().Playing() {
|
||||||
if IGP != nil && IGP.SteamID64 != 0 {
|
if IGP != nil && IGP.SteamID64 != 0 {
|
||||||
killDiff := IGP.Kills() - killMap[IGP.SteamID64]
|
killDiff := IGP.Kills() - killMap[IGP.SteamID64]
|
||||||
@@ -229,7 +241,7 @@ func (p *DemoParser) parseWorker() {
|
|||||||
|
|
||||||
// onPlayerFlashed
|
// onPlayerFlashed
|
||||||
demoParser.RegisterEventHandler(func(e events.PlayerFlashed) {
|
demoParser.RegisterEventHandler(func(e events.PlayerFlashed) {
|
||||||
if e.Attacker == nil || e.Player == nil || !gameStarted {
|
if e.Attacker == nil || e.Player == nil || !demoParser.GameState().IsMatchStarted() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,7 +269,6 @@ func (p *DemoParser) parseWorker() {
|
|||||||
// onMatchStart
|
// onMatchStart
|
||||||
demoParser.RegisterEventHandler(func(e events.MatchStart) {
|
demoParser.RegisterEventHandler(func(e events.MatchStart) {
|
||||||
gs := demoParser.GameState()
|
gs := demoParser.GameState()
|
||||||
gameStarted = true
|
|
||||||
|
|
||||||
for _, demoPlayer := range gs.Participants().Playing() {
|
for _, demoPlayer := range gs.Participants().Playing() {
|
||||||
if demoPlayer != nil && demoPlayer.SteamID64 != 0 {
|
if demoPlayer != nil && demoPlayer.SteamID64 != 0 {
|
||||||
@@ -360,6 +371,15 @@ func (p *DemoParser) parseWorker() {
|
|||||||
log.Errorf("[DP] Unable to create WeaponStat: %v", err)
|
log.Errorf("[DP] Unable to create WeaponStat: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, eco := range ecoMap[tMatchPlayer.PlayerStats] {
|
||||||
|
p.lock.Lock()
|
||||||
|
err := p.db.RoundStats.Create().SetStat(nMatchPLayer).SetRound(uint(eco.Round)).SetBank(uint(eco.Bank)).SetEquipment(uint(eco.EqV)).Exec(context.Background())
|
||||||
|
p.lock.Unlock()
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("[DP] Unable to create WeaponStat: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Infof("[DP] Parsed %d (took %s/%s)", demo.MatchId, downloadTime, time.Now().Sub(startTime))
|
log.Infof("[DP] Parsed %d (took %s/%s)", demo.MatchId, downloadTime, time.Now().Sub(startTime))
|
||||||
|
129
ent/client.go
129
ent/client.go
@@ -11,6 +11,7 @@ import (
|
|||||||
|
|
||||||
"csgowtfd/ent/match"
|
"csgowtfd/ent/match"
|
||||||
"csgowtfd/ent/player"
|
"csgowtfd/ent/player"
|
||||||
|
"csgowtfd/ent/roundstats"
|
||||||
"csgowtfd/ent/stats"
|
"csgowtfd/ent/stats"
|
||||||
"csgowtfd/ent/weaponstats"
|
"csgowtfd/ent/weaponstats"
|
||||||
|
|
||||||
@@ -28,6 +29,8 @@ type Client struct {
|
|||||||
Match *MatchClient
|
Match *MatchClient
|
||||||
// Player is the client for interacting with the Player builders.
|
// Player is the client for interacting with the Player builders.
|
||||||
Player *PlayerClient
|
Player *PlayerClient
|
||||||
|
// RoundStats is the client for interacting with the RoundStats builders.
|
||||||
|
RoundStats *RoundStatsClient
|
||||||
// Stats is the client for interacting with the Stats builders.
|
// Stats is the client for interacting with the Stats builders.
|
||||||
Stats *StatsClient
|
Stats *StatsClient
|
||||||
// WeaponStats is the client for interacting with the WeaponStats builders.
|
// WeaponStats is the client for interacting with the WeaponStats builders.
|
||||||
@@ -47,6 +50,7 @@ func (c *Client) init() {
|
|||||||
c.Schema = migrate.NewSchema(c.driver)
|
c.Schema = migrate.NewSchema(c.driver)
|
||||||
c.Match = NewMatchClient(c.config)
|
c.Match = NewMatchClient(c.config)
|
||||||
c.Player = NewPlayerClient(c.config)
|
c.Player = NewPlayerClient(c.config)
|
||||||
|
c.RoundStats = NewRoundStatsClient(c.config)
|
||||||
c.Stats = NewStatsClient(c.config)
|
c.Stats = NewStatsClient(c.config)
|
||||||
c.WeaponStats = NewWeaponStatsClient(c.config)
|
c.WeaponStats = NewWeaponStatsClient(c.config)
|
||||||
}
|
}
|
||||||
@@ -84,6 +88,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
|
|||||||
config: cfg,
|
config: cfg,
|
||||||
Match: NewMatchClient(cfg),
|
Match: NewMatchClient(cfg),
|
||||||
Player: NewPlayerClient(cfg),
|
Player: NewPlayerClient(cfg),
|
||||||
|
RoundStats: NewRoundStatsClient(cfg),
|
||||||
Stats: NewStatsClient(cfg),
|
Stats: NewStatsClient(cfg),
|
||||||
WeaponStats: NewWeaponStatsClient(cfg),
|
WeaponStats: NewWeaponStatsClient(cfg),
|
||||||
}, nil
|
}, nil
|
||||||
@@ -106,6 +111,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
|
|||||||
config: cfg,
|
config: cfg,
|
||||||
Match: NewMatchClient(cfg),
|
Match: NewMatchClient(cfg),
|
||||||
Player: NewPlayerClient(cfg),
|
Player: NewPlayerClient(cfg),
|
||||||
|
RoundStats: NewRoundStatsClient(cfg),
|
||||||
Stats: NewStatsClient(cfg),
|
Stats: NewStatsClient(cfg),
|
||||||
WeaponStats: NewWeaponStatsClient(cfg),
|
WeaponStats: NewWeaponStatsClient(cfg),
|
||||||
}, nil
|
}, nil
|
||||||
@@ -139,6 +145,7 @@ func (c *Client) Close() error {
|
|||||||
func (c *Client) Use(hooks ...Hook) {
|
func (c *Client) Use(hooks ...Hook) {
|
||||||
c.Match.Use(hooks...)
|
c.Match.Use(hooks...)
|
||||||
c.Player.Use(hooks...)
|
c.Player.Use(hooks...)
|
||||||
|
c.RoundStats.Use(hooks...)
|
||||||
c.Stats.Use(hooks...)
|
c.Stats.Use(hooks...)
|
||||||
c.WeaponStats.Use(hooks...)
|
c.WeaponStats.Use(hooks...)
|
||||||
}
|
}
|
||||||
@@ -387,6 +394,112 @@ func (c *PlayerClient) Hooks() []Hook {
|
|||||||
return c.hooks.Player
|
return c.hooks.Player
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RoundStatsClient is a client for the RoundStats schema.
|
||||||
|
type RoundStatsClient struct {
|
||||||
|
config
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewRoundStatsClient returns a client for the RoundStats from the given config.
|
||||||
|
func NewRoundStatsClient(c config) *RoundStatsClient {
|
||||||
|
return &RoundStatsClient{config: c}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use adds a list of mutation hooks to the hooks stack.
|
||||||
|
// A call to `Use(f, g, h)` equals to `roundstats.Hooks(f(g(h())))`.
|
||||||
|
func (c *RoundStatsClient) Use(hooks ...Hook) {
|
||||||
|
c.hooks.RoundStats = append(c.hooks.RoundStats, hooks...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create returns a create builder for RoundStats.
|
||||||
|
func (c *RoundStatsClient) Create() *RoundStatsCreate {
|
||||||
|
mutation := newRoundStatsMutation(c.config, OpCreate)
|
||||||
|
return &RoundStatsCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateBulk returns a builder for creating a bulk of RoundStats entities.
|
||||||
|
func (c *RoundStatsClient) CreateBulk(builders ...*RoundStatsCreate) *RoundStatsCreateBulk {
|
||||||
|
return &RoundStatsCreateBulk{config: c.config, builders: builders}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update returns an update builder for RoundStats.
|
||||||
|
func (c *RoundStatsClient) Update() *RoundStatsUpdate {
|
||||||
|
mutation := newRoundStatsMutation(c.config, OpUpdate)
|
||||||
|
return &RoundStatsUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateOne returns an update builder for the given entity.
|
||||||
|
func (c *RoundStatsClient) UpdateOne(rs *RoundStats) *RoundStatsUpdateOne {
|
||||||
|
mutation := newRoundStatsMutation(c.config, OpUpdateOne, withRoundStats(rs))
|
||||||
|
return &RoundStatsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateOneID returns an update builder for the given id.
|
||||||
|
func (c *RoundStatsClient) UpdateOneID(id int) *RoundStatsUpdateOne {
|
||||||
|
mutation := newRoundStatsMutation(c.config, OpUpdateOne, withRoundStatsID(id))
|
||||||
|
return &RoundStatsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete returns a delete builder for RoundStats.
|
||||||
|
func (c *RoundStatsClient) Delete() *RoundStatsDelete {
|
||||||
|
mutation := newRoundStatsMutation(c.config, OpDelete)
|
||||||
|
return &RoundStatsDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteOne returns a delete builder for the given entity.
|
||||||
|
func (c *RoundStatsClient) DeleteOne(rs *RoundStats) *RoundStatsDeleteOne {
|
||||||
|
return c.DeleteOneID(rs.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteOneID returns a delete builder for the given id.
|
||||||
|
func (c *RoundStatsClient) DeleteOneID(id int) *RoundStatsDeleteOne {
|
||||||
|
builder := c.Delete().Where(roundstats.ID(id))
|
||||||
|
builder.mutation.id = &id
|
||||||
|
builder.mutation.op = OpDeleteOne
|
||||||
|
return &RoundStatsDeleteOne{builder}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Query returns a query builder for RoundStats.
|
||||||
|
func (c *RoundStatsClient) Query() *RoundStatsQuery {
|
||||||
|
return &RoundStatsQuery{
|
||||||
|
config: c.config,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get returns a RoundStats entity by its id.
|
||||||
|
func (c *RoundStatsClient) Get(ctx context.Context, id int) (*RoundStats, error) {
|
||||||
|
return c.Query().Where(roundstats.ID(id)).Only(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetX is like Get, but panics if an error occurs.
|
||||||
|
func (c *RoundStatsClient) GetX(ctx context.Context, id int) *RoundStats {
|
||||||
|
obj, err := c.Get(ctx, id)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return obj
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryStat queries the stat edge of a RoundStats.
|
||||||
|
func (c *RoundStatsClient) QueryStat(rs *RoundStats) *StatsQuery {
|
||||||
|
query := &StatsQuery{config: c.config}
|
||||||
|
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||||
|
id := rs.ID
|
||||||
|
step := sqlgraph.NewStep(
|
||||||
|
sqlgraph.From(roundstats.Table, roundstats.FieldID, id),
|
||||||
|
sqlgraph.To(stats.Table, stats.FieldID),
|
||||||
|
sqlgraph.Edge(sqlgraph.M2O, true, roundstats.StatTable, roundstats.StatColumn),
|
||||||
|
)
|
||||||
|
fromV = sqlgraph.Neighbors(rs.driver.Dialect(), step)
|
||||||
|
return fromV, nil
|
||||||
|
}
|
||||||
|
return query
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hooks returns the client hooks.
|
||||||
|
func (c *RoundStatsClient) Hooks() []Hook {
|
||||||
|
return c.hooks.RoundStats
|
||||||
|
}
|
||||||
|
|
||||||
// StatsClient is a client for the Stats schema.
|
// StatsClient is a client for the Stats schema.
|
||||||
type StatsClient struct {
|
type StatsClient struct {
|
||||||
config
|
config
|
||||||
@@ -520,6 +633,22 @@ func (c *StatsClient) QueryWeaponStats(s *Stats) *WeaponStatsQuery {
|
|||||||
return query
|
return query
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// QueryRoundStats queries the round_stats edge of a Stats.
|
||||||
|
func (c *StatsClient) QueryRoundStats(s *Stats) *RoundStatsQuery {
|
||||||
|
query := &RoundStatsQuery{config: c.config}
|
||||||
|
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||||
|
id := s.ID
|
||||||
|
step := sqlgraph.NewStep(
|
||||||
|
sqlgraph.From(stats.Table, stats.FieldID, id),
|
||||||
|
sqlgraph.To(roundstats.Table, roundstats.FieldID),
|
||||||
|
sqlgraph.Edge(sqlgraph.O2M, false, stats.RoundStatsTable, stats.RoundStatsColumn),
|
||||||
|
)
|
||||||
|
fromV = sqlgraph.Neighbors(s.driver.Dialect(), step)
|
||||||
|
return fromV, nil
|
||||||
|
}
|
||||||
|
return query
|
||||||
|
}
|
||||||
|
|
||||||
// Hooks returns the client hooks.
|
// Hooks returns the client hooks.
|
||||||
func (c *StatsClient) Hooks() []Hook {
|
func (c *StatsClient) Hooks() []Hook {
|
||||||
return c.hooks.Stats
|
return c.hooks.Stats
|
||||||
|
@@ -26,6 +26,7 @@ type config struct {
|
|||||||
type hooks struct {
|
type hooks struct {
|
||||||
Match []ent.Hook
|
Match []ent.Hook
|
||||||
Player []ent.Hook
|
Player []ent.Hook
|
||||||
|
RoundStats []ent.Hook
|
||||||
Stats []ent.Hook
|
Stats []ent.Hook
|
||||||
WeaponStats []ent.Hook
|
WeaponStats []ent.Hook
|
||||||
}
|
}
|
||||||
|
@@ -5,6 +5,7 @@ package ent
|
|||||||
import (
|
import (
|
||||||
"csgowtfd/ent/match"
|
"csgowtfd/ent/match"
|
||||||
"csgowtfd/ent/player"
|
"csgowtfd/ent/player"
|
||||||
|
"csgowtfd/ent/roundstats"
|
||||||
"csgowtfd/ent/stats"
|
"csgowtfd/ent/stats"
|
||||||
"csgowtfd/ent/weaponstats"
|
"csgowtfd/ent/weaponstats"
|
||||||
"errors"
|
"errors"
|
||||||
@@ -34,6 +35,7 @@ func columnChecker(table string) func(string) error {
|
|||||||
checks := map[string]func(string) bool{
|
checks := map[string]func(string) bool{
|
||||||
match.Table: match.ValidColumn,
|
match.Table: match.ValidColumn,
|
||||||
player.Table: player.ValidColumn,
|
player.Table: player.ValidColumn,
|
||||||
|
roundstats.Table: roundstats.ValidColumn,
|
||||||
stats.Table: stats.ValidColumn,
|
stats.Table: stats.ValidColumn,
|
||||||
weaponstats.Table: weaponstats.ValidColumn,
|
weaponstats.Table: weaponstats.ValidColumn,
|
||||||
}
|
}
|
||||||
|
@@ -1,3 +0,0 @@
|
|||||||
package ent
|
|
||||||
|
|
||||||
//go:generate go run -mod=mod entgo.io/ent/cmd/ent generate ./schema
|
|
@@ -34,6 +34,19 @@ func (f PlayerFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, erro
|
|||||||
return f(ctx, mv)
|
return f(ctx, mv)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The RoundStatsFunc type is an adapter to allow the use of ordinary
|
||||||
|
// function as RoundStats mutator.
|
||||||
|
type RoundStatsFunc func(context.Context, *ent.RoundStatsMutation) (ent.Value, error)
|
||||||
|
|
||||||
|
// Mutate calls f(ctx, m).
|
||||||
|
func (f RoundStatsFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||||
|
mv, ok := m.(*ent.RoundStatsMutation)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.RoundStatsMutation", m)
|
||||||
|
}
|
||||||
|
return f(ctx, mv)
|
||||||
|
}
|
||||||
|
|
||||||
// The StatsFunc type is an adapter to allow the use of ordinary
|
// The StatsFunc type is an adapter to allow the use of ordinary
|
||||||
// function as Stats mutator.
|
// function as Stats mutator.
|
||||||
type StatsFunc func(context.Context, *ent.StatsMutation) (ent.Value, error)
|
type StatsFunc func(context.Context, *ent.StatsMutation) (ent.Value, error)
|
||||||
|
@@ -33,7 +33,7 @@ var (
|
|||||||
PlayersColumns = []*schema.Column{
|
PlayersColumns = []*schema.Column{
|
||||||
{Name: "id", Type: field.TypeUint64, Increment: true},
|
{Name: "id", Type: field.TypeUint64, Increment: true},
|
||||||
{Name: "name", Type: field.TypeString, Nullable: true},
|
{Name: "name", Type: field.TypeString, Nullable: true},
|
||||||
{Name: "avatar_url", Type: field.TypeString, Nullable: true},
|
{Name: "avatar", Type: field.TypeString, Nullable: true},
|
||||||
{Name: "vanity_url", Type: field.TypeString, Nullable: true},
|
{Name: "vanity_url", Type: field.TypeString, Nullable: true},
|
||||||
{Name: "vanity_url_real", Type: field.TypeString, Nullable: true},
|
{Name: "vanity_url_real", Type: field.TypeString, Nullable: true},
|
||||||
{Name: "vac", Type: field.TypeBool, Default: false},
|
{Name: "vac", Type: field.TypeBool, Default: false},
|
||||||
@@ -50,6 +50,29 @@ var (
|
|||||||
Columns: PlayersColumns,
|
Columns: PlayersColumns,
|
||||||
PrimaryKey: []*schema.Column{PlayersColumns[0]},
|
PrimaryKey: []*schema.Column{PlayersColumns[0]},
|
||||||
}
|
}
|
||||||
|
// RoundStatsColumns holds the columns for the "round_stats" table.
|
||||||
|
RoundStatsColumns = []*schema.Column{
|
||||||
|
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||||
|
{Name: "round", Type: field.TypeUint},
|
||||||
|
{Name: "bank", Type: field.TypeUint},
|
||||||
|
{Name: "equipment", Type: field.TypeUint},
|
||||||
|
{Name: "spent", Type: field.TypeUint},
|
||||||
|
{Name: "stats_round_stats", Type: field.TypeInt, Nullable: true},
|
||||||
|
}
|
||||||
|
// RoundStatsTable holds the schema information for the "round_stats" table.
|
||||||
|
RoundStatsTable = &schema.Table{
|
||||||
|
Name: "round_stats",
|
||||||
|
Columns: RoundStatsColumns,
|
||||||
|
PrimaryKey: []*schema.Column{RoundStatsColumns[0]},
|
||||||
|
ForeignKeys: []*schema.ForeignKey{
|
||||||
|
{
|
||||||
|
Symbol: "round_stats_stats_round_stats",
|
||||||
|
Columns: []*schema.Column{RoundStatsColumns[5]},
|
||||||
|
RefColumns: []*schema.Column{StatsColumns[0]},
|
||||||
|
OnDelete: schema.SetNull,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
// StatsColumns holds the columns for the "stats" table.
|
// StatsColumns holds the columns for the "stats" table.
|
||||||
StatsColumns = []*schema.Column{
|
StatsColumns = []*schema.Column{
|
||||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||||
@@ -165,6 +188,7 @@ var (
|
|||||||
Tables = []*schema.Table{
|
Tables = []*schema.Table{
|
||||||
MatchesTable,
|
MatchesTable,
|
||||||
PlayersTable,
|
PlayersTable,
|
||||||
|
RoundStatsTable,
|
||||||
StatsTable,
|
StatsTable,
|
||||||
WeaponStatsTable,
|
WeaponStatsTable,
|
||||||
PlayerMatchesTable,
|
PlayerMatchesTable,
|
||||||
@@ -172,6 +196,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
RoundStatsTable.ForeignKeys[0].RefTable = StatsTable
|
||||||
StatsTable.ForeignKeys[0].RefTable = MatchesTable
|
StatsTable.ForeignKeys[0].RefTable = MatchesTable
|
||||||
StatsTable.ForeignKeys[1].RefTable = PlayersTable
|
StatsTable.ForeignKeys[1].RefTable = PlayersTable
|
||||||
WeaponStatsTable.ForeignKeys[0].RefTable = StatsTable
|
WeaponStatsTable.ForeignKeys[0].RefTable = StatsTable
|
||||||
|
825
ent/mutation.go
825
ent/mutation.go
@@ -7,6 +7,7 @@ import (
|
|||||||
"csgowtfd/ent/match"
|
"csgowtfd/ent/match"
|
||||||
"csgowtfd/ent/player"
|
"csgowtfd/ent/player"
|
||||||
"csgowtfd/ent/predicate"
|
"csgowtfd/ent/predicate"
|
||||||
|
"csgowtfd/ent/roundstats"
|
||||||
"csgowtfd/ent/stats"
|
"csgowtfd/ent/stats"
|
||||||
"csgowtfd/ent/weaponstats"
|
"csgowtfd/ent/weaponstats"
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -27,6 +28,7 @@ const (
|
|||||||
// Node types.
|
// Node types.
|
||||||
TypeMatch = "Match"
|
TypeMatch = "Match"
|
||||||
TypePlayer = "Player"
|
TypePlayer = "Player"
|
||||||
|
TypeRoundStats = "RoundStats"
|
||||||
TypeStats = "Stats"
|
TypeStats = "Stats"
|
||||||
TypeWeaponStats = "WeaponStats"
|
TypeWeaponStats = "WeaponStats"
|
||||||
)
|
)
|
||||||
@@ -1310,7 +1312,7 @@ type PlayerMutation struct {
|
|||||||
typ string
|
typ string
|
||||||
id *uint64
|
id *uint64
|
||||||
name *string
|
name *string
|
||||||
avatar_url *string
|
avatar *string
|
||||||
vanity_url *string
|
vanity_url *string
|
||||||
vanity_url_real *string
|
vanity_url_real *string
|
||||||
vac *bool
|
vac *bool
|
||||||
@@ -1467,53 +1469,53 @@ func (m *PlayerMutation) ResetName() {
|
|||||||
delete(m.clearedFields, player.FieldName)
|
delete(m.clearedFields, player.FieldName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetAvatarURL sets the "avatar_url" field.
|
// SetAvatar sets the "avatar" field.
|
||||||
func (m *PlayerMutation) SetAvatarURL(s string) {
|
func (m *PlayerMutation) SetAvatar(s string) {
|
||||||
m.avatar_url = &s
|
m.avatar = &s
|
||||||
}
|
}
|
||||||
|
|
||||||
// AvatarURL returns the value of the "avatar_url" field in the mutation.
|
// Avatar returns the value of the "avatar" field in the mutation.
|
||||||
func (m *PlayerMutation) AvatarURL() (r string, exists bool) {
|
func (m *PlayerMutation) Avatar() (r string, exists bool) {
|
||||||
v := m.avatar_url
|
v := m.avatar
|
||||||
if v == nil {
|
if v == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return *v, true
|
return *v, true
|
||||||
}
|
}
|
||||||
|
|
||||||
// OldAvatarURL returns the old "avatar_url" field's value of the Player entity.
|
// OldAvatar returns the old "avatar" field's value of the Player entity.
|
||||||
// If the Player object wasn't provided to the builder, the object is fetched from the database.
|
// 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.
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||||
func (m *PlayerMutation) OldAvatarURL(ctx context.Context) (v string, err error) {
|
func (m *PlayerMutation) OldAvatar(ctx context.Context) (v string, err error) {
|
||||||
if !m.op.Is(OpUpdateOne) {
|
if !m.op.Is(OpUpdateOne) {
|
||||||
return v, fmt.Errorf("OldAvatarURL is only allowed on UpdateOne operations")
|
return v, fmt.Errorf("OldAvatar is only allowed on UpdateOne operations")
|
||||||
}
|
}
|
||||||
if m.id == nil || m.oldValue == nil {
|
if m.id == nil || m.oldValue == nil {
|
||||||
return v, fmt.Errorf("OldAvatarURL requires an ID field in the mutation")
|
return v, fmt.Errorf("OldAvatar requires an ID field in the mutation")
|
||||||
}
|
}
|
||||||
oldValue, err := m.oldValue(ctx)
|
oldValue, err := m.oldValue(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return v, fmt.Errorf("querying old value for OldAvatarURL: %w", err)
|
return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
|
||||||
}
|
}
|
||||||
return oldValue.AvatarURL, nil
|
return oldValue.Avatar, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClearAvatarURL clears the value of the "avatar_url" field.
|
// ClearAvatar clears the value of the "avatar" field.
|
||||||
func (m *PlayerMutation) ClearAvatarURL() {
|
func (m *PlayerMutation) ClearAvatar() {
|
||||||
m.avatar_url = nil
|
m.avatar = nil
|
||||||
m.clearedFields[player.FieldAvatarURL] = struct{}{}
|
m.clearedFields[player.FieldAvatar] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// AvatarURLCleared returns if the "avatar_url" field was cleared in this mutation.
|
// AvatarCleared returns if the "avatar" field was cleared in this mutation.
|
||||||
func (m *PlayerMutation) AvatarURLCleared() bool {
|
func (m *PlayerMutation) AvatarCleared() bool {
|
||||||
_, ok := m.clearedFields[player.FieldAvatarURL]
|
_, ok := m.clearedFields[player.FieldAvatar]
|
||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResetAvatarURL resets all changes to the "avatar_url" field.
|
// ResetAvatar resets all changes to the "avatar" field.
|
||||||
func (m *PlayerMutation) ResetAvatarURL() {
|
func (m *PlayerMutation) ResetAvatar() {
|
||||||
m.avatar_url = nil
|
m.avatar = nil
|
||||||
delete(m.clearedFields, player.FieldAvatarURL)
|
delete(m.clearedFields, player.FieldAvatar)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetVanityURL sets the "vanity_url" field.
|
// SetVanityURL sets the "vanity_url" field.
|
||||||
@@ -2083,8 +2085,8 @@ func (m *PlayerMutation) Fields() []string {
|
|||||||
if m.name != nil {
|
if m.name != nil {
|
||||||
fields = append(fields, player.FieldName)
|
fields = append(fields, player.FieldName)
|
||||||
}
|
}
|
||||||
if m.avatar_url != nil {
|
if m.avatar != nil {
|
||||||
fields = append(fields, player.FieldAvatarURL)
|
fields = append(fields, player.FieldAvatar)
|
||||||
}
|
}
|
||||||
if m.vanity_url != nil {
|
if m.vanity_url != nil {
|
||||||
fields = append(fields, player.FieldVanityURL)
|
fields = append(fields, player.FieldVanityURL)
|
||||||
@@ -2123,8 +2125,8 @@ func (m *PlayerMutation) Field(name string) (ent.Value, bool) {
|
|||||||
switch name {
|
switch name {
|
||||||
case player.FieldName:
|
case player.FieldName:
|
||||||
return m.Name()
|
return m.Name()
|
||||||
case player.FieldAvatarURL:
|
case player.FieldAvatar:
|
||||||
return m.AvatarURL()
|
return m.Avatar()
|
||||||
case player.FieldVanityURL:
|
case player.FieldVanityURL:
|
||||||
return m.VanityURL()
|
return m.VanityURL()
|
||||||
case player.FieldVanityURLReal:
|
case player.FieldVanityURLReal:
|
||||||
@@ -2154,8 +2156,8 @@ func (m *PlayerMutation) OldField(ctx context.Context, name string) (ent.Value,
|
|||||||
switch name {
|
switch name {
|
||||||
case player.FieldName:
|
case player.FieldName:
|
||||||
return m.OldName(ctx)
|
return m.OldName(ctx)
|
||||||
case player.FieldAvatarURL:
|
case player.FieldAvatar:
|
||||||
return m.OldAvatarURL(ctx)
|
return m.OldAvatar(ctx)
|
||||||
case player.FieldVanityURL:
|
case player.FieldVanityURL:
|
||||||
return m.OldVanityURL(ctx)
|
return m.OldVanityURL(ctx)
|
||||||
case player.FieldVanityURLReal:
|
case player.FieldVanityURLReal:
|
||||||
@@ -2190,12 +2192,12 @@ func (m *PlayerMutation) SetField(name string, value ent.Value) error {
|
|||||||
}
|
}
|
||||||
m.SetName(v)
|
m.SetName(v)
|
||||||
return nil
|
return nil
|
||||||
case player.FieldAvatarURL:
|
case player.FieldAvatar:
|
||||||
v, ok := value.(string)
|
v, ok := value.(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||||
}
|
}
|
||||||
m.SetAvatarURL(v)
|
m.SetAvatar(v)
|
||||||
return nil
|
return nil
|
||||||
case player.FieldVanityURL:
|
case player.FieldVanityURL:
|
||||||
v, ok := value.(string)
|
v, ok := value.(string)
|
||||||
@@ -2308,8 +2310,8 @@ func (m *PlayerMutation) ClearedFields() []string {
|
|||||||
if m.FieldCleared(player.FieldName) {
|
if m.FieldCleared(player.FieldName) {
|
||||||
fields = append(fields, player.FieldName)
|
fields = append(fields, player.FieldName)
|
||||||
}
|
}
|
||||||
if m.FieldCleared(player.FieldAvatarURL) {
|
if m.FieldCleared(player.FieldAvatar) {
|
||||||
fields = append(fields, player.FieldAvatarURL)
|
fields = append(fields, player.FieldAvatar)
|
||||||
}
|
}
|
||||||
if m.FieldCleared(player.FieldVanityURL) {
|
if m.FieldCleared(player.FieldVanityURL) {
|
||||||
fields = append(fields, player.FieldVanityURL)
|
fields = append(fields, player.FieldVanityURL)
|
||||||
@@ -2349,8 +2351,8 @@ func (m *PlayerMutation) ClearField(name string) error {
|
|||||||
case player.FieldName:
|
case player.FieldName:
|
||||||
m.ClearName()
|
m.ClearName()
|
||||||
return nil
|
return nil
|
||||||
case player.FieldAvatarURL:
|
case player.FieldAvatar:
|
||||||
m.ClearAvatarURL()
|
m.ClearAvatar()
|
||||||
return nil
|
return nil
|
||||||
case player.FieldVanityURL:
|
case player.FieldVanityURL:
|
||||||
m.ClearVanityURL()
|
m.ClearVanityURL()
|
||||||
@@ -2384,8 +2386,8 @@ func (m *PlayerMutation) ResetField(name string) error {
|
|||||||
case player.FieldName:
|
case player.FieldName:
|
||||||
m.ResetName()
|
m.ResetName()
|
||||||
return nil
|
return nil
|
||||||
case player.FieldAvatarURL:
|
case player.FieldAvatar:
|
||||||
m.ResetAvatarURL()
|
m.ResetAvatar()
|
||||||
return nil
|
return nil
|
||||||
case player.FieldVanityURL:
|
case player.FieldVanityURL:
|
||||||
m.ResetVanityURL()
|
m.ResetVanityURL()
|
||||||
@@ -2528,6 +2530,664 @@ func (m *PlayerMutation) ResetEdge(name string) error {
|
|||||||
return fmt.Errorf("unknown Player edge %s", name)
|
return fmt.Errorf("unknown Player edge %s", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RoundStatsMutation represents an operation that mutates the RoundStats nodes in the graph.
|
||||||
|
type RoundStatsMutation struct {
|
||||||
|
config
|
||||||
|
op Op
|
||||||
|
typ string
|
||||||
|
id *int
|
||||||
|
round *uint
|
||||||
|
addround *uint
|
||||||
|
bank *uint
|
||||||
|
addbank *uint
|
||||||
|
equipment *uint
|
||||||
|
addequipment *uint
|
||||||
|
spent *uint
|
||||||
|
addspent *uint
|
||||||
|
clearedFields map[string]struct{}
|
||||||
|
stat *int
|
||||||
|
clearedstat bool
|
||||||
|
done bool
|
||||||
|
oldValue func(context.Context) (*RoundStats, error)
|
||||||
|
predicates []predicate.RoundStats
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ ent.Mutation = (*RoundStatsMutation)(nil)
|
||||||
|
|
||||||
|
// roundstatsOption allows management of the mutation configuration using functional options.
|
||||||
|
type roundstatsOption func(*RoundStatsMutation)
|
||||||
|
|
||||||
|
// newRoundStatsMutation creates new mutation for the RoundStats entity.
|
||||||
|
func newRoundStatsMutation(c config, op Op, opts ...roundstatsOption) *RoundStatsMutation {
|
||||||
|
m := &RoundStatsMutation{
|
||||||
|
config: c,
|
||||||
|
op: op,
|
||||||
|
typ: TypeRoundStats,
|
||||||
|
clearedFields: make(map[string]struct{}),
|
||||||
|
}
|
||||||
|
for _, opt := range opts {
|
||||||
|
opt(m)
|
||||||
|
}
|
||||||
|
return m
|
||||||
|
}
|
||||||
|
|
||||||
|
// withRoundStatsID sets the ID field of the mutation.
|
||||||
|
func withRoundStatsID(id int) roundstatsOption {
|
||||||
|
return func(m *RoundStatsMutation) {
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
once sync.Once
|
||||||
|
value *RoundStats
|
||||||
|
)
|
||||||
|
m.oldValue = func(ctx context.Context) (*RoundStats, error) {
|
||||||
|
once.Do(func() {
|
||||||
|
if m.done {
|
||||||
|
err = fmt.Errorf("querying old values post mutation is not allowed")
|
||||||
|
} else {
|
||||||
|
value, err = m.Client().RoundStats.Get(ctx, id)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return value, err
|
||||||
|
}
|
||||||
|
m.id = &id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// withRoundStats sets the old RoundStats of the mutation.
|
||||||
|
func withRoundStats(node *RoundStats) roundstatsOption {
|
||||||
|
return func(m *RoundStatsMutation) {
|
||||||
|
m.oldValue = func(context.Context) (*RoundStats, error) {
|
||||||
|
return node, nil
|
||||||
|
}
|
||||||
|
m.id = &node.ID
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Client returns a new `ent.Client` from the mutation. If the mutation was
|
||||||
|
// executed in a transaction (ent.Tx), a transactional client is returned.
|
||||||
|
func (m RoundStatsMutation) Client() *Client {
|
||||||
|
client := &Client{config: m.config}
|
||||||
|
client.init()
|
||||||
|
return client
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tx returns an `ent.Tx` for mutations that were executed in transactions;
|
||||||
|
// it returns an error otherwise.
|
||||||
|
func (m RoundStatsMutation) Tx() (*Tx, error) {
|
||||||
|
if _, ok := m.driver.(*txDriver); !ok {
|
||||||
|
return nil, fmt.Errorf("ent: mutation is not running in a transaction")
|
||||||
|
}
|
||||||
|
tx := &Tx{config: m.config}
|
||||||
|
tx.init()
|
||||||
|
return tx, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 *RoundStatsMutation) ID() (id int, exists bool) {
|
||||||
|
if m.id == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return *m.id, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetRound sets the "round" field.
|
||||||
|
func (m *RoundStatsMutation) SetRound(u uint) {
|
||||||
|
m.round = &u
|
||||||
|
m.addround = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Round returns the value of the "round" field in the mutation.
|
||||||
|
func (m *RoundStatsMutation) Round() (r uint, exists bool) {
|
||||||
|
v := m.round
|
||||||
|
if v == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return *v, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// OldRound returns the old "round" field's value of the RoundStats entity.
|
||||||
|
// If the RoundStats 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 *RoundStatsMutation) OldRound(ctx context.Context) (v uint, err error) {
|
||||||
|
if !m.op.Is(OpUpdateOne) {
|
||||||
|
return v, fmt.Errorf("OldRound is only allowed on UpdateOne operations")
|
||||||
|
}
|
||||||
|
if m.id == nil || m.oldValue == nil {
|
||||||
|
return v, fmt.Errorf("OldRound requires an ID field in the mutation")
|
||||||
|
}
|
||||||
|
oldValue, err := m.oldValue(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return v, fmt.Errorf("querying old value for OldRound: %w", err)
|
||||||
|
}
|
||||||
|
return oldValue.Round, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddRound adds u to the "round" field.
|
||||||
|
func (m *RoundStatsMutation) AddRound(u uint) {
|
||||||
|
if m.addround != nil {
|
||||||
|
*m.addround += u
|
||||||
|
} else {
|
||||||
|
m.addround = &u
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddedRound returns the value that was added to the "round" field in this mutation.
|
||||||
|
func (m *RoundStatsMutation) AddedRound() (r uint, exists bool) {
|
||||||
|
v := m.addround
|
||||||
|
if v == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return *v, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResetRound resets all changes to the "round" field.
|
||||||
|
func (m *RoundStatsMutation) ResetRound() {
|
||||||
|
m.round = nil
|
||||||
|
m.addround = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetBank sets the "bank" field.
|
||||||
|
func (m *RoundStatsMutation) SetBank(u uint) {
|
||||||
|
m.bank = &u
|
||||||
|
m.addbank = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bank returns the value of the "bank" field in the mutation.
|
||||||
|
func (m *RoundStatsMutation) Bank() (r uint, exists bool) {
|
||||||
|
v := m.bank
|
||||||
|
if v == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return *v, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// OldBank returns the old "bank" field's value of the RoundStats entity.
|
||||||
|
// If the RoundStats 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 *RoundStatsMutation) OldBank(ctx context.Context) (v uint, err error) {
|
||||||
|
if !m.op.Is(OpUpdateOne) {
|
||||||
|
return v, fmt.Errorf("OldBank is only allowed on UpdateOne operations")
|
||||||
|
}
|
||||||
|
if m.id == nil || m.oldValue == nil {
|
||||||
|
return v, fmt.Errorf("OldBank requires an ID field in the mutation")
|
||||||
|
}
|
||||||
|
oldValue, err := m.oldValue(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return v, fmt.Errorf("querying old value for OldBank: %w", err)
|
||||||
|
}
|
||||||
|
return oldValue.Bank, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddBank adds u to the "bank" field.
|
||||||
|
func (m *RoundStatsMutation) AddBank(u uint) {
|
||||||
|
if m.addbank != nil {
|
||||||
|
*m.addbank += u
|
||||||
|
} else {
|
||||||
|
m.addbank = &u
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddedBank returns the value that was added to the "bank" field in this mutation.
|
||||||
|
func (m *RoundStatsMutation) AddedBank() (r uint, exists bool) {
|
||||||
|
v := m.addbank
|
||||||
|
if v == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return *v, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResetBank resets all changes to the "bank" field.
|
||||||
|
func (m *RoundStatsMutation) ResetBank() {
|
||||||
|
m.bank = nil
|
||||||
|
m.addbank = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetEquipment sets the "equipment" field.
|
||||||
|
func (m *RoundStatsMutation) SetEquipment(u uint) {
|
||||||
|
m.equipment = &u
|
||||||
|
m.addequipment = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Equipment returns the value of the "equipment" field in the mutation.
|
||||||
|
func (m *RoundStatsMutation) Equipment() (r uint, exists bool) {
|
||||||
|
v := m.equipment
|
||||||
|
if v == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return *v, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// OldEquipment returns the old "equipment" field's value of the RoundStats entity.
|
||||||
|
// If the RoundStats 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 *RoundStatsMutation) OldEquipment(ctx context.Context) (v uint, err error) {
|
||||||
|
if !m.op.Is(OpUpdateOne) {
|
||||||
|
return v, fmt.Errorf("OldEquipment is only allowed on UpdateOne operations")
|
||||||
|
}
|
||||||
|
if m.id == nil || m.oldValue == nil {
|
||||||
|
return v, fmt.Errorf("OldEquipment requires an ID field in the mutation")
|
||||||
|
}
|
||||||
|
oldValue, err := m.oldValue(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return v, fmt.Errorf("querying old value for OldEquipment: %w", err)
|
||||||
|
}
|
||||||
|
return oldValue.Equipment, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddEquipment adds u to the "equipment" field.
|
||||||
|
func (m *RoundStatsMutation) AddEquipment(u uint) {
|
||||||
|
if m.addequipment != nil {
|
||||||
|
*m.addequipment += u
|
||||||
|
} else {
|
||||||
|
m.addequipment = &u
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddedEquipment returns the value that was added to the "equipment" field in this mutation.
|
||||||
|
func (m *RoundStatsMutation) AddedEquipment() (r uint, exists bool) {
|
||||||
|
v := m.addequipment
|
||||||
|
if v == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return *v, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResetEquipment resets all changes to the "equipment" field.
|
||||||
|
func (m *RoundStatsMutation) ResetEquipment() {
|
||||||
|
m.equipment = nil
|
||||||
|
m.addequipment = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetSpent sets the "spent" field.
|
||||||
|
func (m *RoundStatsMutation) SetSpent(u uint) {
|
||||||
|
m.spent = &u
|
||||||
|
m.addspent = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Spent returns the value of the "spent" field in the mutation.
|
||||||
|
func (m *RoundStatsMutation) Spent() (r uint, exists bool) {
|
||||||
|
v := m.spent
|
||||||
|
if v == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return *v, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// OldSpent returns the old "spent" field's value of the RoundStats entity.
|
||||||
|
// If the RoundStats 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 *RoundStatsMutation) OldSpent(ctx context.Context) (v uint, err error) {
|
||||||
|
if !m.op.Is(OpUpdateOne) {
|
||||||
|
return v, fmt.Errorf("OldSpent is only allowed on UpdateOne operations")
|
||||||
|
}
|
||||||
|
if m.id == nil || m.oldValue == nil {
|
||||||
|
return v, fmt.Errorf("OldSpent requires an ID field in the mutation")
|
||||||
|
}
|
||||||
|
oldValue, err := m.oldValue(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return v, fmt.Errorf("querying old value for OldSpent: %w", err)
|
||||||
|
}
|
||||||
|
return oldValue.Spent, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddSpent adds u to the "spent" field.
|
||||||
|
func (m *RoundStatsMutation) AddSpent(u uint) {
|
||||||
|
if m.addspent != nil {
|
||||||
|
*m.addspent += u
|
||||||
|
} else {
|
||||||
|
m.addspent = &u
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddedSpent returns the value that was added to the "spent" field in this mutation.
|
||||||
|
func (m *RoundStatsMutation) AddedSpent() (r uint, exists bool) {
|
||||||
|
v := m.addspent
|
||||||
|
if v == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return *v, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResetSpent resets all changes to the "spent" field.
|
||||||
|
func (m *RoundStatsMutation) ResetSpent() {
|
||||||
|
m.spent = nil
|
||||||
|
m.addspent = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetStatID sets the "stat" edge to the Stats entity by id.
|
||||||
|
func (m *RoundStatsMutation) SetStatID(id int) {
|
||||||
|
m.stat = &id
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearStat clears the "stat" edge to the Stats entity.
|
||||||
|
func (m *RoundStatsMutation) ClearStat() {
|
||||||
|
m.clearedstat = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatCleared reports if the "stat" edge to the Stats entity was cleared.
|
||||||
|
func (m *RoundStatsMutation) StatCleared() bool {
|
||||||
|
return m.clearedstat
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatID returns the "stat" edge ID in the mutation.
|
||||||
|
func (m *RoundStatsMutation) StatID() (id int, exists bool) {
|
||||||
|
if m.stat != nil {
|
||||||
|
return *m.stat, true
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatIDs returns the "stat" edge IDs in the mutation.
|
||||||
|
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
|
||||||
|
// StatID instead. It exists only for internal usage by the builders.
|
||||||
|
func (m *RoundStatsMutation) StatIDs() (ids []int) {
|
||||||
|
if id := m.stat; id != nil {
|
||||||
|
ids = append(ids, *id)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResetStat resets all changes to the "stat" edge.
|
||||||
|
func (m *RoundStatsMutation) ResetStat() {
|
||||||
|
m.stat = nil
|
||||||
|
m.clearedstat = false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the RoundStatsMutation builder.
|
||||||
|
func (m *RoundStatsMutation) Where(ps ...predicate.RoundStats) {
|
||||||
|
m.predicates = append(m.predicates, ps...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Op returns the operation name.
|
||||||
|
func (m *RoundStatsMutation) Op() Op {
|
||||||
|
return m.op
|
||||||
|
}
|
||||||
|
|
||||||
|
// Type returns the node type of this mutation (RoundStats).
|
||||||
|
func (m *RoundStatsMutation) Type() string {
|
||||||
|
return m.typ
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fields returns all fields that were changed during this mutation. Note that in
|
||||||
|
// order to get all numeric fields that were incremented/decremented, call
|
||||||
|
// AddedFields().
|
||||||
|
func (m *RoundStatsMutation) Fields() []string {
|
||||||
|
fields := make([]string, 0, 4)
|
||||||
|
if m.round != nil {
|
||||||
|
fields = append(fields, roundstats.FieldRound)
|
||||||
|
}
|
||||||
|
if m.bank != nil {
|
||||||
|
fields = append(fields, roundstats.FieldBank)
|
||||||
|
}
|
||||||
|
if m.equipment != nil {
|
||||||
|
fields = append(fields, roundstats.FieldEquipment)
|
||||||
|
}
|
||||||
|
if m.spent != nil {
|
||||||
|
fields = append(fields, roundstats.FieldSpent)
|
||||||
|
}
|
||||||
|
return fields
|
||||||
|
}
|
||||||
|
|
||||||
|
// Field returns the value of a field with the given name. The second boolean
|
||||||
|
// return value indicates that this field was not set, or was not defined in the
|
||||||
|
// schema.
|
||||||
|
func (m *RoundStatsMutation) Field(name string) (ent.Value, bool) {
|
||||||
|
switch name {
|
||||||
|
case roundstats.FieldRound:
|
||||||
|
return m.Round()
|
||||||
|
case roundstats.FieldBank:
|
||||||
|
return m.Bank()
|
||||||
|
case roundstats.FieldEquipment:
|
||||||
|
return m.Equipment()
|
||||||
|
case roundstats.FieldSpent:
|
||||||
|
return m.Spent()
|
||||||
|
}
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
|
||||||
|
// OldField returns the old value of the field from the database. An error is
|
||||||
|
// returned if the mutation operation is not UpdateOne, or the query to the
|
||||||
|
// database failed.
|
||||||
|
func (m *RoundStatsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
||||||
|
switch name {
|
||||||
|
case roundstats.FieldRound:
|
||||||
|
return m.OldRound(ctx)
|
||||||
|
case roundstats.FieldBank:
|
||||||
|
return m.OldBank(ctx)
|
||||||
|
case roundstats.FieldEquipment:
|
||||||
|
return m.OldEquipment(ctx)
|
||||||
|
case roundstats.FieldSpent:
|
||||||
|
return m.OldSpent(ctx)
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("unknown RoundStats field %s", name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetField sets the value of a field with the given name. It returns an error if
|
||||||
|
// the field is not defined in the schema, or if the type mismatched the field
|
||||||
|
// type.
|
||||||
|
func (m *RoundStatsMutation) SetField(name string, value ent.Value) error {
|
||||||
|
switch name {
|
||||||
|
case roundstats.FieldRound:
|
||||||
|
v, ok := value.(uint)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||||
|
}
|
||||||
|
m.SetRound(v)
|
||||||
|
return nil
|
||||||
|
case roundstats.FieldBank:
|
||||||
|
v, ok := value.(uint)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||||
|
}
|
||||||
|
m.SetBank(v)
|
||||||
|
return nil
|
||||||
|
case roundstats.FieldEquipment:
|
||||||
|
v, ok := value.(uint)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||||
|
}
|
||||||
|
m.SetEquipment(v)
|
||||||
|
return nil
|
||||||
|
case roundstats.FieldSpent:
|
||||||
|
v, ok := value.(uint)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||||
|
}
|
||||||
|
m.SetSpent(v)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return fmt.Errorf("unknown RoundStats field %s", name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddedFields returns all numeric fields that were incremented/decremented during
|
||||||
|
// this mutation.
|
||||||
|
func (m *RoundStatsMutation) AddedFields() []string {
|
||||||
|
var fields []string
|
||||||
|
if m.addround != nil {
|
||||||
|
fields = append(fields, roundstats.FieldRound)
|
||||||
|
}
|
||||||
|
if m.addbank != nil {
|
||||||
|
fields = append(fields, roundstats.FieldBank)
|
||||||
|
}
|
||||||
|
if m.addequipment != nil {
|
||||||
|
fields = append(fields, roundstats.FieldEquipment)
|
||||||
|
}
|
||||||
|
if m.addspent != nil {
|
||||||
|
fields = append(fields, roundstats.FieldSpent)
|
||||||
|
}
|
||||||
|
return fields
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddedField returns the numeric value that was incremented/decremented on a field
|
||||||
|
// with the given name. The second boolean return value indicates that this field
|
||||||
|
// was not set, or was not defined in the schema.
|
||||||
|
func (m *RoundStatsMutation) AddedField(name string) (ent.Value, bool) {
|
||||||
|
switch name {
|
||||||
|
case roundstats.FieldRound:
|
||||||
|
return m.AddedRound()
|
||||||
|
case roundstats.FieldBank:
|
||||||
|
return m.AddedBank()
|
||||||
|
case roundstats.FieldEquipment:
|
||||||
|
return m.AddedEquipment()
|
||||||
|
case roundstats.FieldSpent:
|
||||||
|
return m.AddedSpent()
|
||||||
|
}
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddField adds the value to the field with the given name. It returns an error if
|
||||||
|
// the field is not defined in the schema, or if the type mismatched the field
|
||||||
|
// type.
|
||||||
|
func (m *RoundStatsMutation) AddField(name string, value ent.Value) error {
|
||||||
|
switch name {
|
||||||
|
case roundstats.FieldRound:
|
||||||
|
v, ok := value.(uint)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||||
|
}
|
||||||
|
m.AddRound(v)
|
||||||
|
return nil
|
||||||
|
case roundstats.FieldBank:
|
||||||
|
v, ok := value.(uint)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||||
|
}
|
||||||
|
m.AddBank(v)
|
||||||
|
return nil
|
||||||
|
case roundstats.FieldEquipment:
|
||||||
|
v, ok := value.(uint)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||||
|
}
|
||||||
|
m.AddEquipment(v)
|
||||||
|
return nil
|
||||||
|
case roundstats.FieldSpent:
|
||||||
|
v, ok := value.(uint)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||||
|
}
|
||||||
|
m.AddSpent(v)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return fmt.Errorf("unknown RoundStats numeric field %s", name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearedFields returns all nullable fields that were cleared during this
|
||||||
|
// mutation.
|
||||||
|
func (m *RoundStatsMutation) ClearedFields() []string {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FieldCleared returns a boolean indicating if a field with the given name was
|
||||||
|
// cleared in this mutation.
|
||||||
|
func (m *RoundStatsMutation) FieldCleared(name string) bool {
|
||||||
|
_, ok := m.clearedFields[name]
|
||||||
|
return ok
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearField clears the value of the field with the given name. It returns an
|
||||||
|
// error if the field is not defined in the schema.
|
||||||
|
func (m *RoundStatsMutation) ClearField(name string) error {
|
||||||
|
return fmt.Errorf("unknown RoundStats nullable field %s", name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResetField resets all changes in the mutation for the field with the given name.
|
||||||
|
// It returns an error if the field is not defined in the schema.
|
||||||
|
func (m *RoundStatsMutation) ResetField(name string) error {
|
||||||
|
switch name {
|
||||||
|
case roundstats.FieldRound:
|
||||||
|
m.ResetRound()
|
||||||
|
return nil
|
||||||
|
case roundstats.FieldBank:
|
||||||
|
m.ResetBank()
|
||||||
|
return nil
|
||||||
|
case roundstats.FieldEquipment:
|
||||||
|
m.ResetEquipment()
|
||||||
|
return nil
|
||||||
|
case roundstats.FieldSpent:
|
||||||
|
m.ResetSpent()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return fmt.Errorf("unknown RoundStats field %s", name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
||||||
|
func (m *RoundStatsMutation) AddedEdges() []string {
|
||||||
|
edges := make([]string, 0, 1)
|
||||||
|
if m.stat != nil {
|
||||||
|
edges = append(edges, roundstats.EdgeStat)
|
||||||
|
}
|
||||||
|
return edges
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
||||||
|
// name in this mutation.
|
||||||
|
func (m *RoundStatsMutation) AddedIDs(name string) []ent.Value {
|
||||||
|
switch name {
|
||||||
|
case roundstats.EdgeStat:
|
||||||
|
if id := m.stat; id != nil {
|
||||||
|
return []ent.Value{*id}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
||||||
|
func (m *RoundStatsMutation) RemovedEdges() []string {
|
||||||
|
edges := make([]string, 0, 1)
|
||||||
|
return edges
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
||||||
|
// the given name in this mutation.
|
||||||
|
func (m *RoundStatsMutation) RemovedIDs(name string) []ent.Value {
|
||||||
|
switch name {
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
||||||
|
func (m *RoundStatsMutation) ClearedEdges() []string {
|
||||||
|
edges := make([]string, 0, 1)
|
||||||
|
if m.clearedstat {
|
||||||
|
edges = append(edges, roundstats.EdgeStat)
|
||||||
|
}
|
||||||
|
return edges
|
||||||
|
}
|
||||||
|
|
||||||
|
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
||||||
|
// was cleared in this mutation.
|
||||||
|
func (m *RoundStatsMutation) EdgeCleared(name string) bool {
|
||||||
|
switch name {
|
||||||
|
case roundstats.EdgeStat:
|
||||||
|
return m.clearedstat
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearEdge clears the value of the edge with the given name. It returns an error
|
||||||
|
// if that edge is not defined in the schema.
|
||||||
|
func (m *RoundStatsMutation) ClearEdge(name string) error {
|
||||||
|
switch name {
|
||||||
|
case roundstats.EdgeStat:
|
||||||
|
m.ClearStat()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return fmt.Errorf("unknown RoundStats unique edge %s", name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResetEdge resets all changes to the edge with the given name in this mutation.
|
||||||
|
// It returns an error if the edge is not defined in the schema.
|
||||||
|
func (m *RoundStatsMutation) ResetEdge(name string) error {
|
||||||
|
switch name {
|
||||||
|
case roundstats.EdgeStat:
|
||||||
|
m.ResetStat()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return fmt.Errorf("unknown RoundStats edge %s", name)
|
||||||
|
}
|
||||||
|
|
||||||
// StatsMutation represents an operation that mutates the Stats nodes in the graph.
|
// StatsMutation represents an operation that mutates the Stats nodes in the graph.
|
||||||
type StatsMutation struct {
|
type StatsMutation struct {
|
||||||
config
|
config
|
||||||
@@ -2614,6 +3274,9 @@ type StatsMutation struct {
|
|||||||
weapon_stats map[int]struct{}
|
weapon_stats map[int]struct{}
|
||||||
removedweapon_stats map[int]struct{}
|
removedweapon_stats map[int]struct{}
|
||||||
clearedweapon_stats bool
|
clearedweapon_stats bool
|
||||||
|
round_stats map[int]struct{}
|
||||||
|
removedround_stats map[int]struct{}
|
||||||
|
clearedround_stats bool
|
||||||
done bool
|
done bool
|
||||||
oldValue func(context.Context) (*Stats, error)
|
oldValue func(context.Context) (*Stats, error)
|
||||||
predicates []predicate.Stats
|
predicates []predicate.Stats
|
||||||
@@ -5378,6 +6041,60 @@ func (m *StatsMutation) ResetWeaponStats() {
|
|||||||
m.removedweapon_stats = nil
|
m.removedweapon_stats = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddRoundStatIDs adds the "round_stats" edge to the RoundStats entity by ids.
|
||||||
|
func (m *StatsMutation) AddRoundStatIDs(ids ...int) {
|
||||||
|
if m.round_stats == nil {
|
||||||
|
m.round_stats = make(map[int]struct{})
|
||||||
|
}
|
||||||
|
for i := range ids {
|
||||||
|
m.round_stats[ids[i]] = struct{}{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearRoundStats clears the "round_stats" edge to the RoundStats entity.
|
||||||
|
func (m *StatsMutation) ClearRoundStats() {
|
||||||
|
m.clearedround_stats = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoundStatsCleared reports if the "round_stats" edge to the RoundStats entity was cleared.
|
||||||
|
func (m *StatsMutation) RoundStatsCleared() bool {
|
||||||
|
return m.clearedround_stats
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveRoundStatIDs removes the "round_stats" edge to the RoundStats entity by IDs.
|
||||||
|
func (m *StatsMutation) RemoveRoundStatIDs(ids ...int) {
|
||||||
|
if m.removedround_stats == nil {
|
||||||
|
m.removedround_stats = make(map[int]struct{})
|
||||||
|
}
|
||||||
|
for i := range ids {
|
||||||
|
delete(m.round_stats, ids[i])
|
||||||
|
m.removedround_stats[ids[i]] = struct{}{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemovedRoundStats returns the removed IDs of the "round_stats" edge to the RoundStats entity.
|
||||||
|
func (m *StatsMutation) RemovedRoundStatsIDs() (ids []int) {
|
||||||
|
for id := range m.removedround_stats {
|
||||||
|
ids = append(ids, id)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoundStatsIDs returns the "round_stats" edge IDs in the mutation.
|
||||||
|
func (m *StatsMutation) RoundStatsIDs() (ids []int) {
|
||||||
|
for id := range m.round_stats {
|
||||||
|
ids = append(ids, id)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResetRoundStats resets all changes to the "round_stats" edge.
|
||||||
|
func (m *StatsMutation) ResetRoundStats() {
|
||||||
|
m.round_stats = nil
|
||||||
|
m.clearedround_stats = false
|
||||||
|
m.removedround_stats = nil
|
||||||
|
}
|
||||||
|
|
||||||
// Where appends a list predicates to the StatsMutation builder.
|
// Where appends a list predicates to the StatsMutation builder.
|
||||||
func (m *StatsMutation) Where(ps ...predicate.Stats) {
|
func (m *StatsMutation) Where(ps ...predicate.Stats) {
|
||||||
m.predicates = append(m.predicates, ps...)
|
m.predicates = append(m.predicates, ps...)
|
||||||
@@ -6760,7 +7477,7 @@ func (m *StatsMutation) ResetField(name string) error {
|
|||||||
|
|
||||||
// AddedEdges returns all edge names that were set/added in this mutation.
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
||||||
func (m *StatsMutation) AddedEdges() []string {
|
func (m *StatsMutation) AddedEdges() []string {
|
||||||
edges := make([]string, 0, 3)
|
edges := make([]string, 0, 4)
|
||||||
if m.matches != nil {
|
if m.matches != nil {
|
||||||
edges = append(edges, stats.EdgeMatches)
|
edges = append(edges, stats.EdgeMatches)
|
||||||
}
|
}
|
||||||
@@ -6770,6 +7487,9 @@ func (m *StatsMutation) AddedEdges() []string {
|
|||||||
if m.weapon_stats != nil {
|
if m.weapon_stats != nil {
|
||||||
edges = append(edges, stats.EdgeWeaponStats)
|
edges = append(edges, stats.EdgeWeaponStats)
|
||||||
}
|
}
|
||||||
|
if m.round_stats != nil {
|
||||||
|
edges = append(edges, stats.EdgeRoundStats)
|
||||||
|
}
|
||||||
return edges
|
return edges
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6791,16 +7511,25 @@ func (m *StatsMutation) AddedIDs(name string) []ent.Value {
|
|||||||
ids = append(ids, id)
|
ids = append(ids, id)
|
||||||
}
|
}
|
||||||
return ids
|
return ids
|
||||||
|
case stats.EdgeRoundStats:
|
||||||
|
ids := make([]ent.Value, 0, len(m.round_stats))
|
||||||
|
for id := range m.round_stats {
|
||||||
|
ids = append(ids, id)
|
||||||
|
}
|
||||||
|
return ids
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemovedEdges returns all edge names that were removed in this mutation.
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
||||||
func (m *StatsMutation) RemovedEdges() []string {
|
func (m *StatsMutation) RemovedEdges() []string {
|
||||||
edges := make([]string, 0, 3)
|
edges := make([]string, 0, 4)
|
||||||
if m.removedweapon_stats != nil {
|
if m.removedweapon_stats != nil {
|
||||||
edges = append(edges, stats.EdgeWeaponStats)
|
edges = append(edges, stats.EdgeWeaponStats)
|
||||||
}
|
}
|
||||||
|
if m.removedround_stats != nil {
|
||||||
|
edges = append(edges, stats.EdgeRoundStats)
|
||||||
|
}
|
||||||
return edges
|
return edges
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6814,13 +7543,19 @@ func (m *StatsMutation) RemovedIDs(name string) []ent.Value {
|
|||||||
ids = append(ids, id)
|
ids = append(ids, id)
|
||||||
}
|
}
|
||||||
return ids
|
return ids
|
||||||
|
case stats.EdgeRoundStats:
|
||||||
|
ids := make([]ent.Value, 0, len(m.removedround_stats))
|
||||||
|
for id := range m.removedround_stats {
|
||||||
|
ids = append(ids, id)
|
||||||
|
}
|
||||||
|
return ids
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClearedEdges returns all edge names that were cleared in this mutation.
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
||||||
func (m *StatsMutation) ClearedEdges() []string {
|
func (m *StatsMutation) ClearedEdges() []string {
|
||||||
edges := make([]string, 0, 3)
|
edges := make([]string, 0, 4)
|
||||||
if m.clearedmatches {
|
if m.clearedmatches {
|
||||||
edges = append(edges, stats.EdgeMatches)
|
edges = append(edges, stats.EdgeMatches)
|
||||||
}
|
}
|
||||||
@@ -6830,6 +7565,9 @@ func (m *StatsMutation) ClearedEdges() []string {
|
|||||||
if m.clearedweapon_stats {
|
if m.clearedweapon_stats {
|
||||||
edges = append(edges, stats.EdgeWeaponStats)
|
edges = append(edges, stats.EdgeWeaponStats)
|
||||||
}
|
}
|
||||||
|
if m.clearedround_stats {
|
||||||
|
edges = append(edges, stats.EdgeRoundStats)
|
||||||
|
}
|
||||||
return edges
|
return edges
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6843,6 +7581,8 @@ func (m *StatsMutation) EdgeCleared(name string) bool {
|
|||||||
return m.clearedplayers
|
return m.clearedplayers
|
||||||
case stats.EdgeWeaponStats:
|
case stats.EdgeWeaponStats:
|
||||||
return m.clearedweapon_stats
|
return m.clearedweapon_stats
|
||||||
|
case stats.EdgeRoundStats:
|
||||||
|
return m.clearedround_stats
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -6874,6 +7614,9 @@ func (m *StatsMutation) ResetEdge(name string) error {
|
|||||||
case stats.EdgeWeaponStats:
|
case stats.EdgeWeaponStats:
|
||||||
m.ResetWeaponStats()
|
m.ResetWeaponStats()
|
||||||
return nil
|
return nil
|
||||||
|
case stats.EdgeRoundStats:
|
||||||
|
m.ResetRoundStats()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
return fmt.Errorf("unknown Stats edge %s", name)
|
return fmt.Errorf("unknown Stats edge %s", name)
|
||||||
}
|
}
|
||||||
|
@@ -18,8 +18,8 @@ type Player struct {
|
|||||||
ID uint64 `json:"steamid,string"`
|
ID uint64 `json:"steamid,string"`
|
||||||
// Name holds the value of the "name" field.
|
// Name holds the value of the "name" field.
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
// AvatarURL holds the value of the "avatar_url" field.
|
// Avatar holds the value of the "avatar" field.
|
||||||
AvatarURL string `json:"avatar_url,omitempty"`
|
Avatar string `json:"avatar,omitempty"`
|
||||||
// VanityURL holds the value of the "vanity_url" field.
|
// VanityURL holds the value of the "vanity_url" field.
|
||||||
VanityURL string `json:"vanity_url,omitempty"`
|
VanityURL string `json:"vanity_url,omitempty"`
|
||||||
// VanityURLReal holds the value of the "vanity_url_real" field.
|
// VanityURLReal holds the value of the "vanity_url_real" field.
|
||||||
@@ -81,7 +81,7 @@ func (*Player) scanValues(columns []string) ([]interface{}, error) {
|
|||||||
values[i] = new(sql.NullBool)
|
values[i] = new(sql.NullBool)
|
||||||
case player.FieldID, player.FieldVacCount:
|
case player.FieldID, player.FieldVacCount:
|
||||||
values[i] = new(sql.NullInt64)
|
values[i] = new(sql.NullInt64)
|
||||||
case player.FieldName, player.FieldAvatarURL, player.FieldVanityURL, player.FieldVanityURLReal, player.FieldAuthCode:
|
case player.FieldName, player.FieldAvatar, player.FieldVanityURL, player.FieldVanityURLReal, player.FieldAuthCode:
|
||||||
values[i] = new(sql.NullString)
|
values[i] = new(sql.NullString)
|
||||||
case player.FieldVacDate, player.FieldSteamUpdated, player.FieldSharecodeUpdated, player.FieldProfileCreated:
|
case player.FieldVacDate, player.FieldSteamUpdated, player.FieldSharecodeUpdated, player.FieldProfileCreated:
|
||||||
values[i] = new(sql.NullTime)
|
values[i] = new(sql.NullTime)
|
||||||
@@ -112,11 +112,11 @@ func (pl *Player) assignValues(columns []string, values []interface{}) error {
|
|||||||
} else if value.Valid {
|
} else if value.Valid {
|
||||||
pl.Name = value.String
|
pl.Name = value.String
|
||||||
}
|
}
|
||||||
case player.FieldAvatarURL:
|
case player.FieldAvatar:
|
||||||
if value, ok := values[i].(*sql.NullString); !ok {
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
return fmt.Errorf("unexpected type %T for field avatar_url", values[i])
|
return fmt.Errorf("unexpected type %T for field avatar", values[i])
|
||||||
} else if value.Valid {
|
} else if value.Valid {
|
||||||
pl.AvatarURL = value.String
|
pl.Avatar = value.String
|
||||||
}
|
}
|
||||||
case player.FieldVanityURL:
|
case player.FieldVanityURL:
|
||||||
if value, ok := values[i].(*sql.NullString); !ok {
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
@@ -212,8 +212,8 @@ func (pl *Player) String() string {
|
|||||||
builder.WriteString(fmt.Sprintf("id=%v", pl.ID))
|
builder.WriteString(fmt.Sprintf("id=%v", pl.ID))
|
||||||
builder.WriteString(", name=")
|
builder.WriteString(", name=")
|
||||||
builder.WriteString(pl.Name)
|
builder.WriteString(pl.Name)
|
||||||
builder.WriteString(", avatar_url=")
|
builder.WriteString(", avatar=")
|
||||||
builder.WriteString(pl.AvatarURL)
|
builder.WriteString(pl.Avatar)
|
||||||
builder.WriteString(", vanity_url=")
|
builder.WriteString(", vanity_url=")
|
||||||
builder.WriteString(pl.VanityURL)
|
builder.WriteString(pl.VanityURL)
|
||||||
builder.WriteString(", vanity_url_real=")
|
builder.WriteString(", vanity_url_real=")
|
||||||
|
@@ -13,8 +13,8 @@ const (
|
|||||||
FieldID = "id"
|
FieldID = "id"
|
||||||
// FieldName holds the string denoting the name field in the database.
|
// FieldName holds the string denoting the name field in the database.
|
||||||
FieldName = "name"
|
FieldName = "name"
|
||||||
// FieldAvatarURL holds the string denoting the avatar_url field in the database.
|
// FieldAvatar holds the string denoting the avatar field in the database.
|
||||||
FieldAvatarURL = "avatar_url"
|
FieldAvatar = "avatar"
|
||||||
// FieldVanityURL holds the string denoting the vanity_url field in the database.
|
// FieldVanityURL holds the string denoting the vanity_url field in the database.
|
||||||
FieldVanityURL = "vanity_url"
|
FieldVanityURL = "vanity_url"
|
||||||
// FieldVanityURLReal holds the string denoting the vanity_url_real field in the database.
|
// FieldVanityURLReal holds the string denoting the vanity_url_real field in the database.
|
||||||
@@ -57,7 +57,7 @@ const (
|
|||||||
var Columns = []string{
|
var Columns = []string{
|
||||||
FieldID,
|
FieldID,
|
||||||
FieldName,
|
FieldName,
|
||||||
FieldAvatarURL,
|
FieldAvatar,
|
||||||
FieldVanityURL,
|
FieldVanityURL,
|
||||||
FieldVanityURLReal,
|
FieldVanityURLReal,
|
||||||
FieldVac,
|
FieldVac,
|
||||||
|
@@ -100,10 +100,10 @@ func Name(v string) predicate.Player {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// AvatarURL applies equality check predicate on the "avatar_url" field. It's identical to AvatarURLEQ.
|
// Avatar applies equality check predicate on the "avatar" field. It's identical to AvatarEQ.
|
||||||
func AvatarURL(v string) predicate.Player {
|
func Avatar(v string) predicate.Player {
|
||||||
return predicate.Player(func(s *sql.Selector) {
|
return predicate.Player(func(s *sql.Selector) {
|
||||||
s.Where(sql.EQ(s.C(FieldAvatarURL), v))
|
s.Where(sql.EQ(s.C(FieldAvatar), v))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,22 +295,22 @@ func NameContainsFold(v string) predicate.Player {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// AvatarURLEQ applies the EQ predicate on the "avatar_url" field.
|
// AvatarEQ applies the EQ predicate on the "avatar" field.
|
||||||
func AvatarURLEQ(v string) predicate.Player {
|
func AvatarEQ(v string) predicate.Player {
|
||||||
return predicate.Player(func(s *sql.Selector) {
|
return predicate.Player(func(s *sql.Selector) {
|
||||||
s.Where(sql.EQ(s.C(FieldAvatarURL), v))
|
s.Where(sql.EQ(s.C(FieldAvatar), v))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// AvatarURLNEQ applies the NEQ predicate on the "avatar_url" field.
|
// AvatarNEQ applies the NEQ predicate on the "avatar" field.
|
||||||
func AvatarURLNEQ(v string) predicate.Player {
|
func AvatarNEQ(v string) predicate.Player {
|
||||||
return predicate.Player(func(s *sql.Selector) {
|
return predicate.Player(func(s *sql.Selector) {
|
||||||
s.Where(sql.NEQ(s.C(FieldAvatarURL), v))
|
s.Where(sql.NEQ(s.C(FieldAvatar), v))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// AvatarURLIn applies the In predicate on the "avatar_url" field.
|
// AvatarIn applies the In predicate on the "avatar" field.
|
||||||
func AvatarURLIn(vs ...string) predicate.Player {
|
func AvatarIn(vs ...string) predicate.Player {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]interface{}, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
@@ -322,12 +322,12 @@ func AvatarURLIn(vs ...string) predicate.Player {
|
|||||||
s.Where(sql.False())
|
s.Where(sql.False())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
s.Where(sql.In(s.C(FieldAvatarURL), v...))
|
s.Where(sql.In(s.C(FieldAvatar), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// AvatarURLNotIn applies the NotIn predicate on the "avatar_url" field.
|
// AvatarNotIn applies the NotIn predicate on the "avatar" field.
|
||||||
func AvatarURLNotIn(vs ...string) predicate.Player {
|
func AvatarNotIn(vs ...string) predicate.Player {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]interface{}, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
@@ -339,84 +339,84 @@ func AvatarURLNotIn(vs ...string) predicate.Player {
|
|||||||
s.Where(sql.False())
|
s.Where(sql.False())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
s.Where(sql.NotIn(s.C(FieldAvatarURL), v...))
|
s.Where(sql.NotIn(s.C(FieldAvatar), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// AvatarURLGT applies the GT predicate on the "avatar_url" field.
|
// AvatarGT applies the GT predicate on the "avatar" field.
|
||||||
func AvatarURLGT(v string) predicate.Player {
|
func AvatarGT(v string) predicate.Player {
|
||||||
return predicate.Player(func(s *sql.Selector) {
|
return predicate.Player(func(s *sql.Selector) {
|
||||||
s.Where(sql.GT(s.C(FieldAvatarURL), v))
|
s.Where(sql.GT(s.C(FieldAvatar), v))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// AvatarURLGTE applies the GTE predicate on the "avatar_url" field.
|
// AvatarGTE applies the GTE predicate on the "avatar" field.
|
||||||
func AvatarURLGTE(v string) predicate.Player {
|
func AvatarGTE(v string) predicate.Player {
|
||||||
return predicate.Player(func(s *sql.Selector) {
|
return predicate.Player(func(s *sql.Selector) {
|
||||||
s.Where(sql.GTE(s.C(FieldAvatarURL), v))
|
s.Where(sql.GTE(s.C(FieldAvatar), v))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// AvatarURLLT applies the LT predicate on the "avatar_url" field.
|
// AvatarLT applies the LT predicate on the "avatar" field.
|
||||||
func AvatarURLLT(v string) predicate.Player {
|
func AvatarLT(v string) predicate.Player {
|
||||||
return predicate.Player(func(s *sql.Selector) {
|
return predicate.Player(func(s *sql.Selector) {
|
||||||
s.Where(sql.LT(s.C(FieldAvatarURL), v))
|
s.Where(sql.LT(s.C(FieldAvatar), v))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// AvatarURLLTE applies the LTE predicate on the "avatar_url" field.
|
// AvatarLTE applies the LTE predicate on the "avatar" field.
|
||||||
func AvatarURLLTE(v string) predicate.Player {
|
func AvatarLTE(v string) predicate.Player {
|
||||||
return predicate.Player(func(s *sql.Selector) {
|
return predicate.Player(func(s *sql.Selector) {
|
||||||
s.Where(sql.LTE(s.C(FieldAvatarURL), v))
|
s.Where(sql.LTE(s.C(FieldAvatar), v))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// AvatarURLContains applies the Contains predicate on the "avatar_url" field.
|
// AvatarContains applies the Contains predicate on the "avatar" field.
|
||||||
func AvatarURLContains(v string) predicate.Player {
|
func AvatarContains(v string) predicate.Player {
|
||||||
return predicate.Player(func(s *sql.Selector) {
|
return predicate.Player(func(s *sql.Selector) {
|
||||||
s.Where(sql.Contains(s.C(FieldAvatarURL), v))
|
s.Where(sql.Contains(s.C(FieldAvatar), v))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// AvatarURLHasPrefix applies the HasPrefix predicate on the "avatar_url" field.
|
// AvatarHasPrefix applies the HasPrefix predicate on the "avatar" field.
|
||||||
func AvatarURLHasPrefix(v string) predicate.Player {
|
func AvatarHasPrefix(v string) predicate.Player {
|
||||||
return predicate.Player(func(s *sql.Selector) {
|
return predicate.Player(func(s *sql.Selector) {
|
||||||
s.Where(sql.HasPrefix(s.C(FieldAvatarURL), v))
|
s.Where(sql.HasPrefix(s.C(FieldAvatar), v))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// AvatarURLHasSuffix applies the HasSuffix predicate on the "avatar_url" field.
|
// AvatarHasSuffix applies the HasSuffix predicate on the "avatar" field.
|
||||||
func AvatarURLHasSuffix(v string) predicate.Player {
|
func AvatarHasSuffix(v string) predicate.Player {
|
||||||
return predicate.Player(func(s *sql.Selector) {
|
return predicate.Player(func(s *sql.Selector) {
|
||||||
s.Where(sql.HasSuffix(s.C(FieldAvatarURL), v))
|
s.Where(sql.HasSuffix(s.C(FieldAvatar), v))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// AvatarURLIsNil applies the IsNil predicate on the "avatar_url" field.
|
// AvatarIsNil applies the IsNil predicate on the "avatar" field.
|
||||||
func AvatarURLIsNil() predicate.Player {
|
func AvatarIsNil() predicate.Player {
|
||||||
return predicate.Player(func(s *sql.Selector) {
|
return predicate.Player(func(s *sql.Selector) {
|
||||||
s.Where(sql.IsNull(s.C(FieldAvatarURL)))
|
s.Where(sql.IsNull(s.C(FieldAvatar)))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// AvatarURLNotNil applies the NotNil predicate on the "avatar_url" field.
|
// AvatarNotNil applies the NotNil predicate on the "avatar" field.
|
||||||
func AvatarURLNotNil() predicate.Player {
|
func AvatarNotNil() predicate.Player {
|
||||||
return predicate.Player(func(s *sql.Selector) {
|
return predicate.Player(func(s *sql.Selector) {
|
||||||
s.Where(sql.NotNull(s.C(FieldAvatarURL)))
|
s.Where(sql.NotNull(s.C(FieldAvatar)))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// AvatarURLEqualFold applies the EqualFold predicate on the "avatar_url" field.
|
// AvatarEqualFold applies the EqualFold predicate on the "avatar" field.
|
||||||
func AvatarURLEqualFold(v string) predicate.Player {
|
func AvatarEqualFold(v string) predicate.Player {
|
||||||
return predicate.Player(func(s *sql.Selector) {
|
return predicate.Player(func(s *sql.Selector) {
|
||||||
s.Where(sql.EqualFold(s.C(FieldAvatarURL), v))
|
s.Where(sql.EqualFold(s.C(FieldAvatar), v))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// AvatarURLContainsFold applies the ContainsFold predicate on the "avatar_url" field.
|
// AvatarContainsFold applies the ContainsFold predicate on the "avatar" field.
|
||||||
func AvatarURLContainsFold(v string) predicate.Player {
|
func AvatarContainsFold(v string) predicate.Player {
|
||||||
return predicate.Player(func(s *sql.Selector) {
|
return predicate.Player(func(s *sql.Selector) {
|
||||||
s.Where(sql.ContainsFold(s.C(FieldAvatarURL), v))
|
s.Where(sql.ContainsFold(s.C(FieldAvatar), v))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -36,16 +36,16 @@ func (pc *PlayerCreate) SetNillableName(s *string) *PlayerCreate {
|
|||||||
return pc
|
return pc
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetAvatarURL sets the "avatar_url" field.
|
// SetAvatar sets the "avatar" field.
|
||||||
func (pc *PlayerCreate) SetAvatarURL(s string) *PlayerCreate {
|
func (pc *PlayerCreate) SetAvatar(s string) *PlayerCreate {
|
||||||
pc.mutation.SetAvatarURL(s)
|
pc.mutation.SetAvatar(s)
|
||||||
return pc
|
return pc
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetNillableAvatarURL sets the "avatar_url" field if the given value is not nil.
|
// SetNillableAvatar sets the "avatar" field if the given value is not nil.
|
||||||
func (pc *PlayerCreate) SetNillableAvatarURL(s *string) *PlayerCreate {
|
func (pc *PlayerCreate) SetNillableAvatar(s *string) *PlayerCreate {
|
||||||
if s != nil {
|
if s != nil {
|
||||||
pc.SetAvatarURL(*s)
|
pc.SetAvatar(*s)
|
||||||
}
|
}
|
||||||
return pc
|
return pc
|
||||||
}
|
}
|
||||||
@@ -342,13 +342,13 @@ func (pc *PlayerCreate) createSpec() (*Player, *sqlgraph.CreateSpec) {
|
|||||||
})
|
})
|
||||||
_node.Name = value
|
_node.Name = value
|
||||||
}
|
}
|
||||||
if value, ok := pc.mutation.AvatarURL(); ok {
|
if value, ok := pc.mutation.Avatar(); ok {
|
||||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||||
Type: field.TypeString,
|
Type: field.TypeString,
|
||||||
Value: value,
|
Value: value,
|
||||||
Column: player.FieldAvatarURL,
|
Column: player.FieldAvatar,
|
||||||
})
|
})
|
||||||
_node.AvatarURL = value
|
_node.Avatar = value
|
||||||
}
|
}
|
||||||
if value, ok := pc.mutation.VanityURL(); ok {
|
if value, ok := pc.mutation.VanityURL(); ok {
|
||||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||||
|
@@ -49,23 +49,23 @@ func (pu *PlayerUpdate) ClearName() *PlayerUpdate {
|
|||||||
return pu
|
return pu
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetAvatarURL sets the "avatar_url" field.
|
// SetAvatar sets the "avatar" field.
|
||||||
func (pu *PlayerUpdate) SetAvatarURL(s string) *PlayerUpdate {
|
func (pu *PlayerUpdate) SetAvatar(s string) *PlayerUpdate {
|
||||||
pu.mutation.SetAvatarURL(s)
|
pu.mutation.SetAvatar(s)
|
||||||
return pu
|
return pu
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetNillableAvatarURL sets the "avatar_url" field if the given value is not nil.
|
// SetNillableAvatar sets the "avatar" field if the given value is not nil.
|
||||||
func (pu *PlayerUpdate) SetNillableAvatarURL(s *string) *PlayerUpdate {
|
func (pu *PlayerUpdate) SetNillableAvatar(s *string) *PlayerUpdate {
|
||||||
if s != nil {
|
if s != nil {
|
||||||
pu.SetAvatarURL(*s)
|
pu.SetAvatar(*s)
|
||||||
}
|
}
|
||||||
return pu
|
return pu
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClearAvatarURL clears the value of the "avatar_url" field.
|
// ClearAvatar clears the value of the "avatar" field.
|
||||||
func (pu *PlayerUpdate) ClearAvatarURL() *PlayerUpdate {
|
func (pu *PlayerUpdate) ClearAvatar() *PlayerUpdate {
|
||||||
pu.mutation.ClearAvatarURL()
|
pu.mutation.ClearAvatar()
|
||||||
return pu
|
return pu
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -406,17 +406,17 @@ func (pu *PlayerUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|||||||
Column: player.FieldName,
|
Column: player.FieldName,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if value, ok := pu.mutation.AvatarURL(); ok {
|
if value, ok := pu.mutation.Avatar(); ok {
|
||||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||||
Type: field.TypeString,
|
Type: field.TypeString,
|
||||||
Value: value,
|
Value: value,
|
||||||
Column: player.FieldAvatarURL,
|
Column: player.FieldAvatar,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if pu.mutation.AvatarURLCleared() {
|
if pu.mutation.AvatarCleared() {
|
||||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||||
Type: field.TypeString,
|
Type: field.TypeString,
|
||||||
Column: player.FieldAvatarURL,
|
Column: player.FieldAvatar,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if value, ok := pu.mutation.VanityURL(); ok {
|
if value, ok := pu.mutation.VanityURL(); ok {
|
||||||
@@ -678,23 +678,23 @@ func (puo *PlayerUpdateOne) ClearName() *PlayerUpdateOne {
|
|||||||
return puo
|
return puo
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetAvatarURL sets the "avatar_url" field.
|
// SetAvatar sets the "avatar" field.
|
||||||
func (puo *PlayerUpdateOne) SetAvatarURL(s string) *PlayerUpdateOne {
|
func (puo *PlayerUpdateOne) SetAvatar(s string) *PlayerUpdateOne {
|
||||||
puo.mutation.SetAvatarURL(s)
|
puo.mutation.SetAvatar(s)
|
||||||
return puo
|
return puo
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetNillableAvatarURL sets the "avatar_url" field if the given value is not nil.
|
// SetNillableAvatar sets the "avatar" field if the given value is not nil.
|
||||||
func (puo *PlayerUpdateOne) SetNillableAvatarURL(s *string) *PlayerUpdateOne {
|
func (puo *PlayerUpdateOne) SetNillableAvatar(s *string) *PlayerUpdateOne {
|
||||||
if s != nil {
|
if s != nil {
|
||||||
puo.SetAvatarURL(*s)
|
puo.SetAvatar(*s)
|
||||||
}
|
}
|
||||||
return puo
|
return puo
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClearAvatarURL clears the value of the "avatar_url" field.
|
// ClearAvatar clears the value of the "avatar" field.
|
||||||
func (puo *PlayerUpdateOne) ClearAvatarURL() *PlayerUpdateOne {
|
func (puo *PlayerUpdateOne) ClearAvatar() *PlayerUpdateOne {
|
||||||
puo.mutation.ClearAvatarURL()
|
puo.mutation.ClearAvatar()
|
||||||
return puo
|
return puo
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1059,17 +1059,17 @@ func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err err
|
|||||||
Column: player.FieldName,
|
Column: player.FieldName,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if value, ok := puo.mutation.AvatarURL(); ok {
|
if value, ok := puo.mutation.Avatar(); ok {
|
||||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||||
Type: field.TypeString,
|
Type: field.TypeString,
|
||||||
Value: value,
|
Value: value,
|
||||||
Column: player.FieldAvatarURL,
|
Column: player.FieldAvatar,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if puo.mutation.AvatarURLCleared() {
|
if puo.mutation.AvatarCleared() {
|
||||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||||
Type: field.TypeString,
|
Type: field.TypeString,
|
||||||
Column: player.FieldAvatarURL,
|
Column: player.FieldAvatar,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if value, ok := puo.mutation.VanityURL(); ok {
|
if value, ok := puo.mutation.VanityURL(); ok {
|
||||||
|
@@ -12,6 +12,9 @@ type Match func(*sql.Selector)
|
|||||||
// Player is the predicate function for player builders.
|
// Player is the predicate function for player builders.
|
||||||
type Player func(*sql.Selector)
|
type Player func(*sql.Selector)
|
||||||
|
|
||||||
|
// RoundStats is the predicate function for roundstats builders.
|
||||||
|
type RoundStats func(*sql.Selector)
|
||||||
|
|
||||||
// Stats is the predicate function for stats builders.
|
// Stats is the predicate function for stats builders.
|
||||||
type Stats func(*sql.Selector)
|
type Stats func(*sql.Selector)
|
||||||
|
|
||||||
|
169
ent/roundstats.go
Normal file
169
ent/roundstats.go
Normal file
@@ -0,0 +1,169 @@
|
|||||||
|
// Code generated by entc, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"csgowtfd/ent/roundstats"
|
||||||
|
"csgowtfd/ent/stats"
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RoundStats is the model entity for the RoundStats schema.
|
||||||
|
type RoundStats struct {
|
||||||
|
config `json:"-"`
|
||||||
|
// ID of the ent.
|
||||||
|
ID int `json:"id,omitempty"`
|
||||||
|
// Round holds the value of the "round" field.
|
||||||
|
Round uint `json:"round,omitempty"`
|
||||||
|
// Bank holds the value of the "bank" field.
|
||||||
|
Bank uint `json:"bank,omitempty"`
|
||||||
|
// Equipment holds the value of the "equipment" field.
|
||||||
|
Equipment uint `json:"equipment,omitempty"`
|
||||||
|
// Spent holds the value of the "spent" field.
|
||||||
|
Spent uint `json:"spent,omitempty"`
|
||||||
|
// Edges holds the relations/edges for other nodes in the graph.
|
||||||
|
// The values are being populated by the RoundStatsQuery when eager-loading is set.
|
||||||
|
Edges RoundStatsEdges `json:"edges"`
|
||||||
|
stats_round_stats *int
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoundStatsEdges holds the relations/edges for other nodes in the graph.
|
||||||
|
type RoundStatsEdges struct {
|
||||||
|
// Stat holds the value of the stat edge.
|
||||||
|
Stat *Stats `json:"stat,omitempty"`
|
||||||
|
// loadedTypes holds the information for reporting if a
|
||||||
|
// type was loaded (or requested) in eager-loading or not.
|
||||||
|
loadedTypes [1]bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatOrErr returns the Stat value or an error if the edge
|
||||||
|
// was not loaded in eager-loading, or loaded but was not found.
|
||||||
|
func (e RoundStatsEdges) StatOrErr() (*Stats, error) {
|
||||||
|
if e.loadedTypes[0] {
|
||||||
|
if e.Stat == nil {
|
||||||
|
// The edge stat was loaded in eager-loading,
|
||||||
|
// but was not found.
|
||||||
|
return nil, &NotFoundError{label: stats.Label}
|
||||||
|
}
|
||||||
|
return e.Stat, nil
|
||||||
|
}
|
||||||
|
return nil, &NotLoadedError{edge: "stat"}
|
||||||
|
}
|
||||||
|
|
||||||
|
// scanValues returns the types for scanning values from sql.Rows.
|
||||||
|
func (*RoundStats) scanValues(columns []string) ([]interface{}, error) {
|
||||||
|
values := make([]interface{}, len(columns))
|
||||||
|
for i := range columns {
|
||||||
|
switch columns[i] {
|
||||||
|
case roundstats.FieldID, roundstats.FieldRound, roundstats.FieldBank, roundstats.FieldEquipment, roundstats.FieldSpent:
|
||||||
|
values[i] = new(sql.NullInt64)
|
||||||
|
case roundstats.ForeignKeys[0]: // stats_round_stats
|
||||||
|
values[i] = new(sql.NullInt64)
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("unexpected column %q for type RoundStats", columns[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return values, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||||
|
// to the RoundStats fields.
|
||||||
|
func (rs *RoundStats) assignValues(columns []string, values []interface{}) error {
|
||||||
|
if m, n := len(values), len(columns); m < n {
|
||||||
|
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||||
|
}
|
||||||
|
for i := range columns {
|
||||||
|
switch columns[i] {
|
||||||
|
case roundstats.FieldID:
|
||||||
|
value, ok := values[i].(*sql.NullInt64)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field id", value)
|
||||||
|
}
|
||||||
|
rs.ID = int(value.Int64)
|
||||||
|
case roundstats.FieldRound:
|
||||||
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field round", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
rs.Round = uint(value.Int64)
|
||||||
|
}
|
||||||
|
case roundstats.FieldBank:
|
||||||
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field bank", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
rs.Bank = uint(value.Int64)
|
||||||
|
}
|
||||||
|
case roundstats.FieldEquipment:
|
||||||
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field equipment", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
rs.Equipment = uint(value.Int64)
|
||||||
|
}
|
||||||
|
case roundstats.FieldSpent:
|
||||||
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field spent", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
rs.Spent = uint(value.Int64)
|
||||||
|
}
|
||||||
|
case roundstats.ForeignKeys[0]:
|
||||||
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for edge-field stats_round_stats", value)
|
||||||
|
} else if value.Valid {
|
||||||
|
rs.stats_round_stats = new(int)
|
||||||
|
*rs.stats_round_stats = int(value.Int64)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryStat queries the "stat" edge of the RoundStats entity.
|
||||||
|
func (rs *RoundStats) QueryStat() *StatsQuery {
|
||||||
|
return (&RoundStatsClient{config: rs.config}).QueryStat(rs)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update returns a builder for updating this RoundStats.
|
||||||
|
// Note that you need to call RoundStats.Unwrap() before calling this method if this RoundStats
|
||||||
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||||
|
func (rs *RoundStats) Update() *RoundStatsUpdateOne {
|
||||||
|
return (&RoundStatsClient{config: rs.config}).UpdateOne(rs)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unwrap unwraps the RoundStats entity that was returned from a transaction after it was closed,
|
||||||
|
// so that all future queries will be executed through the driver which created the transaction.
|
||||||
|
func (rs *RoundStats) Unwrap() *RoundStats {
|
||||||
|
tx, ok := rs.config.driver.(*txDriver)
|
||||||
|
if !ok {
|
||||||
|
panic("ent: RoundStats is not a transactional entity")
|
||||||
|
}
|
||||||
|
rs.config.driver = tx.drv
|
||||||
|
return rs
|
||||||
|
}
|
||||||
|
|
||||||
|
// String implements the fmt.Stringer.
|
||||||
|
func (rs *RoundStats) String() string {
|
||||||
|
var builder strings.Builder
|
||||||
|
builder.WriteString("RoundStats(")
|
||||||
|
builder.WriteString(fmt.Sprintf("id=%v", rs.ID))
|
||||||
|
builder.WriteString(", round=")
|
||||||
|
builder.WriteString(fmt.Sprintf("%v", rs.Round))
|
||||||
|
builder.WriteString(", bank=")
|
||||||
|
builder.WriteString(fmt.Sprintf("%v", rs.Bank))
|
||||||
|
builder.WriteString(", equipment=")
|
||||||
|
builder.WriteString(fmt.Sprintf("%v", rs.Equipment))
|
||||||
|
builder.WriteString(", spent=")
|
||||||
|
builder.WriteString(fmt.Sprintf("%v", rs.Spent))
|
||||||
|
builder.WriteByte(')')
|
||||||
|
return builder.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoundStatsSlice is a parsable slice of RoundStats.
|
||||||
|
type RoundStatsSlice []*RoundStats
|
||||||
|
|
||||||
|
func (rs RoundStatsSlice) config(cfg config) {
|
||||||
|
for _i := range rs {
|
||||||
|
rs[_i].config = cfg
|
||||||
|
}
|
||||||
|
}
|
59
ent/roundstats/roundstats.go
Normal file
59
ent/roundstats/roundstats.go
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
// Code generated by entc, DO NOT EDIT.
|
||||||
|
|
||||||
|
package roundstats
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Label holds the string label denoting the roundstats type in the database.
|
||||||
|
Label = "round_stats"
|
||||||
|
// FieldID holds the string denoting the id field in the database.
|
||||||
|
FieldID = "id"
|
||||||
|
// FieldRound holds the string denoting the round field in the database.
|
||||||
|
FieldRound = "round"
|
||||||
|
// FieldBank holds the string denoting the bank field in the database.
|
||||||
|
FieldBank = "bank"
|
||||||
|
// FieldEquipment holds the string denoting the equipment field in the database.
|
||||||
|
FieldEquipment = "equipment"
|
||||||
|
// FieldSpent holds the string denoting the spent field in the database.
|
||||||
|
FieldSpent = "spent"
|
||||||
|
// EdgeStat holds the string denoting the stat edge name in mutations.
|
||||||
|
EdgeStat = "stat"
|
||||||
|
// Table holds the table name of the roundstats in the database.
|
||||||
|
Table = "round_stats"
|
||||||
|
// StatTable is the table that holds the stat relation/edge.
|
||||||
|
StatTable = "round_stats"
|
||||||
|
// StatInverseTable is the table name for the Stats entity.
|
||||||
|
// It exists in this package in order to avoid circular dependency with the "stats" package.
|
||||||
|
StatInverseTable = "stats"
|
||||||
|
// StatColumn is the table column denoting the stat relation/edge.
|
||||||
|
StatColumn = "stats_round_stats"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Columns holds all SQL columns for roundstats fields.
|
||||||
|
var Columns = []string{
|
||||||
|
FieldID,
|
||||||
|
FieldRound,
|
||||||
|
FieldBank,
|
||||||
|
FieldEquipment,
|
||||||
|
FieldSpent,
|
||||||
|
}
|
||||||
|
|
||||||
|
// ForeignKeys holds the SQL foreign-keys that are owned by the "round_stats"
|
||||||
|
// table and are not defined as standalone fields in the schema.
|
||||||
|
var ForeignKeys = []string{
|
||||||
|
"stats_round_stats",
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||||
|
func ValidColumn(column string) bool {
|
||||||
|
for i := range Columns {
|
||||||
|
if column == Columns[i] {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for i := range ForeignKeys {
|
||||||
|
if column == ForeignKeys[i] {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
485
ent/roundstats/where.go
Normal file
485
ent/roundstats/where.go
Normal file
@@ -0,0 +1,485 @@
|
|||||||
|
// Code generated by entc, DO NOT EDIT.
|
||||||
|
|
||||||
|
package roundstats
|
||||||
|
|
||||||
|
import (
|
||||||
|
"csgowtfd/ent/predicate"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ID filters vertices based on their ID field.
|
||||||
|
func ID(id int) predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(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.RoundStats {
|
||||||
|
return predicate.RoundStats(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.RoundStats {
|
||||||
|
return predicate.RoundStats(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.RoundStats {
|
||||||
|
return predicate.RoundStats(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(ids) == 0 {
|
||||||
|
s.Where(sql.False())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
v := make([]interface{}, len(ids))
|
||||||
|
for i := range v {
|
||||||
|
v[i] = ids[i]
|
||||||
|
}
|
||||||
|
s.Where(sql.In(s.C(FieldID), v...))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDNotIn applies the NotIn predicate on the ID field.
|
||||||
|
func IDNotIn(ids ...int) predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(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(ids) == 0 {
|
||||||
|
s.Where(sql.False())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
v := make([]interface{}, len(ids))
|
||||||
|
for i := range v {
|
||||||
|
v[i] = ids[i]
|
||||||
|
}
|
||||||
|
s.Where(sql.NotIn(s.C(FieldID), v...))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDGT applies the GT predicate on the ID field.
|
||||||
|
func IDGT(id int) predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(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.RoundStats {
|
||||||
|
return predicate.RoundStats(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.RoundStats {
|
||||||
|
return predicate.RoundStats(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.RoundStats {
|
||||||
|
return predicate.RoundStats(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.LTE(s.C(FieldID), id))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Round applies equality check predicate on the "round" field. It's identical to RoundEQ.
|
||||||
|
func Round(v uint) predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.EQ(s.C(FieldRound), v))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bank applies equality check predicate on the "bank" field. It's identical to BankEQ.
|
||||||
|
func Bank(v uint) predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.EQ(s.C(FieldBank), v))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Equipment applies equality check predicate on the "equipment" field. It's identical to EquipmentEQ.
|
||||||
|
func Equipment(v uint) predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.EQ(s.C(FieldEquipment), v))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Spent applies equality check predicate on the "spent" field. It's identical to SpentEQ.
|
||||||
|
func Spent(v uint) predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.EQ(s.C(FieldSpent), v))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoundEQ applies the EQ predicate on the "round" field.
|
||||||
|
func RoundEQ(v uint) predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.EQ(s.C(FieldRound), v))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoundNEQ applies the NEQ predicate on the "round" field.
|
||||||
|
func RoundNEQ(v uint) predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.NEQ(s.C(FieldRound), v))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoundIn applies the In predicate on the "round" field.
|
||||||
|
func RoundIn(vs ...uint) predicate.RoundStats {
|
||||||
|
v := make([]interface{}, len(vs))
|
||||||
|
for i := range v {
|
||||||
|
v[i] = vs[i]
|
||||||
|
}
|
||||||
|
return predicate.RoundStats(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(FieldRound), v...))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoundNotIn applies the NotIn predicate on the "round" field.
|
||||||
|
func RoundNotIn(vs ...uint) predicate.RoundStats {
|
||||||
|
v := make([]interface{}, len(vs))
|
||||||
|
for i := range v {
|
||||||
|
v[i] = vs[i]
|
||||||
|
}
|
||||||
|
return predicate.RoundStats(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(FieldRound), v...))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoundGT applies the GT predicate on the "round" field.
|
||||||
|
func RoundGT(v uint) predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.GT(s.C(FieldRound), v))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoundGTE applies the GTE predicate on the "round" field.
|
||||||
|
func RoundGTE(v uint) predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.GTE(s.C(FieldRound), v))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoundLT applies the LT predicate on the "round" field.
|
||||||
|
func RoundLT(v uint) predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.LT(s.C(FieldRound), v))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoundLTE applies the LTE predicate on the "round" field.
|
||||||
|
func RoundLTE(v uint) predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.LTE(s.C(FieldRound), v))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// BankEQ applies the EQ predicate on the "bank" field.
|
||||||
|
func BankEQ(v uint) predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.EQ(s.C(FieldBank), v))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// BankNEQ applies the NEQ predicate on the "bank" field.
|
||||||
|
func BankNEQ(v uint) predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.NEQ(s.C(FieldBank), v))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// BankIn applies the In predicate on the "bank" field.
|
||||||
|
func BankIn(vs ...uint) predicate.RoundStats {
|
||||||
|
v := make([]interface{}, len(vs))
|
||||||
|
for i := range v {
|
||||||
|
v[i] = vs[i]
|
||||||
|
}
|
||||||
|
return predicate.RoundStats(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(FieldBank), v...))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// BankNotIn applies the NotIn predicate on the "bank" field.
|
||||||
|
func BankNotIn(vs ...uint) predicate.RoundStats {
|
||||||
|
v := make([]interface{}, len(vs))
|
||||||
|
for i := range v {
|
||||||
|
v[i] = vs[i]
|
||||||
|
}
|
||||||
|
return predicate.RoundStats(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(FieldBank), v...))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// BankGT applies the GT predicate on the "bank" field.
|
||||||
|
func BankGT(v uint) predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.GT(s.C(FieldBank), v))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// BankGTE applies the GTE predicate on the "bank" field.
|
||||||
|
func BankGTE(v uint) predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.GTE(s.C(FieldBank), v))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// BankLT applies the LT predicate on the "bank" field.
|
||||||
|
func BankLT(v uint) predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.LT(s.C(FieldBank), v))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// BankLTE applies the LTE predicate on the "bank" field.
|
||||||
|
func BankLTE(v uint) predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.LTE(s.C(FieldBank), v))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// EquipmentEQ applies the EQ predicate on the "equipment" field.
|
||||||
|
func EquipmentEQ(v uint) predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.EQ(s.C(FieldEquipment), v))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// EquipmentNEQ applies the NEQ predicate on the "equipment" field.
|
||||||
|
func EquipmentNEQ(v uint) predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.NEQ(s.C(FieldEquipment), v))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// EquipmentIn applies the In predicate on the "equipment" field.
|
||||||
|
func EquipmentIn(vs ...uint) predicate.RoundStats {
|
||||||
|
v := make([]interface{}, len(vs))
|
||||||
|
for i := range v {
|
||||||
|
v[i] = vs[i]
|
||||||
|
}
|
||||||
|
return predicate.RoundStats(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(FieldEquipment), v...))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// EquipmentNotIn applies the NotIn predicate on the "equipment" field.
|
||||||
|
func EquipmentNotIn(vs ...uint) predicate.RoundStats {
|
||||||
|
v := make([]interface{}, len(vs))
|
||||||
|
for i := range v {
|
||||||
|
v[i] = vs[i]
|
||||||
|
}
|
||||||
|
return predicate.RoundStats(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(FieldEquipment), v...))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// EquipmentGT applies the GT predicate on the "equipment" field.
|
||||||
|
func EquipmentGT(v uint) predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.GT(s.C(FieldEquipment), v))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// EquipmentGTE applies the GTE predicate on the "equipment" field.
|
||||||
|
func EquipmentGTE(v uint) predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.GTE(s.C(FieldEquipment), v))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// EquipmentLT applies the LT predicate on the "equipment" field.
|
||||||
|
func EquipmentLT(v uint) predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.LT(s.C(FieldEquipment), v))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// EquipmentLTE applies the LTE predicate on the "equipment" field.
|
||||||
|
func EquipmentLTE(v uint) predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.LTE(s.C(FieldEquipment), v))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// SpentEQ applies the EQ predicate on the "spent" field.
|
||||||
|
func SpentEQ(v uint) predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.EQ(s.C(FieldSpent), v))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// SpentNEQ applies the NEQ predicate on the "spent" field.
|
||||||
|
func SpentNEQ(v uint) predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.NEQ(s.C(FieldSpent), v))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// SpentIn applies the In predicate on the "spent" field.
|
||||||
|
func SpentIn(vs ...uint) predicate.RoundStats {
|
||||||
|
v := make([]interface{}, len(vs))
|
||||||
|
for i := range v {
|
||||||
|
v[i] = vs[i]
|
||||||
|
}
|
||||||
|
return predicate.RoundStats(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(FieldSpent), v...))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// SpentNotIn applies the NotIn predicate on the "spent" field.
|
||||||
|
func SpentNotIn(vs ...uint) predicate.RoundStats {
|
||||||
|
v := make([]interface{}, len(vs))
|
||||||
|
for i := range v {
|
||||||
|
v[i] = vs[i]
|
||||||
|
}
|
||||||
|
return predicate.RoundStats(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(FieldSpent), v...))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// SpentGT applies the GT predicate on the "spent" field.
|
||||||
|
func SpentGT(v uint) predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.GT(s.C(FieldSpent), v))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// SpentGTE applies the GTE predicate on the "spent" field.
|
||||||
|
func SpentGTE(v uint) predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.GTE(s.C(FieldSpent), v))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// SpentLT applies the LT predicate on the "spent" field.
|
||||||
|
func SpentLT(v uint) predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.LT(s.C(FieldSpent), v))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// SpentLTE applies the LTE predicate on the "spent" field.
|
||||||
|
func SpentLTE(v uint) predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.LTE(s.C(FieldSpent), v))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasStat applies the HasEdge predicate on the "stat" edge.
|
||||||
|
func HasStat() predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(func(s *sql.Selector) {
|
||||||
|
step := sqlgraph.NewStep(
|
||||||
|
sqlgraph.From(Table, FieldID),
|
||||||
|
sqlgraph.To(StatTable, FieldID),
|
||||||
|
sqlgraph.Edge(sqlgraph.M2O, true, StatTable, StatColumn),
|
||||||
|
)
|
||||||
|
sqlgraph.HasNeighbors(s, step)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasStatWith applies the HasEdge predicate on the "stat" edge with a given conditions (other predicates).
|
||||||
|
func HasStatWith(preds ...predicate.Stats) predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(func(s *sql.Selector) {
|
||||||
|
step := sqlgraph.NewStep(
|
||||||
|
sqlgraph.From(Table, FieldID),
|
||||||
|
sqlgraph.To(StatInverseTable, FieldID),
|
||||||
|
sqlgraph.Edge(sqlgraph.M2O, true, StatTable, StatColumn),
|
||||||
|
)
|
||||||
|
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||||
|
for _, p := range preds {
|
||||||
|
p(s)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// And groups predicates with the AND operator between them.
|
||||||
|
func And(predicates ...predicate.RoundStats) predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(func(s *sql.Selector) {
|
||||||
|
s1 := s.Clone().SetP(nil)
|
||||||
|
for _, p := range predicates {
|
||||||
|
p(s1)
|
||||||
|
}
|
||||||
|
s.Where(s1.P())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Or groups predicates with the OR operator between them.
|
||||||
|
func Or(predicates ...predicate.RoundStats) predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(func(s *sql.Selector) {
|
||||||
|
s1 := s.Clone().SetP(nil)
|
||||||
|
for i, p := range predicates {
|
||||||
|
if i > 0 {
|
||||||
|
s1.Or()
|
||||||
|
}
|
||||||
|
p(s1)
|
||||||
|
}
|
||||||
|
s.Where(s1.P())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not applies the not operator on the given predicate.
|
||||||
|
func Not(p predicate.RoundStats) predicate.RoundStats {
|
||||||
|
return predicate.RoundStats(func(s *sql.Selector) {
|
||||||
|
p(s.Not())
|
||||||
|
})
|
||||||
|
}
|
311
ent/roundstats_create.go
Normal file
311
ent/roundstats_create.go
Normal file
@@ -0,0 +1,311 @@
|
|||||||
|
// Code generated by entc, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"csgowtfd/ent/roundstats"
|
||||||
|
"csgowtfd/ent/stats"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RoundStatsCreate is the builder for creating a RoundStats entity.
|
||||||
|
type RoundStatsCreate struct {
|
||||||
|
config
|
||||||
|
mutation *RoundStatsMutation
|
||||||
|
hooks []Hook
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetRound sets the "round" field.
|
||||||
|
func (rsc *RoundStatsCreate) SetRound(u uint) *RoundStatsCreate {
|
||||||
|
rsc.mutation.SetRound(u)
|
||||||
|
return rsc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetBank sets the "bank" field.
|
||||||
|
func (rsc *RoundStatsCreate) SetBank(u uint) *RoundStatsCreate {
|
||||||
|
rsc.mutation.SetBank(u)
|
||||||
|
return rsc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetEquipment sets the "equipment" field.
|
||||||
|
func (rsc *RoundStatsCreate) SetEquipment(u uint) *RoundStatsCreate {
|
||||||
|
rsc.mutation.SetEquipment(u)
|
||||||
|
return rsc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetSpent sets the "spent" field.
|
||||||
|
func (rsc *RoundStatsCreate) SetSpent(u uint) *RoundStatsCreate {
|
||||||
|
rsc.mutation.SetSpent(u)
|
||||||
|
return rsc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetStatID sets the "stat" edge to the Stats entity by ID.
|
||||||
|
func (rsc *RoundStatsCreate) SetStatID(id int) *RoundStatsCreate {
|
||||||
|
rsc.mutation.SetStatID(id)
|
||||||
|
return rsc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableStatID sets the "stat" edge to the Stats entity by ID if the given value is not nil.
|
||||||
|
func (rsc *RoundStatsCreate) SetNillableStatID(id *int) *RoundStatsCreate {
|
||||||
|
if id != nil {
|
||||||
|
rsc = rsc.SetStatID(*id)
|
||||||
|
}
|
||||||
|
return rsc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetStat sets the "stat" edge to the Stats entity.
|
||||||
|
func (rsc *RoundStatsCreate) SetStat(s *Stats) *RoundStatsCreate {
|
||||||
|
return rsc.SetStatID(s.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutation returns the RoundStatsMutation object of the builder.
|
||||||
|
func (rsc *RoundStatsCreate) Mutation() *RoundStatsMutation {
|
||||||
|
return rsc.mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save creates the RoundStats in the database.
|
||||||
|
func (rsc *RoundStatsCreate) Save(ctx context.Context) (*RoundStats, error) {
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
node *RoundStats
|
||||||
|
)
|
||||||
|
if len(rsc.hooks) == 0 {
|
||||||
|
if err = rsc.check(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
node, err = rsc.sqlSave(ctx)
|
||||||
|
} else {
|
||||||
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||||
|
mutation, ok := m.(*RoundStatsMutation)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||||
|
}
|
||||||
|
if err = rsc.check(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
rsc.mutation = mutation
|
||||||
|
if node, err = rsc.sqlSave(ctx); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
mutation.id = &node.ID
|
||||||
|
mutation.done = true
|
||||||
|
return node, err
|
||||||
|
})
|
||||||
|
for i := len(rsc.hooks) - 1; i >= 0; i-- {
|
||||||
|
if rsc.hooks[i] == nil {
|
||||||
|
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
|
||||||
|
}
|
||||||
|
mut = rsc.hooks[i](mut)
|
||||||
|
}
|
||||||
|
if _, err := mut.Mutate(ctx, rsc.mutation); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return node, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX calls Save and panics if Save returns an error.
|
||||||
|
func (rsc *RoundStatsCreate) SaveX(ctx context.Context) *RoundStats {
|
||||||
|
v, err := rsc.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (rsc *RoundStatsCreate) Exec(ctx context.Context) error {
|
||||||
|
_, err := rsc.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (rsc *RoundStatsCreate) ExecX(ctx context.Context) {
|
||||||
|
if err := rsc.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check runs all checks and user-defined validators on the builder.
|
||||||
|
func (rsc *RoundStatsCreate) check() error {
|
||||||
|
if _, ok := rsc.mutation.Round(); !ok {
|
||||||
|
return &ValidationError{Name: "round", err: errors.New(`ent: missing required field "round"`)}
|
||||||
|
}
|
||||||
|
if _, ok := rsc.mutation.Bank(); !ok {
|
||||||
|
return &ValidationError{Name: "bank", err: errors.New(`ent: missing required field "bank"`)}
|
||||||
|
}
|
||||||
|
if _, ok := rsc.mutation.Equipment(); !ok {
|
||||||
|
return &ValidationError{Name: "equipment", err: errors.New(`ent: missing required field "equipment"`)}
|
||||||
|
}
|
||||||
|
if _, ok := rsc.mutation.Spent(); !ok {
|
||||||
|
return &ValidationError{Name: "spent", err: errors.New(`ent: missing required field "spent"`)}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rsc *RoundStatsCreate) sqlSave(ctx context.Context) (*RoundStats, error) {
|
||||||
|
_node, _spec := rsc.createSpec()
|
||||||
|
if err := sqlgraph.CreateNode(ctx, rsc.driver, _spec); err != nil {
|
||||||
|
if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{err.Error(), err}
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
id := _spec.ID.Value.(int64)
|
||||||
|
_node.ID = int(id)
|
||||||
|
return _node, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rsc *RoundStatsCreate) createSpec() (*RoundStats, *sqlgraph.CreateSpec) {
|
||||||
|
var (
|
||||||
|
_node = &RoundStats{config: rsc.config}
|
||||||
|
_spec = &sqlgraph.CreateSpec{
|
||||||
|
Table: roundstats.Table,
|
||||||
|
ID: &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeInt,
|
||||||
|
Column: roundstats.FieldID,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
if value, ok := rsc.mutation.Round(); ok {
|
||||||
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeUint,
|
||||||
|
Value: value,
|
||||||
|
Column: roundstats.FieldRound,
|
||||||
|
})
|
||||||
|
_node.Round = value
|
||||||
|
}
|
||||||
|
if value, ok := rsc.mutation.Bank(); ok {
|
||||||
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeUint,
|
||||||
|
Value: value,
|
||||||
|
Column: roundstats.FieldBank,
|
||||||
|
})
|
||||||
|
_node.Bank = value
|
||||||
|
}
|
||||||
|
if value, ok := rsc.mutation.Equipment(); ok {
|
||||||
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeUint,
|
||||||
|
Value: value,
|
||||||
|
Column: roundstats.FieldEquipment,
|
||||||
|
})
|
||||||
|
_node.Equipment = value
|
||||||
|
}
|
||||||
|
if value, ok := rsc.mutation.Spent(); ok {
|
||||||
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeUint,
|
||||||
|
Value: value,
|
||||||
|
Column: roundstats.FieldSpent,
|
||||||
|
})
|
||||||
|
_node.Spent = value
|
||||||
|
}
|
||||||
|
if nodes := rsc.mutation.StatIDs(); len(nodes) > 0 {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.M2O,
|
||||||
|
Inverse: true,
|
||||||
|
Table: roundstats.StatTable,
|
||||||
|
Columns: []string{roundstats.StatColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeInt,
|
||||||
|
Column: stats.FieldID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, k := range nodes {
|
||||||
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||||
|
}
|
||||||
|
_node.stats_round_stats = &nodes[0]
|
||||||
|
_spec.Edges = append(_spec.Edges, edge)
|
||||||
|
}
|
||||||
|
return _node, _spec
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoundStatsCreateBulk is the builder for creating many RoundStats entities in bulk.
|
||||||
|
type RoundStatsCreateBulk struct {
|
||||||
|
config
|
||||||
|
builders []*RoundStatsCreate
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save creates the RoundStats entities in the database.
|
||||||
|
func (rscb *RoundStatsCreateBulk) Save(ctx context.Context) ([]*RoundStats, error) {
|
||||||
|
specs := make([]*sqlgraph.CreateSpec, len(rscb.builders))
|
||||||
|
nodes := make([]*RoundStats, len(rscb.builders))
|
||||||
|
mutators := make([]Mutator, len(rscb.builders))
|
||||||
|
for i := range rscb.builders {
|
||||||
|
func(i int, root context.Context) {
|
||||||
|
builder := rscb.builders[i]
|
||||||
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||||
|
mutation, ok := m.(*RoundStatsMutation)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||||
|
}
|
||||||
|
if err := builder.check(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
builder.mutation = mutation
|
||||||
|
nodes[i], specs[i] = builder.createSpec()
|
||||||
|
var err error
|
||||||
|
if i < len(mutators)-1 {
|
||||||
|
_, err = mutators[i+1].Mutate(root, rscb.builders[i+1].mutation)
|
||||||
|
} else {
|
||||||
|
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||||
|
// Invoke the actual operation on the latest mutation in the chain.
|
||||||
|
if err = sqlgraph.BatchCreate(ctx, rscb.driver, spec); err != nil {
|
||||||
|
if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{err.Error(), err}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
mutation.id = &nodes[i].ID
|
||||||
|
mutation.done = true
|
||||||
|
if specs[i].ID.Value != nil {
|
||||||
|
id := specs[i].ID.Value.(int64)
|
||||||
|
nodes[i].ID = int(id)
|
||||||
|
}
|
||||||
|
return nodes[i], nil
|
||||||
|
})
|
||||||
|
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||||
|
mut = builder.hooks[i](mut)
|
||||||
|
}
|
||||||
|
mutators[i] = mut
|
||||||
|
}(i, ctx)
|
||||||
|
}
|
||||||
|
if len(mutators) > 0 {
|
||||||
|
if _, err := mutators[0].Mutate(ctx, rscb.builders[0].mutation); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (rscb *RoundStatsCreateBulk) SaveX(ctx context.Context) []*RoundStats {
|
||||||
|
v, err := rscb.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (rscb *RoundStatsCreateBulk) Exec(ctx context.Context) error {
|
||||||
|
_, err := rscb.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (rscb *RoundStatsCreateBulk) ExecX(ctx context.Context) {
|
||||||
|
if err := rscb.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
111
ent/roundstats_delete.go
Normal file
111
ent/roundstats_delete.go
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
// Code generated by entc, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"csgowtfd/ent/predicate"
|
||||||
|
"csgowtfd/ent/roundstats"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RoundStatsDelete is the builder for deleting a RoundStats entity.
|
||||||
|
type RoundStatsDelete struct {
|
||||||
|
config
|
||||||
|
hooks []Hook
|
||||||
|
mutation *RoundStatsMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the RoundStatsDelete builder.
|
||||||
|
func (rsd *RoundStatsDelete) Where(ps ...predicate.RoundStats) *RoundStatsDelete {
|
||||||
|
rsd.mutation.Where(ps...)
|
||||||
|
return rsd
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||||
|
func (rsd *RoundStatsDelete) Exec(ctx context.Context) (int, error) {
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
affected int
|
||||||
|
)
|
||||||
|
if len(rsd.hooks) == 0 {
|
||||||
|
affected, err = rsd.sqlExec(ctx)
|
||||||
|
} else {
|
||||||
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||||
|
mutation, ok := m.(*RoundStatsMutation)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||||
|
}
|
||||||
|
rsd.mutation = mutation
|
||||||
|
affected, err = rsd.sqlExec(ctx)
|
||||||
|
mutation.done = true
|
||||||
|
return affected, err
|
||||||
|
})
|
||||||
|
for i := len(rsd.hooks) - 1; i >= 0; i-- {
|
||||||
|
if rsd.hooks[i] == nil {
|
||||||
|
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
|
||||||
|
}
|
||||||
|
mut = rsd.hooks[i](mut)
|
||||||
|
}
|
||||||
|
if _, err := mut.Mutate(ctx, rsd.mutation); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return affected, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (rsd *RoundStatsDelete) ExecX(ctx context.Context) int {
|
||||||
|
n, err := rsd.Exec(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rsd *RoundStatsDelete) sqlExec(ctx context.Context) (int, error) {
|
||||||
|
_spec := &sqlgraph.DeleteSpec{
|
||||||
|
Node: &sqlgraph.NodeSpec{
|
||||||
|
Table: roundstats.Table,
|
||||||
|
ID: &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeInt,
|
||||||
|
Column: roundstats.FieldID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
if ps := rsd.mutation.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sqlgraph.DeleteNodes(ctx, rsd.driver, _spec)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoundStatsDeleteOne is the builder for deleting a single RoundStats entity.
|
||||||
|
type RoundStatsDeleteOne struct {
|
||||||
|
rsd *RoundStatsDelete
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the deletion query.
|
||||||
|
func (rsdo *RoundStatsDeleteOne) Exec(ctx context.Context) error {
|
||||||
|
n, err := rsdo.rsd.Exec(ctx)
|
||||||
|
switch {
|
||||||
|
case err != nil:
|
||||||
|
return err
|
||||||
|
case n == 0:
|
||||||
|
return &NotFoundError{roundstats.Label}
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (rsdo *RoundStatsDeleteOne) ExecX(ctx context.Context) {
|
||||||
|
rsdo.rsd.ExecX(ctx)
|
||||||
|
}
|
1016
ent/roundstats_query.go
Normal file
1016
ent/roundstats_query.go
Normal file
File diff suppressed because it is too large
Load Diff
575
ent/roundstats_update.go
Normal file
575
ent/roundstats_update.go
Normal file
@@ -0,0 +1,575 @@
|
|||||||
|
// Code generated by entc, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"csgowtfd/ent/predicate"
|
||||||
|
"csgowtfd/ent/roundstats"
|
||||||
|
"csgowtfd/ent/stats"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RoundStatsUpdate is the builder for updating RoundStats entities.
|
||||||
|
type RoundStatsUpdate struct {
|
||||||
|
config
|
||||||
|
hooks []Hook
|
||||||
|
mutation *RoundStatsMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the RoundStatsUpdate builder.
|
||||||
|
func (rsu *RoundStatsUpdate) Where(ps ...predicate.RoundStats) *RoundStatsUpdate {
|
||||||
|
rsu.mutation.Where(ps...)
|
||||||
|
return rsu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetRound sets the "round" field.
|
||||||
|
func (rsu *RoundStatsUpdate) SetRound(u uint) *RoundStatsUpdate {
|
||||||
|
rsu.mutation.ResetRound()
|
||||||
|
rsu.mutation.SetRound(u)
|
||||||
|
return rsu
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddRound adds u to the "round" field.
|
||||||
|
func (rsu *RoundStatsUpdate) AddRound(u uint) *RoundStatsUpdate {
|
||||||
|
rsu.mutation.AddRound(u)
|
||||||
|
return rsu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetBank sets the "bank" field.
|
||||||
|
func (rsu *RoundStatsUpdate) SetBank(u uint) *RoundStatsUpdate {
|
||||||
|
rsu.mutation.ResetBank()
|
||||||
|
rsu.mutation.SetBank(u)
|
||||||
|
return rsu
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddBank adds u to the "bank" field.
|
||||||
|
func (rsu *RoundStatsUpdate) AddBank(u uint) *RoundStatsUpdate {
|
||||||
|
rsu.mutation.AddBank(u)
|
||||||
|
return rsu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetEquipment sets the "equipment" field.
|
||||||
|
func (rsu *RoundStatsUpdate) SetEquipment(u uint) *RoundStatsUpdate {
|
||||||
|
rsu.mutation.ResetEquipment()
|
||||||
|
rsu.mutation.SetEquipment(u)
|
||||||
|
return rsu
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddEquipment adds u to the "equipment" field.
|
||||||
|
func (rsu *RoundStatsUpdate) AddEquipment(u uint) *RoundStatsUpdate {
|
||||||
|
rsu.mutation.AddEquipment(u)
|
||||||
|
return rsu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetSpent sets the "spent" field.
|
||||||
|
func (rsu *RoundStatsUpdate) SetSpent(u uint) *RoundStatsUpdate {
|
||||||
|
rsu.mutation.ResetSpent()
|
||||||
|
rsu.mutation.SetSpent(u)
|
||||||
|
return rsu
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddSpent adds u to the "spent" field.
|
||||||
|
func (rsu *RoundStatsUpdate) AddSpent(u uint) *RoundStatsUpdate {
|
||||||
|
rsu.mutation.AddSpent(u)
|
||||||
|
return rsu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetStatID sets the "stat" edge to the Stats entity by ID.
|
||||||
|
func (rsu *RoundStatsUpdate) SetStatID(id int) *RoundStatsUpdate {
|
||||||
|
rsu.mutation.SetStatID(id)
|
||||||
|
return rsu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableStatID sets the "stat" edge to the Stats entity by ID if the given value is not nil.
|
||||||
|
func (rsu *RoundStatsUpdate) SetNillableStatID(id *int) *RoundStatsUpdate {
|
||||||
|
if id != nil {
|
||||||
|
rsu = rsu.SetStatID(*id)
|
||||||
|
}
|
||||||
|
return rsu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetStat sets the "stat" edge to the Stats entity.
|
||||||
|
func (rsu *RoundStatsUpdate) SetStat(s *Stats) *RoundStatsUpdate {
|
||||||
|
return rsu.SetStatID(s.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutation returns the RoundStatsMutation object of the builder.
|
||||||
|
func (rsu *RoundStatsUpdate) Mutation() *RoundStatsMutation {
|
||||||
|
return rsu.mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearStat clears the "stat" edge to the Stats entity.
|
||||||
|
func (rsu *RoundStatsUpdate) ClearStat() *RoundStatsUpdate {
|
||||||
|
rsu.mutation.ClearStat()
|
||||||
|
return rsu
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||||
|
func (rsu *RoundStatsUpdate) Save(ctx context.Context) (int, error) {
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
affected int
|
||||||
|
)
|
||||||
|
if len(rsu.hooks) == 0 {
|
||||||
|
affected, err = rsu.sqlSave(ctx)
|
||||||
|
} else {
|
||||||
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||||
|
mutation, ok := m.(*RoundStatsMutation)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||||
|
}
|
||||||
|
rsu.mutation = mutation
|
||||||
|
affected, err = rsu.sqlSave(ctx)
|
||||||
|
mutation.done = true
|
||||||
|
return affected, err
|
||||||
|
})
|
||||||
|
for i := len(rsu.hooks) - 1; i >= 0; i-- {
|
||||||
|
if rsu.hooks[i] == nil {
|
||||||
|
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
|
||||||
|
}
|
||||||
|
mut = rsu.hooks[i](mut)
|
||||||
|
}
|
||||||
|
if _, err := mut.Mutate(ctx, rsu.mutation); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return affected, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (rsu *RoundStatsUpdate) SaveX(ctx context.Context) int {
|
||||||
|
affected, err := rsu.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return affected
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (rsu *RoundStatsUpdate) Exec(ctx context.Context) error {
|
||||||
|
_, err := rsu.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (rsu *RoundStatsUpdate) ExecX(ctx context.Context) {
|
||||||
|
if err := rsu.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rsu *RoundStatsUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||||
|
_spec := &sqlgraph.UpdateSpec{
|
||||||
|
Node: &sqlgraph.NodeSpec{
|
||||||
|
Table: roundstats.Table,
|
||||||
|
Columns: roundstats.Columns,
|
||||||
|
ID: &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeInt,
|
||||||
|
Column: roundstats.FieldID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
if ps := rsu.mutation.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if value, ok := rsu.mutation.Round(); ok {
|
||||||
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeUint,
|
||||||
|
Value: value,
|
||||||
|
Column: roundstats.FieldRound,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if value, ok := rsu.mutation.AddedRound(); ok {
|
||||||
|
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeUint,
|
||||||
|
Value: value,
|
||||||
|
Column: roundstats.FieldRound,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if value, ok := rsu.mutation.Bank(); ok {
|
||||||
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeUint,
|
||||||
|
Value: value,
|
||||||
|
Column: roundstats.FieldBank,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if value, ok := rsu.mutation.AddedBank(); ok {
|
||||||
|
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeUint,
|
||||||
|
Value: value,
|
||||||
|
Column: roundstats.FieldBank,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if value, ok := rsu.mutation.Equipment(); ok {
|
||||||
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeUint,
|
||||||
|
Value: value,
|
||||||
|
Column: roundstats.FieldEquipment,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if value, ok := rsu.mutation.AddedEquipment(); ok {
|
||||||
|
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeUint,
|
||||||
|
Value: value,
|
||||||
|
Column: roundstats.FieldEquipment,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if value, ok := rsu.mutation.Spent(); ok {
|
||||||
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeUint,
|
||||||
|
Value: value,
|
||||||
|
Column: roundstats.FieldSpent,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if value, ok := rsu.mutation.AddedSpent(); ok {
|
||||||
|
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeUint,
|
||||||
|
Value: value,
|
||||||
|
Column: roundstats.FieldSpent,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if rsu.mutation.StatCleared() {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.M2O,
|
||||||
|
Inverse: true,
|
||||||
|
Table: roundstats.StatTable,
|
||||||
|
Columns: []string{roundstats.StatColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeInt,
|
||||||
|
Column: stats.FieldID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||||
|
}
|
||||||
|
if nodes := rsu.mutation.StatIDs(); len(nodes) > 0 {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.M2O,
|
||||||
|
Inverse: true,
|
||||||
|
Table: roundstats.StatTable,
|
||||||
|
Columns: []string{roundstats.StatColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeInt,
|
||||||
|
Column: stats.FieldID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, k := range nodes {
|
||||||
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||||
|
}
|
||||||
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||||
|
}
|
||||||
|
if n, err = sqlgraph.UpdateNodes(ctx, rsu.driver, _spec); err != nil {
|
||||||
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
|
err = &NotFoundError{roundstats.Label}
|
||||||
|
} else if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{err.Error(), err}
|
||||||
|
}
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return n, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoundStatsUpdateOne is the builder for updating a single RoundStats entity.
|
||||||
|
type RoundStatsUpdateOne struct {
|
||||||
|
config
|
||||||
|
fields []string
|
||||||
|
hooks []Hook
|
||||||
|
mutation *RoundStatsMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetRound sets the "round" field.
|
||||||
|
func (rsuo *RoundStatsUpdateOne) SetRound(u uint) *RoundStatsUpdateOne {
|
||||||
|
rsuo.mutation.ResetRound()
|
||||||
|
rsuo.mutation.SetRound(u)
|
||||||
|
return rsuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddRound adds u to the "round" field.
|
||||||
|
func (rsuo *RoundStatsUpdateOne) AddRound(u uint) *RoundStatsUpdateOne {
|
||||||
|
rsuo.mutation.AddRound(u)
|
||||||
|
return rsuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetBank sets the "bank" field.
|
||||||
|
func (rsuo *RoundStatsUpdateOne) SetBank(u uint) *RoundStatsUpdateOne {
|
||||||
|
rsuo.mutation.ResetBank()
|
||||||
|
rsuo.mutation.SetBank(u)
|
||||||
|
return rsuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddBank adds u to the "bank" field.
|
||||||
|
func (rsuo *RoundStatsUpdateOne) AddBank(u uint) *RoundStatsUpdateOne {
|
||||||
|
rsuo.mutation.AddBank(u)
|
||||||
|
return rsuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetEquipment sets the "equipment" field.
|
||||||
|
func (rsuo *RoundStatsUpdateOne) SetEquipment(u uint) *RoundStatsUpdateOne {
|
||||||
|
rsuo.mutation.ResetEquipment()
|
||||||
|
rsuo.mutation.SetEquipment(u)
|
||||||
|
return rsuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddEquipment adds u to the "equipment" field.
|
||||||
|
func (rsuo *RoundStatsUpdateOne) AddEquipment(u uint) *RoundStatsUpdateOne {
|
||||||
|
rsuo.mutation.AddEquipment(u)
|
||||||
|
return rsuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetSpent sets the "spent" field.
|
||||||
|
func (rsuo *RoundStatsUpdateOne) SetSpent(u uint) *RoundStatsUpdateOne {
|
||||||
|
rsuo.mutation.ResetSpent()
|
||||||
|
rsuo.mutation.SetSpent(u)
|
||||||
|
return rsuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddSpent adds u to the "spent" field.
|
||||||
|
func (rsuo *RoundStatsUpdateOne) AddSpent(u uint) *RoundStatsUpdateOne {
|
||||||
|
rsuo.mutation.AddSpent(u)
|
||||||
|
return rsuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetStatID sets the "stat" edge to the Stats entity by ID.
|
||||||
|
func (rsuo *RoundStatsUpdateOne) SetStatID(id int) *RoundStatsUpdateOne {
|
||||||
|
rsuo.mutation.SetStatID(id)
|
||||||
|
return rsuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableStatID sets the "stat" edge to the Stats entity by ID if the given value is not nil.
|
||||||
|
func (rsuo *RoundStatsUpdateOne) SetNillableStatID(id *int) *RoundStatsUpdateOne {
|
||||||
|
if id != nil {
|
||||||
|
rsuo = rsuo.SetStatID(*id)
|
||||||
|
}
|
||||||
|
return rsuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetStat sets the "stat" edge to the Stats entity.
|
||||||
|
func (rsuo *RoundStatsUpdateOne) SetStat(s *Stats) *RoundStatsUpdateOne {
|
||||||
|
return rsuo.SetStatID(s.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutation returns the RoundStatsMutation object of the builder.
|
||||||
|
func (rsuo *RoundStatsUpdateOne) Mutation() *RoundStatsMutation {
|
||||||
|
return rsuo.mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearStat clears the "stat" edge to the Stats entity.
|
||||||
|
func (rsuo *RoundStatsUpdateOne) ClearStat() *RoundStatsUpdateOne {
|
||||||
|
rsuo.mutation.ClearStat()
|
||||||
|
return rsuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||||
|
// The default is selecting all fields defined in the entity schema.
|
||||||
|
func (rsuo *RoundStatsUpdateOne) Select(field string, fields ...string) *RoundStatsUpdateOne {
|
||||||
|
rsuo.fields = append([]string{field}, fields...)
|
||||||
|
return rsuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save executes the query and returns the updated RoundStats entity.
|
||||||
|
func (rsuo *RoundStatsUpdateOne) Save(ctx context.Context) (*RoundStats, error) {
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
node *RoundStats
|
||||||
|
)
|
||||||
|
if len(rsuo.hooks) == 0 {
|
||||||
|
node, err = rsuo.sqlSave(ctx)
|
||||||
|
} else {
|
||||||
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||||
|
mutation, ok := m.(*RoundStatsMutation)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||||
|
}
|
||||||
|
rsuo.mutation = mutation
|
||||||
|
node, err = rsuo.sqlSave(ctx)
|
||||||
|
mutation.done = true
|
||||||
|
return node, err
|
||||||
|
})
|
||||||
|
for i := len(rsuo.hooks) - 1; i >= 0; i-- {
|
||||||
|
if rsuo.hooks[i] == nil {
|
||||||
|
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
|
||||||
|
}
|
||||||
|
mut = rsuo.hooks[i](mut)
|
||||||
|
}
|
||||||
|
if _, err := mut.Mutate(ctx, rsuo.mutation); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return node, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (rsuo *RoundStatsUpdateOne) SaveX(ctx context.Context) *RoundStats {
|
||||||
|
node, err := rsuo.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query on the entity.
|
||||||
|
func (rsuo *RoundStatsUpdateOne) Exec(ctx context.Context) error {
|
||||||
|
_, err := rsuo.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (rsuo *RoundStatsUpdateOne) ExecX(ctx context.Context) {
|
||||||
|
if err := rsuo.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rsuo *RoundStatsUpdateOne) sqlSave(ctx context.Context) (_node *RoundStats, err error) {
|
||||||
|
_spec := &sqlgraph.UpdateSpec{
|
||||||
|
Node: &sqlgraph.NodeSpec{
|
||||||
|
Table: roundstats.Table,
|
||||||
|
Columns: roundstats.Columns,
|
||||||
|
ID: &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeInt,
|
||||||
|
Column: roundstats.FieldID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
id, ok := rsuo.mutation.ID()
|
||||||
|
if !ok {
|
||||||
|
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing RoundStats.ID for update")}
|
||||||
|
}
|
||||||
|
_spec.Node.ID.Value = id
|
||||||
|
if fields := rsuo.fields; len(fields) > 0 {
|
||||||
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, roundstats.FieldID)
|
||||||
|
for _, f := range fields {
|
||||||
|
if !roundstats.ValidColumn(f) {
|
||||||
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||||
|
}
|
||||||
|
if f != roundstats.FieldID {
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ps := rsuo.mutation.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if value, ok := rsuo.mutation.Round(); ok {
|
||||||
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeUint,
|
||||||
|
Value: value,
|
||||||
|
Column: roundstats.FieldRound,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if value, ok := rsuo.mutation.AddedRound(); ok {
|
||||||
|
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeUint,
|
||||||
|
Value: value,
|
||||||
|
Column: roundstats.FieldRound,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if value, ok := rsuo.mutation.Bank(); ok {
|
||||||
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeUint,
|
||||||
|
Value: value,
|
||||||
|
Column: roundstats.FieldBank,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if value, ok := rsuo.mutation.AddedBank(); ok {
|
||||||
|
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeUint,
|
||||||
|
Value: value,
|
||||||
|
Column: roundstats.FieldBank,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if value, ok := rsuo.mutation.Equipment(); ok {
|
||||||
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeUint,
|
||||||
|
Value: value,
|
||||||
|
Column: roundstats.FieldEquipment,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if value, ok := rsuo.mutation.AddedEquipment(); ok {
|
||||||
|
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeUint,
|
||||||
|
Value: value,
|
||||||
|
Column: roundstats.FieldEquipment,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if value, ok := rsuo.mutation.Spent(); ok {
|
||||||
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeUint,
|
||||||
|
Value: value,
|
||||||
|
Column: roundstats.FieldSpent,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if value, ok := rsuo.mutation.AddedSpent(); ok {
|
||||||
|
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeUint,
|
||||||
|
Value: value,
|
||||||
|
Column: roundstats.FieldSpent,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if rsuo.mutation.StatCleared() {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.M2O,
|
||||||
|
Inverse: true,
|
||||||
|
Table: roundstats.StatTable,
|
||||||
|
Columns: []string{roundstats.StatColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeInt,
|
||||||
|
Column: stats.FieldID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||||
|
}
|
||||||
|
if nodes := rsuo.mutation.StatIDs(); len(nodes) > 0 {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.M2O,
|
||||||
|
Inverse: true,
|
||||||
|
Table: roundstats.StatTable,
|
||||||
|
Columns: []string{roundstats.StatColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeInt,
|
||||||
|
Column: stats.FieldID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, k := range nodes {
|
||||||
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||||
|
}
|
||||||
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||||
|
}
|
||||||
|
_node = &RoundStats{config: rsuo.config}
|
||||||
|
_spec.Assign = _node.assignValues
|
||||||
|
_spec.ScanValues = _node.scanValues
|
||||||
|
if err = sqlgraph.UpdateNode(ctx, rsuo.driver, _spec); err != nil {
|
||||||
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
|
err = &NotFoundError{roundstats.Label}
|
||||||
|
} else if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{err.Error(), err}
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return _node, nil
|
||||||
|
}
|
29
ent/schema/RoundStats.go
Normal file
29
ent/schema/RoundStats.go
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
package schema
|
||||||
|
|
||||||
|
import (
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/schema/edge"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RoundStats holds the schema definition for the EcoStats entity.
|
||||||
|
type RoundStats struct {
|
||||||
|
ent.Schema
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fields of the EcoStats.
|
||||||
|
func (RoundStats) Fields() []ent.Field {
|
||||||
|
return []ent.Field{
|
||||||
|
field.Uint("round"),
|
||||||
|
field.Uint("bank"),
|
||||||
|
field.Uint("equipment"),
|
||||||
|
field.Uint("spent"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Edges of the RoundStats.
|
||||||
|
func (RoundStats) Edges() []ent.Edge {
|
||||||
|
return []ent.Edge{
|
||||||
|
edge.From("stat", Stats.Type).Ref("round_stats").Unique(),
|
||||||
|
}
|
||||||
|
}
|
@@ -17,7 +17,7 @@ func (Player) Fields() []ent.Field {
|
|||||||
return []ent.Field{
|
return []ent.Field{
|
||||||
field.Uint64("id").Unique().Immutable().StructTag(`json:"steamid,string"`),
|
field.Uint64("id").Unique().Immutable().StructTag(`json:"steamid,string"`),
|
||||||
field.String("name").Optional(),
|
field.String("name").Optional(),
|
||||||
field.String("avatar_url").Optional(),
|
field.String("avatar").Optional(),
|
||||||
field.String("vanity_url").Optional(),
|
field.String("vanity_url").Optional(),
|
||||||
field.String("vanity_url_real").Optional(),
|
field.String("vanity_url_real").Optional(),
|
||||||
field.Bool("vac").Default(false),
|
field.Bool("vac").Default(false),
|
||||||
|
@@ -62,5 +62,6 @@ func (Stats) Edges() []ent.Edge {
|
|||||||
edge.From("matches", Match.Type).Ref("stats").Unique().Field("match_stats"),
|
edge.From("matches", Match.Type).Ref("stats").Unique().Field("match_stats"),
|
||||||
edge.From("players", Player.Type).Ref("stats").Unique().Field("player_stats"),
|
edge.From("players", Player.Type).Ref("stats").Unique().Field("player_stats"),
|
||||||
edge.To("weapon_stats", WeaponStats.Type),
|
edge.To("weapon_stats", WeaponStats.Type),
|
||||||
|
edge.To("round_stats", RoundStats.Type),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
18
ent/stats.go
18
ent/stats.go
@@ -108,9 +108,11 @@ type StatsEdges struct {
|
|||||||
Players *Player `json:"players,omitempty"`
|
Players *Player `json:"players,omitempty"`
|
||||||
// WeaponStats holds the value of the weapon_stats edge.
|
// WeaponStats holds the value of the weapon_stats edge.
|
||||||
WeaponStats []*WeaponStats `json:"weapon_stats,omitempty"`
|
WeaponStats []*WeaponStats `json:"weapon_stats,omitempty"`
|
||||||
|
// RoundStats holds the value of the round_stats edge.
|
||||||
|
RoundStats []*RoundStats `json:"round_stats,omitempty"`
|
||||||
// loadedTypes holds the information for reporting if a
|
// loadedTypes holds the information for reporting if a
|
||||||
// type was loaded (or requested) in eager-loading or not.
|
// type was loaded (or requested) in eager-loading or not.
|
||||||
loadedTypes [3]bool
|
loadedTypes [4]bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// MatchesOrErr returns the Matches value or an error if the edge
|
// MatchesOrErr returns the Matches value or an error if the edge
|
||||||
@@ -150,6 +152,15 @@ func (e StatsEdges) WeaponStatsOrErr() ([]*WeaponStats, error) {
|
|||||||
return nil, &NotLoadedError{edge: "weapon_stats"}
|
return nil, &NotLoadedError{edge: "weapon_stats"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RoundStatsOrErr returns the RoundStats value or an error if the edge
|
||||||
|
// was not loaded in eager-loading.
|
||||||
|
func (e StatsEdges) RoundStatsOrErr() ([]*RoundStats, error) {
|
||||||
|
if e.loadedTypes[3] {
|
||||||
|
return e.RoundStats, nil
|
||||||
|
}
|
||||||
|
return nil, &NotLoadedError{edge: "round_stats"}
|
||||||
|
}
|
||||||
|
|
||||||
// scanValues returns the types for scanning values from sql.Rows.
|
// scanValues returns the types for scanning values from sql.Rows.
|
||||||
func (*Stats) scanValues(columns []string) ([]interface{}, error) {
|
func (*Stats) scanValues(columns []string) ([]interface{}, error) {
|
||||||
values := make([]interface{}, len(columns))
|
values := make([]interface{}, len(columns))
|
||||||
@@ -436,6 +447,11 @@ func (s *Stats) QueryWeaponStats() *WeaponStatsQuery {
|
|||||||
return (&StatsClient{config: s.config}).QueryWeaponStats(s)
|
return (&StatsClient{config: s.config}).QueryWeaponStats(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// QueryRoundStats queries the "round_stats" edge of the Stats entity.
|
||||||
|
func (s *Stats) QueryRoundStats() *RoundStatsQuery {
|
||||||
|
return (&StatsClient{config: s.config}).QueryRoundStats(s)
|
||||||
|
}
|
||||||
|
|
||||||
// Update returns a builder for updating this Stats.
|
// Update returns a builder for updating this Stats.
|
||||||
// Note that you need to call Stats.Unwrap() before calling this method if this Stats
|
// Note that you need to call Stats.Unwrap() before calling this method if this Stats
|
||||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||||
|
@@ -95,6 +95,8 @@ const (
|
|||||||
EdgePlayers = "players"
|
EdgePlayers = "players"
|
||||||
// EdgeWeaponStats holds the string denoting the weapon_stats edge name in mutations.
|
// EdgeWeaponStats holds the string denoting the weapon_stats edge name in mutations.
|
||||||
EdgeWeaponStats = "weapon_stats"
|
EdgeWeaponStats = "weapon_stats"
|
||||||
|
// EdgeRoundStats holds the string denoting the round_stats edge name in mutations.
|
||||||
|
EdgeRoundStats = "round_stats"
|
||||||
// Table holds the table name of the stats in the database.
|
// Table holds the table name of the stats in the database.
|
||||||
Table = "stats"
|
Table = "stats"
|
||||||
// MatchesTable is the table that holds the matches relation/edge.
|
// MatchesTable is the table that holds the matches relation/edge.
|
||||||
@@ -118,6 +120,13 @@ const (
|
|||||||
WeaponStatsInverseTable = "weapon_stats"
|
WeaponStatsInverseTable = "weapon_stats"
|
||||||
// WeaponStatsColumn is the table column denoting the weapon_stats relation/edge.
|
// WeaponStatsColumn is the table column denoting the weapon_stats relation/edge.
|
||||||
WeaponStatsColumn = "stats_weapon_stats"
|
WeaponStatsColumn = "stats_weapon_stats"
|
||||||
|
// RoundStatsTable is the table that holds the round_stats relation/edge.
|
||||||
|
RoundStatsTable = "round_stats"
|
||||||
|
// RoundStatsInverseTable is the table name for the RoundStats entity.
|
||||||
|
// It exists in this package in order to avoid circular dependency with the "roundstats" package.
|
||||||
|
RoundStatsInverseTable = "round_stats"
|
||||||
|
// RoundStatsColumn is the table column denoting the round_stats relation/edge.
|
||||||
|
RoundStatsColumn = "stats_round_stats"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Columns holds all SQL columns for stats fields.
|
// Columns holds all SQL columns for stats fields.
|
||||||
|
@@ -3805,6 +3805,34 @@ func HasWeaponStatsWith(preds ...predicate.WeaponStats) predicate.Stats {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HasRoundStats applies the HasEdge predicate on the "round_stats" edge.
|
||||||
|
func HasRoundStats() predicate.Stats {
|
||||||
|
return predicate.Stats(func(s *sql.Selector) {
|
||||||
|
step := sqlgraph.NewStep(
|
||||||
|
sqlgraph.From(Table, FieldID),
|
||||||
|
sqlgraph.To(RoundStatsTable, FieldID),
|
||||||
|
sqlgraph.Edge(sqlgraph.O2M, false, RoundStatsTable, RoundStatsColumn),
|
||||||
|
)
|
||||||
|
sqlgraph.HasNeighbors(s, step)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasRoundStatsWith applies the HasEdge predicate on the "round_stats" edge with a given conditions (other predicates).
|
||||||
|
func HasRoundStatsWith(preds ...predicate.RoundStats) predicate.Stats {
|
||||||
|
return predicate.Stats(func(s *sql.Selector) {
|
||||||
|
step := sqlgraph.NewStep(
|
||||||
|
sqlgraph.From(Table, FieldID),
|
||||||
|
sqlgraph.To(RoundStatsInverseTable, FieldID),
|
||||||
|
sqlgraph.Edge(sqlgraph.O2M, false, RoundStatsTable, RoundStatsColumn),
|
||||||
|
)
|
||||||
|
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||||
|
for _, p := range preds {
|
||||||
|
p(s)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// And groups predicates with the AND operator between them.
|
// And groups predicates with the AND operator between them.
|
||||||
func And(predicates ...predicate.Stats) predicate.Stats {
|
func And(predicates ...predicate.Stats) predicate.Stats {
|
||||||
return predicate.Stats(func(s *sql.Selector) {
|
return predicate.Stats(func(s *sql.Selector) {
|
||||||
|
@@ -6,6 +6,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"csgowtfd/ent/match"
|
"csgowtfd/ent/match"
|
||||||
"csgowtfd/ent/player"
|
"csgowtfd/ent/player"
|
||||||
|
"csgowtfd/ent/roundstats"
|
||||||
"csgowtfd/ent/stats"
|
"csgowtfd/ent/stats"
|
||||||
"csgowtfd/ent/weaponstats"
|
"csgowtfd/ent/weaponstats"
|
||||||
"errors"
|
"errors"
|
||||||
@@ -565,6 +566,21 @@ func (sc *StatsCreate) AddWeaponStats(w ...*WeaponStats) *StatsCreate {
|
|||||||
return sc.AddWeaponStatIDs(ids...)
|
return sc.AddWeaponStatIDs(ids...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddRoundStatIDs adds the "round_stats" edge to the RoundStats entity by IDs.
|
||||||
|
func (sc *StatsCreate) AddRoundStatIDs(ids ...int) *StatsCreate {
|
||||||
|
sc.mutation.AddRoundStatIDs(ids...)
|
||||||
|
return sc
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddRoundStats adds the "round_stats" edges to the RoundStats entity.
|
||||||
|
func (sc *StatsCreate) AddRoundStats(r ...*RoundStats) *StatsCreate {
|
||||||
|
ids := make([]int, len(r))
|
||||||
|
for i := range r {
|
||||||
|
ids[i] = r[i].ID
|
||||||
|
}
|
||||||
|
return sc.AddRoundStatIDs(ids...)
|
||||||
|
}
|
||||||
|
|
||||||
// Mutation returns the StatsMutation object of the builder.
|
// Mutation returns the StatsMutation object of the builder.
|
||||||
func (sc *StatsCreate) Mutation() *StatsMutation {
|
func (sc *StatsCreate) Mutation() *StatsMutation {
|
||||||
return sc.mutation
|
return sc.mutation
|
||||||
@@ -1043,6 +1059,25 @@ func (sc *StatsCreate) createSpec() (*Stats, *sqlgraph.CreateSpec) {
|
|||||||
}
|
}
|
||||||
_spec.Edges = append(_spec.Edges, edge)
|
_spec.Edges = append(_spec.Edges, edge)
|
||||||
}
|
}
|
||||||
|
if nodes := sc.mutation.RoundStatsIDs(); len(nodes) > 0 {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.O2M,
|
||||||
|
Inverse: false,
|
||||||
|
Table: stats.RoundStatsTable,
|
||||||
|
Columns: []string{stats.RoundStatsColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeInt,
|
||||||
|
Column: roundstats.FieldID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, k := range nodes {
|
||||||
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||||
|
}
|
||||||
|
_spec.Edges = append(_spec.Edges, edge)
|
||||||
|
}
|
||||||
return _node, _spec
|
return _node, _spec
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -7,6 +7,7 @@ import (
|
|||||||
"csgowtfd/ent/match"
|
"csgowtfd/ent/match"
|
||||||
"csgowtfd/ent/player"
|
"csgowtfd/ent/player"
|
||||||
"csgowtfd/ent/predicate"
|
"csgowtfd/ent/predicate"
|
||||||
|
"csgowtfd/ent/roundstats"
|
||||||
"csgowtfd/ent/stats"
|
"csgowtfd/ent/stats"
|
||||||
"csgowtfd/ent/weaponstats"
|
"csgowtfd/ent/weaponstats"
|
||||||
"database/sql/driver"
|
"database/sql/driver"
|
||||||
@@ -32,6 +33,7 @@ type StatsQuery struct {
|
|||||||
withMatches *MatchQuery
|
withMatches *MatchQuery
|
||||||
withPlayers *PlayerQuery
|
withPlayers *PlayerQuery
|
||||||
withWeaponStats *WeaponStatsQuery
|
withWeaponStats *WeaponStatsQuery
|
||||||
|
withRoundStats *RoundStatsQuery
|
||||||
modifiers []func(s *sql.Selector)
|
modifiers []func(s *sql.Selector)
|
||||||
// intermediate query (i.e. traversal path).
|
// intermediate query (i.e. traversal path).
|
||||||
sql *sql.Selector
|
sql *sql.Selector
|
||||||
@@ -135,6 +137,28 @@ func (sq *StatsQuery) QueryWeaponStats() *WeaponStatsQuery {
|
|||||||
return query
|
return query
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// QueryRoundStats chains the current query on the "round_stats" edge.
|
||||||
|
func (sq *StatsQuery) QueryRoundStats() *RoundStatsQuery {
|
||||||
|
query := &RoundStatsQuery{config: sq.config}
|
||||||
|
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||||
|
if err := sq.prepareQuery(ctx); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
selector := sq.sqlQuery(ctx)
|
||||||
|
if err := selector.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
step := sqlgraph.NewStep(
|
||||||
|
sqlgraph.From(stats.Table, stats.FieldID, selector),
|
||||||
|
sqlgraph.To(roundstats.Table, roundstats.FieldID),
|
||||||
|
sqlgraph.Edge(sqlgraph.O2M, false, stats.RoundStatsTable, stats.RoundStatsColumn),
|
||||||
|
)
|
||||||
|
fromU = sqlgraph.SetNeighbors(sq.driver.Dialect(), step)
|
||||||
|
return fromU, nil
|
||||||
|
}
|
||||||
|
return query
|
||||||
|
}
|
||||||
|
|
||||||
// First returns the first Stats entity from the query.
|
// First returns the first Stats entity from the query.
|
||||||
// Returns a *NotFoundError when no Stats was found.
|
// Returns a *NotFoundError when no Stats was found.
|
||||||
func (sq *StatsQuery) First(ctx context.Context) (*Stats, error) {
|
func (sq *StatsQuery) First(ctx context.Context) (*Stats, error) {
|
||||||
@@ -319,6 +343,7 @@ func (sq *StatsQuery) Clone() *StatsQuery {
|
|||||||
withMatches: sq.withMatches.Clone(),
|
withMatches: sq.withMatches.Clone(),
|
||||||
withPlayers: sq.withPlayers.Clone(),
|
withPlayers: sq.withPlayers.Clone(),
|
||||||
withWeaponStats: sq.withWeaponStats.Clone(),
|
withWeaponStats: sq.withWeaponStats.Clone(),
|
||||||
|
withRoundStats: sq.withRoundStats.Clone(),
|
||||||
// clone intermediate query.
|
// clone intermediate query.
|
||||||
sql: sq.sql.Clone(),
|
sql: sq.sql.Clone(),
|
||||||
path: sq.path,
|
path: sq.path,
|
||||||
@@ -358,6 +383,17 @@ func (sq *StatsQuery) WithWeaponStats(opts ...func(*WeaponStatsQuery)) *StatsQue
|
|||||||
return sq
|
return sq
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithRoundStats tells the query-builder to eager-load the nodes that are connected to
|
||||||
|
// the "round_stats" edge. The optional arguments are used to configure the query builder of the edge.
|
||||||
|
func (sq *StatsQuery) WithRoundStats(opts ...func(*RoundStatsQuery)) *StatsQuery {
|
||||||
|
query := &RoundStatsQuery{config: sq.config}
|
||||||
|
for _, opt := range opts {
|
||||||
|
opt(query)
|
||||||
|
}
|
||||||
|
sq.withRoundStats = query
|
||||||
|
return sq
|
||||||
|
}
|
||||||
|
|
||||||
// GroupBy is used to group vertices by one or more fields/columns.
|
// GroupBy is used to group vertices by one or more fields/columns.
|
||||||
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||||
//
|
//
|
||||||
@@ -423,10 +459,11 @@ func (sq *StatsQuery) sqlAll(ctx context.Context) ([]*Stats, error) {
|
|||||||
var (
|
var (
|
||||||
nodes = []*Stats{}
|
nodes = []*Stats{}
|
||||||
_spec = sq.querySpec()
|
_spec = sq.querySpec()
|
||||||
loadedTypes = [3]bool{
|
loadedTypes = [4]bool{
|
||||||
sq.withMatches != nil,
|
sq.withMatches != nil,
|
||||||
sq.withPlayers != nil,
|
sq.withPlayers != nil,
|
||||||
sq.withWeaponStats != nil,
|
sq.withWeaponStats != nil,
|
||||||
|
sq.withRoundStats != nil,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
_spec.ScanValues = func(columns []string) ([]interface{}, error) {
|
_spec.ScanValues = func(columns []string) ([]interface{}, error) {
|
||||||
@@ -533,6 +570,35 @@ func (sq *StatsQuery) sqlAll(ctx context.Context) ([]*Stats, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if query := sq.withRoundStats; query != nil {
|
||||||
|
fks := make([]driver.Value, 0, len(nodes))
|
||||||
|
nodeids := make(map[int]*Stats)
|
||||||
|
for i := range nodes {
|
||||||
|
fks = append(fks, nodes[i].ID)
|
||||||
|
nodeids[nodes[i].ID] = nodes[i]
|
||||||
|
nodes[i].Edges.RoundStats = []*RoundStats{}
|
||||||
|
}
|
||||||
|
query.withFKs = true
|
||||||
|
query.Where(predicate.RoundStats(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.InValues(stats.RoundStatsColumn, fks...))
|
||||||
|
}))
|
||||||
|
neighbors, err := query.All(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, n := range neighbors {
|
||||||
|
fk := n.stats_round_stats
|
||||||
|
if fk == nil {
|
||||||
|
return nil, fmt.Errorf(`foreign-key "stats_round_stats" is nil for node %v`, n.ID)
|
||||||
|
}
|
||||||
|
node, ok := nodeids[*fk]
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf(`unexpected foreign-key "stats_round_stats" returned %v for node %v`, *fk, n.ID)
|
||||||
|
}
|
||||||
|
node.Edges.RoundStats = append(node.Edges.RoundStats, n)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nodes, nil
|
return nodes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -7,6 +7,7 @@ import (
|
|||||||
"csgowtfd/ent/match"
|
"csgowtfd/ent/match"
|
||||||
"csgowtfd/ent/player"
|
"csgowtfd/ent/player"
|
||||||
"csgowtfd/ent/predicate"
|
"csgowtfd/ent/predicate"
|
||||||
|
"csgowtfd/ent/roundstats"
|
||||||
"csgowtfd/ent/stats"
|
"csgowtfd/ent/stats"
|
||||||
"csgowtfd/ent/weaponstats"
|
"csgowtfd/ent/weaponstats"
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -1009,6 +1010,21 @@ func (su *StatsUpdate) AddWeaponStats(w ...*WeaponStats) *StatsUpdate {
|
|||||||
return su.AddWeaponStatIDs(ids...)
|
return su.AddWeaponStatIDs(ids...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddRoundStatIDs adds the "round_stats" edge to the RoundStats entity by IDs.
|
||||||
|
func (su *StatsUpdate) AddRoundStatIDs(ids ...int) *StatsUpdate {
|
||||||
|
su.mutation.AddRoundStatIDs(ids...)
|
||||||
|
return su
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddRoundStats adds the "round_stats" edges to the RoundStats entity.
|
||||||
|
func (su *StatsUpdate) AddRoundStats(r ...*RoundStats) *StatsUpdate {
|
||||||
|
ids := make([]int, len(r))
|
||||||
|
for i := range r {
|
||||||
|
ids[i] = r[i].ID
|
||||||
|
}
|
||||||
|
return su.AddRoundStatIDs(ids...)
|
||||||
|
}
|
||||||
|
|
||||||
// Mutation returns the StatsMutation object of the builder.
|
// Mutation returns the StatsMutation object of the builder.
|
||||||
func (su *StatsUpdate) Mutation() *StatsMutation {
|
func (su *StatsUpdate) Mutation() *StatsMutation {
|
||||||
return su.mutation
|
return su.mutation
|
||||||
@@ -1047,6 +1063,27 @@ func (su *StatsUpdate) RemoveWeaponStats(w ...*WeaponStats) *StatsUpdate {
|
|||||||
return su.RemoveWeaponStatIDs(ids...)
|
return su.RemoveWeaponStatIDs(ids...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ClearRoundStats clears all "round_stats" edges to the RoundStats entity.
|
||||||
|
func (su *StatsUpdate) ClearRoundStats() *StatsUpdate {
|
||||||
|
su.mutation.ClearRoundStats()
|
||||||
|
return su
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveRoundStatIDs removes the "round_stats" edge to RoundStats entities by IDs.
|
||||||
|
func (su *StatsUpdate) RemoveRoundStatIDs(ids ...int) *StatsUpdate {
|
||||||
|
su.mutation.RemoveRoundStatIDs(ids...)
|
||||||
|
return su
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveRoundStats removes "round_stats" edges to RoundStats entities.
|
||||||
|
func (su *StatsUpdate) RemoveRoundStats(r ...*RoundStats) *StatsUpdate {
|
||||||
|
ids := make([]int, len(r))
|
||||||
|
for i := range r {
|
||||||
|
ids[i] = r[i].ID
|
||||||
|
}
|
||||||
|
return su.RemoveRoundStatIDs(ids...)
|
||||||
|
}
|
||||||
|
|
||||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||||
func (su *StatsUpdate) Save(ctx context.Context) (int, error) {
|
func (su *StatsUpdate) Save(ctx context.Context) (int, error) {
|
||||||
var (
|
var (
|
||||||
@@ -1943,6 +1980,60 @@ func (su *StatsUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|||||||
}
|
}
|
||||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||||
}
|
}
|
||||||
|
if su.mutation.RoundStatsCleared() {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.O2M,
|
||||||
|
Inverse: false,
|
||||||
|
Table: stats.RoundStatsTable,
|
||||||
|
Columns: []string{stats.RoundStatsColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeInt,
|
||||||
|
Column: roundstats.FieldID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||||
|
}
|
||||||
|
if nodes := su.mutation.RemovedRoundStatsIDs(); len(nodes) > 0 && !su.mutation.RoundStatsCleared() {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.O2M,
|
||||||
|
Inverse: false,
|
||||||
|
Table: stats.RoundStatsTable,
|
||||||
|
Columns: []string{stats.RoundStatsColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeInt,
|
||||||
|
Column: roundstats.FieldID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, k := range nodes {
|
||||||
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||||
|
}
|
||||||
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||||
|
}
|
||||||
|
if nodes := su.mutation.RoundStatsIDs(); len(nodes) > 0 {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.O2M,
|
||||||
|
Inverse: false,
|
||||||
|
Table: stats.RoundStatsTable,
|
||||||
|
Columns: []string{stats.RoundStatsColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeInt,
|
||||||
|
Column: roundstats.FieldID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, k := range nodes {
|
||||||
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||||
|
}
|
||||||
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||||
|
}
|
||||||
if n, err = sqlgraph.UpdateNodes(ctx, su.driver, _spec); err != nil {
|
if n, err = sqlgraph.UpdateNodes(ctx, su.driver, _spec); err != nil {
|
||||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
err = &NotFoundError{stats.Label}
|
err = &NotFoundError{stats.Label}
|
||||||
@@ -2942,6 +3033,21 @@ func (suo *StatsUpdateOne) AddWeaponStats(w ...*WeaponStats) *StatsUpdateOne {
|
|||||||
return suo.AddWeaponStatIDs(ids...)
|
return suo.AddWeaponStatIDs(ids...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddRoundStatIDs adds the "round_stats" edge to the RoundStats entity by IDs.
|
||||||
|
func (suo *StatsUpdateOne) AddRoundStatIDs(ids ...int) *StatsUpdateOne {
|
||||||
|
suo.mutation.AddRoundStatIDs(ids...)
|
||||||
|
return suo
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddRoundStats adds the "round_stats" edges to the RoundStats entity.
|
||||||
|
func (suo *StatsUpdateOne) AddRoundStats(r ...*RoundStats) *StatsUpdateOne {
|
||||||
|
ids := make([]int, len(r))
|
||||||
|
for i := range r {
|
||||||
|
ids[i] = r[i].ID
|
||||||
|
}
|
||||||
|
return suo.AddRoundStatIDs(ids...)
|
||||||
|
}
|
||||||
|
|
||||||
// Mutation returns the StatsMutation object of the builder.
|
// Mutation returns the StatsMutation object of the builder.
|
||||||
func (suo *StatsUpdateOne) Mutation() *StatsMutation {
|
func (suo *StatsUpdateOne) Mutation() *StatsMutation {
|
||||||
return suo.mutation
|
return suo.mutation
|
||||||
@@ -2980,6 +3086,27 @@ func (suo *StatsUpdateOne) RemoveWeaponStats(w ...*WeaponStats) *StatsUpdateOne
|
|||||||
return suo.RemoveWeaponStatIDs(ids...)
|
return suo.RemoveWeaponStatIDs(ids...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ClearRoundStats clears all "round_stats" edges to the RoundStats entity.
|
||||||
|
func (suo *StatsUpdateOne) ClearRoundStats() *StatsUpdateOne {
|
||||||
|
suo.mutation.ClearRoundStats()
|
||||||
|
return suo
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveRoundStatIDs removes the "round_stats" edge to RoundStats entities by IDs.
|
||||||
|
func (suo *StatsUpdateOne) RemoveRoundStatIDs(ids ...int) *StatsUpdateOne {
|
||||||
|
suo.mutation.RemoveRoundStatIDs(ids...)
|
||||||
|
return suo
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveRoundStats removes "round_stats" edges to RoundStats entities.
|
||||||
|
func (suo *StatsUpdateOne) RemoveRoundStats(r ...*RoundStats) *StatsUpdateOne {
|
||||||
|
ids := make([]int, len(r))
|
||||||
|
for i := range r {
|
||||||
|
ids[i] = r[i].ID
|
||||||
|
}
|
||||||
|
return suo.RemoveRoundStatIDs(ids...)
|
||||||
|
}
|
||||||
|
|
||||||
// Select allows selecting one or more fields (columns) of the returned entity.
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||||
// The default is selecting all fields defined in the entity schema.
|
// The default is selecting all fields defined in the entity schema.
|
||||||
func (suo *StatsUpdateOne) Select(field string, fields ...string) *StatsUpdateOne {
|
func (suo *StatsUpdateOne) Select(field string, fields ...string) *StatsUpdateOne {
|
||||||
@@ -3900,6 +4027,60 @@ func (suo *StatsUpdateOne) sqlSave(ctx context.Context) (_node *Stats, err error
|
|||||||
}
|
}
|
||||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||||
}
|
}
|
||||||
|
if suo.mutation.RoundStatsCleared() {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.O2M,
|
||||||
|
Inverse: false,
|
||||||
|
Table: stats.RoundStatsTable,
|
||||||
|
Columns: []string{stats.RoundStatsColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeInt,
|
||||||
|
Column: roundstats.FieldID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||||
|
}
|
||||||
|
if nodes := suo.mutation.RemovedRoundStatsIDs(); len(nodes) > 0 && !suo.mutation.RoundStatsCleared() {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.O2M,
|
||||||
|
Inverse: false,
|
||||||
|
Table: stats.RoundStatsTable,
|
||||||
|
Columns: []string{stats.RoundStatsColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeInt,
|
||||||
|
Column: roundstats.FieldID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, k := range nodes {
|
||||||
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||||
|
}
|
||||||
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||||
|
}
|
||||||
|
if nodes := suo.mutation.RoundStatsIDs(); len(nodes) > 0 {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.O2M,
|
||||||
|
Inverse: false,
|
||||||
|
Table: stats.RoundStatsTable,
|
||||||
|
Columns: []string{stats.RoundStatsColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeInt,
|
||||||
|
Column: roundstats.FieldID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, k := range nodes {
|
||||||
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||||
|
}
|
||||||
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||||
|
}
|
||||||
_node = &Stats{config: suo.config}
|
_node = &Stats{config: suo.config}
|
||||||
_spec.Assign = _node.assignValues
|
_spec.Assign = _node.assignValues
|
||||||
_spec.ScanValues = _node.scanValues
|
_spec.ScanValues = _node.scanValues
|
||||||
|
@@ -16,6 +16,8 @@ type Tx struct {
|
|||||||
Match *MatchClient
|
Match *MatchClient
|
||||||
// Player is the client for interacting with the Player builders.
|
// Player is the client for interacting with the Player builders.
|
||||||
Player *PlayerClient
|
Player *PlayerClient
|
||||||
|
// RoundStats is the client for interacting with the RoundStats builders.
|
||||||
|
RoundStats *RoundStatsClient
|
||||||
// Stats is the client for interacting with the Stats builders.
|
// Stats is the client for interacting with the Stats builders.
|
||||||
Stats *StatsClient
|
Stats *StatsClient
|
||||||
// WeaponStats is the client for interacting with the WeaponStats builders.
|
// WeaponStats is the client for interacting with the WeaponStats builders.
|
||||||
@@ -157,6 +159,7 @@ func (tx *Tx) Client() *Client {
|
|||||||
func (tx *Tx) init() {
|
func (tx *Tx) init() {
|
||||||
tx.Match = NewMatchClient(tx.config)
|
tx.Match = NewMatchClient(tx.config)
|
||||||
tx.Player = NewPlayerClient(tx.config)
|
tx.Player = NewPlayerClient(tx.config)
|
||||||
|
tx.RoundStats = NewRoundStatsClient(tx.config)
|
||||||
tx.Stats = NewStatsClient(tx.config)
|
tx.Stats = NewStatsClient(tx.config)
|
||||||
tx.WeaponStats = NewWeaponStatsClient(tx.config)
|
tx.WeaponStats = NewWeaponStatsClient(tx.config)
|
||||||
}
|
}
|
||||||
|
2
go.mod
2
go.mod
@@ -4,8 +4,8 @@ go 1.17
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
entgo.io/ent v0.9.1
|
entgo.io/ent v0.9.1
|
||||||
github.com/Philipp15b/go-steamapi v0.0.0-20210114153316-ec4fdd23b4c1
|
|
||||||
github.com/an0nfunc/go-steam/v3 v3.0.1
|
github.com/an0nfunc/go-steam/v3 v3.0.1
|
||||||
|
github.com/an0nfunc/go-steamapi v1.0.0
|
||||||
github.com/go-redis/cache/v8 v8.4.3
|
github.com/go-redis/cache/v8 v8.4.3
|
||||||
github.com/go-redis/redis/v8 v8.11.4
|
github.com/go-redis/redis/v8 v8.11.4
|
||||||
github.com/gorilla/handlers v1.5.1
|
github.com/gorilla/handlers v1.5.1
|
||||||
|
4
go.sum
4
go.sum
@@ -20,8 +20,6 @@ github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20O
|
|||||||
github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
|
github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
|
||||||
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
|
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
|
||||||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
||||||
github.com/Philipp15b/go-steamapi v0.0.0-20210114153316-ec4fdd23b4c1 h1:PD13eMe9XAgPQ0SYWyirqwyOJG90TlEWApCw8A699l0=
|
|
||||||
github.com/Philipp15b/go-steamapi v0.0.0-20210114153316-ec4fdd23b4c1/go.mod h1:eQR7Xf64m2ALDAQE7Nr9ylFZhav1izvF3zzysKPhb0I=
|
|
||||||
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
|
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
|
||||||
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
|
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
|
||||||
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
|
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
|
||||||
@@ -32,6 +30,8 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF
|
|||||||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||||
github.com/an0nfunc/go-steam/v3 v3.0.1 h1:Sc/B8R3454Q3f8r/LyKX7iTK7Saiw8EiQTKyGVwn6D0=
|
github.com/an0nfunc/go-steam/v3 v3.0.1 h1:Sc/B8R3454Q3f8r/LyKX7iTK7Saiw8EiQTKyGVwn6D0=
|
||||||
github.com/an0nfunc/go-steam/v3 v3.0.1/go.mod h1:HnlYcTVnAJbSlyzC5lxft9jQOu2mjTw8LHfN/bYuDEs=
|
github.com/an0nfunc/go-steam/v3 v3.0.1/go.mod h1:HnlYcTVnAJbSlyzC5lxft9jQOu2mjTw8LHfN/bYuDEs=
|
||||||
|
github.com/an0nfunc/go-steamapi v1.0.0 h1:J8Ytya/3q7Dm/t4EnDqEqavt+DWUOEVOQTjukv8kx9s=
|
||||||
|
github.com/an0nfunc/go-steamapi v1.0.0/go.mod h1:tInHdrGkh0gaXuPnvhMG4BoW9S5gVcWOY9gJ9gCBKOI=
|
||||||
github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129 h1:MzBOUgng9orim59UnfUTLRjMpd09C5uEVQ6RPGeCaVI=
|
github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129 h1:MzBOUgng9orim59UnfUTLRjMpd09C5uEVQ6RPGeCaVI=
|
||||||
github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129/go.mod h1:rFgpPQZYZ8vdbc+48xibu8ALc3yeyd64IhHS+PU6Yyg=
|
github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129/go.mod h1:rFgpPQZYZ8vdbc+48xibu8ALc3yeyd64IhHS+PU6Yyg=
|
||||||
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
||||||
|
4
main.go
4
main.go
@@ -136,7 +136,7 @@ func getPlayer(w http.ResponseWriter, r *http.Request) {
|
|||||||
response := utils.PlayerResponse{
|
response := utils.PlayerResponse{
|
||||||
SteamID64: tPlayer.ID,
|
SteamID64: tPlayer.ID,
|
||||||
Name: tPlayer.Name,
|
Name: tPlayer.Name,
|
||||||
Avatar: tPlayer.AvatarURL,
|
Avatar: tPlayer.Avatar,
|
||||||
VAC: tPlayer.Vac,
|
VAC: tPlayer.Vac,
|
||||||
VanityURL: tPlayer.VanityURLReal,
|
VanityURL: tPlayer.VanityURLReal,
|
||||||
Tracked: tPlayer.AuthCode != "",
|
Tracked: tPlayer.AuthCode != "",
|
||||||
@@ -444,7 +444,7 @@ func getMatch(w http.ResponseWriter, r *http.Request) {
|
|||||||
Player: utils.PlayerResponse{
|
Player: utils.PlayerResponse{
|
||||||
SteamID64: iStats.Edges.Players.ID,
|
SteamID64: iStats.Edges.Players.ID,
|
||||||
Name: iStats.Edges.Players.Name,
|
Name: iStats.Edges.Players.Name,
|
||||||
Avatar: iStats.Edges.Players.AvatarURL,
|
Avatar: iStats.Edges.Players.Avatar,
|
||||||
VAC: iStats.Edges.Players.Vac,
|
VAC: iStats.Edges.Players.Vac,
|
||||||
VanityURL: iStats.Edges.Players.VanityURLReal,
|
VanityURL: iStats.Edges.Players.VanityURLReal,
|
||||||
Tracked: iStats.Edges.Players.AuthCode != "",
|
Tracked: iStats.Edges.Players.AuthCode != "",
|
||||||
|
@@ -9,7 +9,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"entgo.io/ent/dialect/sql"
|
"entgo.io/ent/dialect/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/Philipp15b/go-steamapi"
|
"github.com/an0nfunc/go-steamapi"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"go.uber.org/ratelimit"
|
"go.uber.org/ratelimit"
|
||||||
"io"
|
"io"
|
||||||
@@ -455,7 +455,7 @@ func UpdatePlayerFromSteam(players []*ent.Player, db *ent.Client, apiKey string,
|
|||||||
lock.Lock()
|
lock.Lock()
|
||||||
tPlayer, err := db.Player.UpdateOneID(pS.SteamID).
|
tPlayer, err := db.Player.UpdateOneID(pS.SteamID).
|
||||||
SetName(pS.PersonaName).
|
SetName(pS.PersonaName).
|
||||||
SetAvatarURL(pS.LargeAvatarURL).
|
SetAvatar(pS.AvatarHash).
|
||||||
SetSteamUpdated(time.Now().UTC()).
|
SetSteamUpdated(time.Now().UTC()).
|
||||||
SetVanityURL(strings.ToLower(pS.ProfileURL)).
|
SetVanityURL(strings.ToLower(pS.ProfileURL)).
|
||||||
SetVanityURLReal(pS.ProfileURL).
|
SetVanityURLReal(pS.ProfileURL).
|
||||||
|
Reference in New Issue
Block a user