diff --git a/csgo/demo_loader.go b/csgo/demo_loader.go index 69bed1a..de393fd 100644 --- a/csgo/demo_loader.go +++ b/csgo/demo_loader.go @@ -418,7 +418,7 @@ func (d *DemoMatchLoader) gcWorker(apiKey string, rl ratelimit.Limiter) { SetKills(int(lastRound.GetKills()[i])). SetDeaths(int(lastRound.GetDeaths()[i])). SetAssists(int(lastRound.GetAssists()[i])). - SetMvp(int(lastRound.GetMvps()[i])). + SetMvp(uint(lastRound.GetMvps()[i])). SetScore(int(lastRound.GetScores()[i])). SetHeadshot(int(lastRound.GetEnemyHeadshots()[i])). Exec(context.Background()) diff --git a/csgo/demo_parser.go b/csgo/demo_parser.go index 60994f9..ab621a2 100644 --- a/csgo/demo_parser.go +++ b/csgo/demo_parser.go @@ -6,6 +6,7 @@ import ( "csgowtfd/ent" "csgowtfd/ent/match" "csgowtfd/ent/player" + "csgowtfd/ent/stats" "fmt" "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs" "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/common" @@ -143,53 +144,52 @@ func (p *DemoParser) parseWorker() { } killMap := make(map[uint64]int, 10) + eqMap := make(map[uint64][]*struct { + Eq int + HitGroup int + Dmg uint + To uint64 + }) gameStarted := false demoParser := demoinfocs.NewParser(fDemo) // onPlayerHurt demoParser.RegisterEventHandler(func(e events.PlayerHurt) { - if e.Attacker == nil || e.Player == nil || !gameStarted { + if e.Attacker == nil || e.Player == nil || e.Weapon == nil || !gameStarted { return } tAttacker := p.getMatchPlayerBySteamID(tStats, e.Attacker.SteamID64) if e.Attacker.Team == e.Player.Team { - tAttacker.Extended.Dmg.Team += e.HealthDamageTaken - return + tAttacker.DmgTeam += uint(e.HealthDamageTaken) } else { - tAttacker.Extended.Dmg.Enemy += e.HealthDamageTaken + tAttacker.DmgEnemy += uint(e.HealthDamageTaken) } - switch e.Weapon.Type { - case common.EqDecoy: - tAttacker.Extended.Dmg.UD.Decoy += e.HealthDamageTaken - case common.EqSmoke: - tAttacker.Extended.Dmg.UD.Smoke += e.HealthDamageTaken - case common.EqHE: - tAttacker.Extended.Dmg.UD.HE += e.HealthDamageTaken - case common.EqMolotov, common.EqIncendiary: - tAttacker.Extended.Dmg.UD.Flames += e.HealthDamageTaken - case common.EqFlash: - tAttacker.Extended.Dmg.UD.Flash += e.HealthDamageTaken + if _, ok := eqMap[e.Attacker.SteamID64]; !ok { + eqMap[e.Attacker.SteamID64] = make([]*struct { + Eq int + HitGroup int + Dmg uint + To uint64 + }, 0) } - switch e.HitGroup { - case events.HitGroupHead: - tAttacker.Extended.Dmg.HitGroup.Head += e.HealthDamageTaken - case events.HitGroupChest: - tAttacker.Extended.Dmg.HitGroup.Chest += e.HealthDamageTaken - case events.HitGroupStomach: - tAttacker.Extended.Dmg.HitGroup.Stomach += e.HealthDamageTaken - case events.HitGroupLeftArm: - tAttacker.Extended.Dmg.HitGroup.LeftArm += e.HealthDamageTaken - case events.HitGroupRightArm: - tAttacker.Extended.Dmg.HitGroup.RightArm += e.HealthDamageTaken - case events.HitGroupLeftLeg: - tAttacker.Extended.Dmg.HitGroup.LeftLeg += e.HealthDamageTaken - case events.HitGroupRightLeg: - tAttacker.Extended.Dmg.HitGroup.RightLeg += e.HealthDamageTaken - case events.HitGroupGear: - tAttacker.Extended.Dmg.HitGroup.Gear += e.HealthDamageTaken + found := false + for _, di := range eqMap[e.Attacker.SteamID64] { + if di.Eq == int(e.Weapon.Type) && di.HitGroup == int(e.HitGroup) { + di.Dmg += uint(e.HealthDamageTaken) + found = true + } + } + + if !found { + eqMap[e.Attacker.SteamID64] = append(eqMap[e.Attacker.SteamID64], &struct { + Eq int + HitGroup int + Dmg uint + To uint64 + }{Eq: int(e.Weapon.Type), HitGroup: int(e.HitGroup), Dmg: uint(e.HealthDamageTaken), To: e.Player.SteamID64}) } }) @@ -213,13 +213,13 @@ func (p *DemoParser) parseWorker() { switch killDiff { case 2: - tPlayer.Extended.MultiKills.Duo++ + tPlayer.Mk2++ case 3: - tPlayer.Extended.MultiKills.Triple++ + tPlayer.Mk3++ case 4: - tPlayer.Extended.MultiKills.Quad++ + tPlayer.Mk4++ case 5: - tPlayer.Extended.MultiKills.Pent++ + tPlayer.Mk5++ } killMap[IGP.SteamID64] = IGP.Kills() } @@ -237,20 +237,20 @@ func (p *DemoParser) parseWorker() { // team flash if e.Attacker.Team == e.Player.Team && e.Attacker.SteamID64 != e.Player.SteamID64 { - tAttacker.Extended.Flash.Total.Team++ - tAttacker.Extended.Flash.Duration.Team += e.Player.FlashDuration + tAttacker.FlashTotalTeam++ + tAttacker.FlashDurationTeam += e.Player.FlashDuration } // own flash if e.Attacker.SteamID64 == e.Player.SteamID64 { - tAttacker.Extended.Flash.Total.Self++ - tAttacker.Extended.Flash.Duration.Self += e.Player.FlashDuration + tAttacker.FlashTotalSelf++ + tAttacker.FlashDurationSelf += e.Player.FlashDuration } // enemy flash if e.Attacker.Team != e.Player.Team { - tAttacker.Extended.Flash.Total.Enemy++ - tAttacker.Extended.Flash.Duration.Enemy += e.Player.FlashDuration + tAttacker.FlashTotalEnemy++ + tAttacker.FlashDurationEnemy += e.Player.FlashDuration } }) @@ -263,8 +263,26 @@ func (p *DemoParser) parseWorker() { if demoPlayer != nil && demoPlayer.SteamID64 != 0 { tMatchPlayer := p.getMatchPlayerBySteamID(tStats, demoPlayer.SteamID64) - tMatchPlayer.Extended.Crosshair = demoPlayer.CrosshairCode() - tMatchPlayer.Extended.Color = demoPlayer.Color().String() + tMatchPlayer.Crosshair = demoPlayer.CrosshairCode() + switch demoPlayer.Color() { + case common.Yellow: + tMatchPlayer.Color = stats.ColorYellow + break + case common.Green: + tMatchPlayer.Color = stats.ColorGreen + break + case common.Purple: + tMatchPlayer.Color = stats.ColorPurple + break + case common.Blue: + tMatchPlayer.Color = stats.ColorBlue + break + case common.Orange: + tMatchPlayer.Color = stats.ColorOrange + break + default: + tMatchPlayer.Color = stats.ColorGrey + } } } }) @@ -279,8 +297,8 @@ func (p *DemoParser) parseWorker() { if e.Player != nil && e.SteamID64() != 0 { tMatchPlayer := p.getMatchPlayerBySteamID(tStats, e.SteamID64()) - tMatchPlayer.Extended.Rank.Old = e.RankOld - tMatchPlayer.Extended.Rank.New = e.RankNew + tMatchPlayer.RankOld = e.RankOld + tMatchPlayer.RankNew = e.RankNew } }) @@ -299,13 +317,49 @@ func (p *DemoParser) parseWorker() { } for _, tMatchPlayer := range tStats { + if tMatchPlayer.Color == "" { + tMatchPlayer.Color = stats.ColorGrey + } + p.lock.Lock() - err := tMatchPlayer.Update().SetExtended(tMatchPlayer.Extended).Exec(context.Background()) + nMatchPLayer, err := tMatchPlayer.Update(). + SetDmgTeam(tMatchPlayer.DmgTeam). + SetDmgEnemy(tMatchPlayer.DmgEnemy). + SetUdHe(tMatchPlayer.UdHe). + SetUdFlash(tMatchPlayer.UdFlash). + SetUdSmoke(tMatchPlayer.UdSmoke). + SetUdFlames(tMatchPlayer.UdFlames). + SetMk2(tMatchPlayer.Mk2). + SetMk3(tMatchPlayer.Mk3). + SetMk4(tMatchPlayer.Mk4). + SetMk5(tMatchPlayer.Mk5). + SetRankOld(tMatchPlayer.RankOld). + SetRankNew(tMatchPlayer.RankNew). + SetColor(tMatchPlayer.Color). + SetCrosshair(tMatchPlayer.Crosshair). + SetFlashDurationTeam(tMatchPlayer.FlashDurationTeam). + SetFlashDurationSelf(tMatchPlayer.FlashDurationSelf). + SetFlashDurationEnemy(tMatchPlayer.FlashDurationEnemy). + SetFlashTotalEnemy(tMatchPlayer.FlashTotalEnemy). + SetFlashTotalSelf(tMatchPlayer.FlashTotalSelf). + SetFlashTotalTeam(tMatchPlayer.FlashTotalTeam). + SetDmgTeam(tMatchPlayer.DmgTeam). + SetDmgEnemy(tMatchPlayer.DmgEnemy). + Save(context.Background()) p.lock.Unlock() if err != nil { log.Errorf("[DP] Unable to update player %d in database: %v", tMatchPlayer.Edges.Players.ID, err) continue } + + for _, eqDmg := range eqMap[tMatchPlayer.PlayerStats] { + p.lock.Lock() + err := p.db.WeaponStats.Create().SetStat(nMatchPLayer).SetDmg(eqDmg.Dmg).SetVictim(eqDmg.To).SetHitGroup(eqDmg.HitGroup).SetEqType(eqDmg.Eq).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)) diff --git a/ent/client.go b/ent/client.go index caab0f9..1a447da 100644 --- a/ent/client.go +++ b/ent/client.go @@ -12,6 +12,7 @@ import ( "csgowtfd/ent/match" "csgowtfd/ent/player" "csgowtfd/ent/stats" + "csgowtfd/ent/weaponstats" "entgo.io/ent/dialect" "entgo.io/ent/dialect/sql" @@ -29,6 +30,8 @@ type Client struct { Player *PlayerClient // Stats is the client for interacting with the Stats builders. Stats *StatsClient + // WeaponStats is the client for interacting with the WeaponStats builders. + WeaponStats *WeaponStatsClient } // NewClient creates a new client configured with the given options. @@ -45,6 +48,7 @@ func (c *Client) init() { c.Match = NewMatchClient(c.config) c.Player = NewPlayerClient(c.config) c.Stats = NewStatsClient(c.config) + c.WeaponStats = NewWeaponStatsClient(c.config) } // Open opens a database/sql.DB specified by the driver name and @@ -76,11 +80,12 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { cfg := c.config cfg.driver = tx return &Tx{ - ctx: ctx, - config: cfg, - Match: NewMatchClient(cfg), - Player: NewPlayerClient(cfg), - Stats: NewStatsClient(cfg), + ctx: ctx, + config: cfg, + Match: NewMatchClient(cfg), + Player: NewPlayerClient(cfg), + Stats: NewStatsClient(cfg), + WeaponStats: NewWeaponStatsClient(cfg), }, nil } @@ -98,10 +103,11 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) cfg := c.config cfg.driver = &txDriver{tx: tx, drv: c.driver} return &Tx{ - config: cfg, - Match: NewMatchClient(cfg), - Player: NewPlayerClient(cfg), - Stats: NewStatsClient(cfg), + config: cfg, + Match: NewMatchClient(cfg), + Player: NewPlayerClient(cfg), + Stats: NewStatsClient(cfg), + WeaponStats: NewWeaponStatsClient(cfg), }, nil } @@ -134,6 +140,7 @@ func (c *Client) Use(hooks ...Hook) { c.Match.Use(hooks...) c.Player.Use(hooks...) c.Stats.Use(hooks...) + c.WeaponStats.Use(hooks...) } // MatchClient is a client for the Match schema. @@ -497,7 +504,129 @@ func (c *StatsClient) QueryPlayers(s *Stats) *PlayerQuery { return query } +// QueryWeaponStats queries the weapon_stats edge of a Stats. +func (c *StatsClient) QueryWeaponStats(s *Stats) *WeaponStatsQuery { + query := &WeaponStatsQuery{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(weaponstats.Table, weaponstats.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, stats.WeaponStatsTable, stats.WeaponStatsColumn), + ) + fromV = sqlgraph.Neighbors(s.driver.Dialect(), step) + return fromV, nil + } + return query +} + // Hooks returns the client hooks. func (c *StatsClient) Hooks() []Hook { return c.hooks.Stats } + +// WeaponStatsClient is a client for the WeaponStats schema. +type WeaponStatsClient struct { + config +} + +// NewWeaponStatsClient returns a client for the WeaponStats from the given config. +func NewWeaponStatsClient(c config) *WeaponStatsClient { + return &WeaponStatsClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `weaponstats.Hooks(f(g(h())))`. +func (c *WeaponStatsClient) Use(hooks ...Hook) { + c.hooks.WeaponStats = append(c.hooks.WeaponStats, hooks...) +} + +// Create returns a create builder for WeaponStats. +func (c *WeaponStatsClient) Create() *WeaponStatsCreate { + mutation := newWeaponStatsMutation(c.config, OpCreate) + return &WeaponStatsCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of WeaponStats entities. +func (c *WeaponStatsClient) CreateBulk(builders ...*WeaponStatsCreate) *WeaponStatsCreateBulk { + return &WeaponStatsCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for WeaponStats. +func (c *WeaponStatsClient) Update() *WeaponStatsUpdate { + mutation := newWeaponStatsMutation(c.config, OpUpdate) + return &WeaponStatsUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *WeaponStatsClient) UpdateOne(ws *WeaponStats) *WeaponStatsUpdateOne { + mutation := newWeaponStatsMutation(c.config, OpUpdateOne, withWeaponStats(ws)) + return &WeaponStatsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *WeaponStatsClient) UpdateOneID(id int) *WeaponStatsUpdateOne { + mutation := newWeaponStatsMutation(c.config, OpUpdateOne, withWeaponStatsID(id)) + return &WeaponStatsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for WeaponStats. +func (c *WeaponStatsClient) Delete() *WeaponStatsDelete { + mutation := newWeaponStatsMutation(c.config, OpDelete) + return &WeaponStatsDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a delete builder for the given entity. +func (c *WeaponStatsClient) DeleteOne(ws *WeaponStats) *WeaponStatsDeleteOne { + return c.DeleteOneID(ws.ID) +} + +// DeleteOneID returns a delete builder for the given id. +func (c *WeaponStatsClient) DeleteOneID(id int) *WeaponStatsDeleteOne { + builder := c.Delete().Where(weaponstats.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &WeaponStatsDeleteOne{builder} +} + +// Query returns a query builder for WeaponStats. +func (c *WeaponStatsClient) Query() *WeaponStatsQuery { + return &WeaponStatsQuery{ + config: c.config, + } +} + +// Get returns a WeaponStats entity by its id. +func (c *WeaponStatsClient) Get(ctx context.Context, id int) (*WeaponStats, error) { + return c.Query().Where(weaponstats.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *WeaponStatsClient) GetX(ctx context.Context, id int) *WeaponStats { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryStat queries the stat edge of a WeaponStats. +func (c *WeaponStatsClient) QueryStat(ws *WeaponStats) *StatsQuery { + query := &StatsQuery{config: c.config} + query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) { + id := ws.ID + step := sqlgraph.NewStep( + sqlgraph.From(weaponstats.Table, weaponstats.FieldID, id), + sqlgraph.To(stats.Table, stats.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, weaponstats.StatTable, weaponstats.StatColumn), + ) + fromV = sqlgraph.Neighbors(ws.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *WeaponStatsClient) Hooks() []Hook { + return c.hooks.WeaponStats +} diff --git a/ent/config.go b/ent/config.go index 7b9ff0c..9722f95 100644 --- a/ent/config.go +++ b/ent/config.go @@ -24,9 +24,10 @@ type config struct { // hooks per client, for fast access. type hooks struct { - Match []ent.Hook - Player []ent.Hook - Stats []ent.Hook + Match []ent.Hook + Player []ent.Hook + Stats []ent.Hook + WeaponStats []ent.Hook } // Options applies the options on the config object. diff --git a/ent/ent.go b/ent/ent.go index b9508e6..c93c96a 100644 --- a/ent/ent.go +++ b/ent/ent.go @@ -6,6 +6,7 @@ import ( "csgowtfd/ent/match" "csgowtfd/ent/player" "csgowtfd/ent/stats" + "csgowtfd/ent/weaponstats" "errors" "fmt" @@ -31,9 +32,10 @@ type OrderFunc func(*sql.Selector) // columnChecker returns a function indicates if the column exists in the given column. func columnChecker(table string) func(string) error { checks := map[string]func(string) bool{ - match.Table: match.ValidColumn, - player.Table: player.ValidColumn, - stats.Table: stats.ValidColumn, + match.Table: match.ValidColumn, + player.Table: player.ValidColumn, + stats.Table: stats.ValidColumn, + weaponstats.Table: weaponstats.ValidColumn, } check, ok := checks[table] if !ok { diff --git a/ent/hook/hook.go b/ent/hook/hook.go index 1430174..959af0b 100644 --- a/ent/hook/hook.go +++ b/ent/hook/hook.go @@ -47,6 +47,19 @@ func (f StatsFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error return f(ctx, mv) } +// The WeaponStatsFunc type is an adapter to allow the use of ordinary +// function as WeaponStats mutator. +type WeaponStatsFunc func(context.Context, *ent.WeaponStatsMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f WeaponStatsFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + mv, ok := m.(*ent.WeaponStatsMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.WeaponStatsMutation", m) + } + return f(ctx, mv) +} + // Condition is a hook condition function. type Condition func(context.Context, ent.Mutation) bool diff --git a/ent/match_query.go b/ent/match_query.go index 884e84c..f68ae38 100644 --- a/ent/match_query.go +++ b/ent/match_query.go @@ -423,7 +423,6 @@ func (mq *MatchQuery) sqlAll(ctx context.Context) ([]*Match, error) { nodeids[nodes[i].ID] = nodes[i] nodes[i].Edges.Stats = []*Stats{} } - query.withFKs = true query.Where(predicate.Stats(func(s *sql.Selector) { s.Where(sql.InValues(match.StatsColumn, fks...)) })) @@ -432,13 +431,10 @@ func (mq *MatchQuery) sqlAll(ctx context.Context) ([]*Match, error) { return nil, err } for _, n := range neighbors { - fk := n.match_stats - if fk == nil { - return nil, fmt.Errorf(`foreign-key "match_stats" is nil for node %v`, n.ID) - } - node, ok := nodeids[*fk] + fk := n.MatchStats + node, ok := nodeids[fk] if !ok { - return nil, fmt.Errorf(`unexpected foreign-key "match_stats" returned %v for node %v`, *fk, n.ID) + return nil, fmt.Errorf(`unexpected foreign-key "match_stats" returned %v for node %v`, fk, n.ID) } node.Edges.Stats = append(node.Edges.Stats, n) } diff --git a/ent/migrate/schema.go b/ent/migrate/schema.go index 38ec227..a70192f 100644 --- a/ent/migrate/schema.go +++ b/ent/migrate/schema.go @@ -42,6 +42,7 @@ var ( {Name: "steam_updated", Type: field.TypeTime}, {Name: "sharecode_updated", Type: field.TypeTime, Nullable: true}, {Name: "auth_code", Type: field.TypeString, Nullable: true}, + {Name: "profile_created", Type: field.TypeTime, Nullable: true}, } // PlayersTable holds the schema information for the "players" table. PlayersTable = &schema.Table{ @@ -57,9 +58,38 @@ var ( {Name: "deaths", Type: field.TypeInt}, {Name: "assists", Type: field.TypeInt}, {Name: "headshot", Type: field.TypeInt}, - {Name: "mvp", Type: field.TypeInt}, + {Name: "mvp", Type: field.TypeUint}, {Name: "score", Type: field.TypeInt}, - {Name: "extended", Type: field.TypeJSON, Nullable: true}, + {Name: "rank_new", Type: field.TypeInt, Nullable: true}, + {Name: "rank_old", Type: field.TypeInt, Nullable: true}, + {Name: "mk_2", Type: field.TypeUint, Nullable: true}, + {Name: "mk_3", Type: field.TypeUint, Nullable: true}, + {Name: "mk_4", Type: field.TypeUint, Nullable: true}, + {Name: "mk_5", Type: field.TypeUint, Nullable: true}, + {Name: "dmg_enemy", Type: field.TypeUint, Nullable: true}, + {Name: "dmg_team", Type: field.TypeUint, Nullable: true}, + {Name: "ud_he", Type: field.TypeUint, Nullable: true}, + {Name: "ud_flames", Type: field.TypeUint, Nullable: true}, + {Name: "ud_flash", Type: field.TypeUint, Nullable: true}, + {Name: "ud_decoy", Type: field.TypeUint, Nullable: true}, + {Name: "ud_smoke", Type: field.TypeUint, Nullable: true}, + {Name: "hit_group_head", Type: field.TypeUint, Nullable: true}, + {Name: "hit_group_chest", Type: field.TypeUint, Nullable: true}, + {Name: "hit_group_stomach", Type: field.TypeUint, Nullable: true}, + {Name: "hit_group_left_arm", Type: field.TypeUint, Nullable: true}, + {Name: "hit_group_right_arm", Type: field.TypeUint, Nullable: true}, + {Name: "hit_group_left_leg", Type: field.TypeUint, Nullable: true}, + {Name: "hit_group_right_leg", Type: field.TypeUint, Nullable: true}, + {Name: "hit_group_gear", Type: field.TypeUint, Nullable: true}, + {Name: "crosshair", Type: field.TypeString, Nullable: true}, + {Name: "color", Type: field.TypeEnum, Nullable: true, Enums: []string{"green", "yellow", "purple", "blue", "orange", "grey"}}, + {Name: "kast", Type: field.TypeInt, Nullable: true}, + {Name: "flash_duration_self", Type: field.TypeFloat32, Nullable: true}, + {Name: "flash_duration_team", Type: field.TypeFloat32, Nullable: true}, + {Name: "flash_duration_enemy", Type: field.TypeFloat32, Nullable: true}, + {Name: "flash_total_self", Type: field.TypeUint, Nullable: true}, + {Name: "flash_total_team", Type: field.TypeUint, Nullable: true}, + {Name: "flash_total_enemy", Type: field.TypeUint, Nullable: true}, {Name: "match_stats", Type: field.TypeUint64, Nullable: true}, {Name: "player_stats", Type: field.TypeUint64, Nullable: true}, } @@ -71,18 +101,41 @@ var ( ForeignKeys: []*schema.ForeignKey{ { Symbol: "stats_matches_stats", - Columns: []*schema.Column{StatsColumns[9]}, + Columns: []*schema.Column{StatsColumns[38]}, RefColumns: []*schema.Column{MatchesColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "stats_players_stats", - Columns: []*schema.Column{StatsColumns[10]}, + Columns: []*schema.Column{StatsColumns[39]}, RefColumns: []*schema.Column{PlayersColumns[0]}, OnDelete: schema.SetNull, }, }, } + // WeaponStatsColumns holds the columns for the "weapon_stats" table. + WeaponStatsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "victim", Type: field.TypeUint64}, + {Name: "dmg", Type: field.TypeUint}, + {Name: "eq_type", Type: field.TypeInt}, + {Name: "hit_group", Type: field.TypeInt}, + {Name: "stats_weapon_stats", Type: field.TypeInt, Nullable: true}, + } + // WeaponStatsTable holds the schema information for the "weapon_stats" table. + WeaponStatsTable = &schema.Table{ + Name: "weapon_stats", + Columns: WeaponStatsColumns, + PrimaryKey: []*schema.Column{WeaponStatsColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "weapon_stats_stats_weapon_stats", + Columns: []*schema.Column{WeaponStatsColumns[5]}, + RefColumns: []*schema.Column{StatsColumns[0]}, + OnDelete: schema.SetNull, + }, + }, + } // PlayerMatchesColumns holds the columns for the "player_matches" table. PlayerMatchesColumns = []*schema.Column{ {Name: "player_id", Type: field.TypeUint64}, @@ -113,6 +166,7 @@ var ( MatchesTable, PlayersTable, StatsTable, + WeaponStatsTable, PlayerMatchesTable, } ) @@ -120,6 +174,7 @@ var ( func init() { StatsTable.ForeignKeys[0].RefTable = MatchesTable StatsTable.ForeignKeys[1].RefTable = PlayersTable + WeaponStatsTable.ForeignKeys[0].RefTable = StatsTable PlayerMatchesTable.ForeignKeys[0].RefTable = PlayersTable PlayerMatchesTable.ForeignKeys[1].RefTable = MatchesTable } diff --git a/ent/mutation.go b/ent/mutation.go index 0ddc64d..33f314e 100644 --- a/ent/mutation.go +++ b/ent/mutation.go @@ -8,6 +8,7 @@ import ( "csgowtfd/ent/player" "csgowtfd/ent/predicate" "csgowtfd/ent/stats" + "csgowtfd/ent/weaponstats" "fmt" "sync" "time" @@ -24,9 +25,10 @@ const ( OpUpdateOne = ent.OpUpdateOne // Node types. - TypeMatch = "Match" - TypePlayer = "Player" - TypeStats = "Stats" + TypeMatch = "Match" + TypePlayer = "Player" + TypeStats = "Stats" + TypeWeaponStats = "WeaponStats" ) // MatchMutation represents an operation that mutates the Match nodes in the graph. @@ -1318,6 +1320,7 @@ type PlayerMutation struct { steam_updated *time.Time sharecode_updated *time.Time auth_code *string + profile_created *time.Time clearedFields map[string]struct{} stats map[int]struct{} removedstats map[int]struct{} @@ -1900,6 +1903,55 @@ func (m *PlayerMutation) ResetAuthCode() { delete(m.clearedFields, player.FieldAuthCode) } +// SetProfileCreated sets the "profile_created" field. +func (m *PlayerMutation) SetProfileCreated(t time.Time) { + m.profile_created = &t +} + +// ProfileCreated returns the value of the "profile_created" field in the mutation. +func (m *PlayerMutation) ProfileCreated() (r time.Time, exists bool) { + v := m.profile_created + if v == nil { + return + } + return *v, true +} + +// OldProfileCreated returns the old "profile_created" field's value of the Player entity. +// If the Player object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlayerMutation) OldProfileCreated(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldProfileCreated is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldProfileCreated requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldProfileCreated: %w", err) + } + return oldValue.ProfileCreated, nil +} + +// ClearProfileCreated clears the value of the "profile_created" field. +func (m *PlayerMutation) ClearProfileCreated() { + m.profile_created = nil + m.clearedFields[player.FieldProfileCreated] = struct{}{} +} + +// ProfileCreatedCleared returns if the "profile_created" field was cleared in this mutation. +func (m *PlayerMutation) ProfileCreatedCleared() bool { + _, ok := m.clearedFields[player.FieldProfileCreated] + return ok +} + +// ResetProfileCreated resets all changes to the "profile_created" field. +func (m *PlayerMutation) ResetProfileCreated() { + m.profile_created = nil + delete(m.clearedFields, player.FieldProfileCreated) +} + // AddStatIDs adds the "stats" edge to the Stats entity by ids. func (m *PlayerMutation) AddStatIDs(ids ...int) { if m.stats == nil { @@ -2027,7 +2079,7 @@ func (m *PlayerMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *PlayerMutation) Fields() []string { - fields := make([]string, 0, 10) + fields := make([]string, 0, 11) if m.name != nil { fields = append(fields, player.FieldName) } @@ -2058,6 +2110,9 @@ func (m *PlayerMutation) Fields() []string { if m.auth_code != nil { fields = append(fields, player.FieldAuthCode) } + if m.profile_created != nil { + fields = append(fields, player.FieldProfileCreated) + } return fields } @@ -2086,6 +2141,8 @@ func (m *PlayerMutation) Field(name string) (ent.Value, bool) { return m.SharecodeUpdated() case player.FieldAuthCode: return m.AuthCode() + case player.FieldProfileCreated: + return m.ProfileCreated() } return nil, false } @@ -2115,6 +2172,8 @@ func (m *PlayerMutation) OldField(ctx context.Context, name string) (ent.Value, return m.OldSharecodeUpdated(ctx) case player.FieldAuthCode: return m.OldAuthCode(ctx) + case player.FieldProfileCreated: + return m.OldProfileCreated(ctx) } return nil, fmt.Errorf("unknown Player field %s", name) } @@ -2194,6 +2253,13 @@ func (m *PlayerMutation) SetField(name string, value ent.Value) error { } m.SetAuthCode(v) return nil + case player.FieldProfileCreated: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetProfileCreated(v) + return nil } return fmt.Errorf("unknown Player field %s", name) } @@ -2263,6 +2329,9 @@ func (m *PlayerMutation) ClearedFields() []string { if m.FieldCleared(player.FieldAuthCode) { fields = append(fields, player.FieldAuthCode) } + if m.FieldCleared(player.FieldProfileCreated) { + fields = append(fields, player.FieldProfileCreated) + } return fields } @@ -2301,6 +2370,9 @@ func (m *PlayerMutation) ClearField(name string) error { case player.FieldAuthCode: m.ClearAuthCode() return nil + case player.FieldProfileCreated: + m.ClearProfileCreated() + return nil } return fmt.Errorf("unknown Player nullable field %s", name) } @@ -2339,6 +2411,9 @@ func (m *PlayerMutation) ResetField(name string) error { case player.FieldAuthCode: m.ResetAuthCode() return nil + case player.FieldProfileCreated: + m.ResetProfileCreated() + return nil } return fmt.Errorf("unknown Player field %s", name) } @@ -2456,79 +2531,92 @@ func (m *PlayerMutation) ResetEdge(name string) error { // StatsMutation represents an operation that mutates the Stats nodes in the graph. type StatsMutation struct { config - op Op - typ string - id *int - team_id *int - addteam_id *int - kills *int - addkills *int - deaths *int - adddeaths *int - assists *int - addassists *int - headshot *int - addheadshot *int - mvp *int - addmvp *int - score *int - addscore *int - extended *struct { - MultiKills struct { - Duo int "json:\"duo,omitempty\"" - Triple int "json:\"triple,omitempty\"" - Quad int "json:\"quad,omitempty\"" - Pent int "json:\"pent,omitempty\"" - } "json:\"multi_kills,omitempty\"" - Dmg struct { - Enemy int "json:\"enemy,omitempty\"" - Team int "json:\"team,omitempty\"" - UD struct { - HE int "json:\"he,omitempty\"" - Flames int "json:\"flames,omitempty\"" - Flash int "json:\"flash,omitempty\"" - Decoy int "json:\"decoy,omitempty\"" - Smoke int "json:\"smoke,omitempty\"" - } "json:\"ud,omitempty\"" - HitGroup struct { - Head int "json:\"head,omitempty\"" - Chest int "json:\"chest,omitempty\"" - Stomach int "json:\"stomach,omitempty\"" - LeftArm int "json:\"left_arm,omitempty\"" - RightArm int "json:\"right_arm,omitempty\"" - LeftLeg int "json:\"left_leg,omitempty\"" - RightLeg int "json:\"right_leg,omitempty\"" - Gear int "json:\"gear,omitempty\"" - } "json:\"hit_group,omitempty\"" - } "json:\"dmg,omitempty\"" - Crosshair string "json:\"crosshair,omitempty\"" - Color string "json:\"color,omitempty\"" - KAST int "json:\"kast,omitempty\"" - Rank struct { - Old int "json:\"old,omitempty\"" - New int "json:\"new,omitempty\"" - } "json:\"rank,omitempty\"" - Flash struct { - Duration struct { - Self float32 "json:\"self,omitempty\"" - Team float32 "json:\"team,omitempty\"" - Enemy float32 "json:\"enemy,omitempty\"" - } "json:\"duration,omitempty\"" - Total struct { - Team int "json:\"team,omitempty\"" - Enemy int "json:\"enemy,omitempty\"" - Self int "json:\"self,omitempty\"" - } "json:\"total,omitempty\"" - } "json:\"flash,omitempty\"" - } - clearedFields map[string]struct{} - matches *uint64 - clearedmatches bool - players *uint64 - clearedplayers bool - done bool - oldValue func(context.Context) (*Stats, error) - predicates []predicate.Stats + op Op + typ string + id *int + team_id *int + addteam_id *int + kills *int + addkills *int + deaths *int + adddeaths *int + assists *int + addassists *int + headshot *int + addheadshot *int + mvp *uint + addmvp *uint + score *int + addscore *int + rank_new *int + addrank_new *int + rank_old *int + addrank_old *int + mk_2 *uint + addmk_2 *uint + mk_3 *uint + addmk_3 *uint + mk_4 *uint + addmk_4 *uint + mk_5 *uint + addmk_5 *uint + dmg_enemy *uint + adddmg_enemy *uint + dmg_team *uint + adddmg_team *uint + ud_he *uint + addud_he *uint + ud_flames *uint + addud_flames *uint + ud_flash *uint + addud_flash *uint + ud_decoy *uint + addud_decoy *uint + ud_smoke *uint + addud_smoke *uint + hit_group_head *uint + addhit_group_head *uint + hit_group_chest *uint + addhit_group_chest *uint + hit_group_stomach *uint + addhit_group_stomach *uint + hit_group_left_arm *uint + addhit_group_left_arm *uint + hit_group_right_arm *uint + addhit_group_right_arm *uint + hit_group_left_leg *uint + addhit_group_left_leg *uint + hit_group_right_leg *uint + addhit_group_right_leg *uint + hit_group_gear *uint + addhit_group_gear *uint + crosshair *string + color *stats.Color + kast *int + addkast *int + flash_duration_self *float32 + addflash_duration_self *float32 + flash_duration_team *float32 + addflash_duration_team *float32 + flash_duration_enemy *float32 + addflash_duration_enemy *float32 + flash_total_self *uint + addflash_total_self *uint + flash_total_team *uint + addflash_total_team *uint + flash_total_enemy *uint + addflash_total_enemy *uint + clearedFields map[string]struct{} + matches *uint64 + clearedmatches bool + players *uint64 + clearedplayers bool + weapon_stats map[int]struct{} + removedweapon_stats map[int]struct{} + clearedweapon_stats bool + done bool + oldValue func(context.Context) (*Stats, error) + predicates []predicate.Stats } var _ ent.Mutation = (*StatsMutation)(nil) @@ -2891,13 +2979,13 @@ func (m *StatsMutation) ResetHeadshot() { } // SetMvp sets the "mvp" field. -func (m *StatsMutation) SetMvp(i int) { - m.mvp = &i +func (m *StatsMutation) SetMvp(u uint) { + m.mvp = &u m.addmvp = nil } // Mvp returns the value of the "mvp" field in the mutation. -func (m *StatsMutation) Mvp() (r int, exists bool) { +func (m *StatsMutation) Mvp() (r uint, exists bool) { v := m.mvp if v == nil { return @@ -2908,7 +2996,7 @@ func (m *StatsMutation) Mvp() (r int, exists bool) { // OldMvp returns the old "mvp" field's value of the Stats entity. // If the Stats 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 *StatsMutation) OldMvp(ctx context.Context) (v int, err error) { +func (m *StatsMutation) OldMvp(ctx context.Context) (v uint, err error) { if !m.op.Is(OpUpdateOne) { return v, fmt.Errorf("OldMvp is only allowed on UpdateOne operations") } @@ -2922,17 +3010,17 @@ func (m *StatsMutation) OldMvp(ctx context.Context) (v int, err error) { return oldValue.Mvp, nil } -// AddMvp adds i to the "mvp" field. -func (m *StatsMutation) AddMvp(i int) { +// AddMvp adds u to the "mvp" field. +func (m *StatsMutation) AddMvp(u uint) { if m.addmvp != nil { - *m.addmvp += i + *m.addmvp += u } else { - m.addmvp = &i + m.addmvp = &u } } // AddedMvp returns the value that was added to the "mvp" field in this mutation. -func (m *StatsMutation) AddedMvp() (r int, exists bool) { +func (m *StatsMutation) AddedMvp() (r uint, exists bool) { v := m.addmvp if v == nil { return @@ -3002,194 +3090,2160 @@ func (m *StatsMutation) ResetScore() { m.addscore = nil } -// SetExtended sets the "extended" field. -func (m *StatsMutation) SetExtended(skkgaaaallllg struct { - MultiKills struct { - Duo int "json:\"duo,omitempty\"" - Triple int "json:\"triple,omitempty\"" - Quad int "json:\"quad,omitempty\"" - Pent int "json:\"pent,omitempty\"" - } "json:\"multi_kills,omitempty\"" - Dmg struct { - Enemy int "json:\"enemy,omitempty\"" - Team int "json:\"team,omitempty\"" - UD struct { - HE int "json:\"he,omitempty\"" - Flames int "json:\"flames,omitempty\"" - Flash int "json:\"flash,omitempty\"" - Decoy int "json:\"decoy,omitempty\"" - Smoke int "json:\"smoke,omitempty\"" - } "json:\"ud,omitempty\"" - HitGroup struct { - Head int "json:\"head,omitempty\"" - Chest int "json:\"chest,omitempty\"" - Stomach int "json:\"stomach,omitempty\"" - LeftArm int "json:\"left_arm,omitempty\"" - RightArm int "json:\"right_arm,omitempty\"" - LeftLeg int "json:\"left_leg,omitempty\"" - RightLeg int "json:\"right_leg,omitempty\"" - Gear int "json:\"gear,omitempty\"" - } "json:\"hit_group,omitempty\"" - } "json:\"dmg,omitempty\"" - Crosshair string "json:\"crosshair,omitempty\"" - Color string "json:\"color,omitempty\"" - KAST int "json:\"kast,omitempty\"" - Rank struct { - Old int "json:\"old,omitempty\"" - New int "json:\"new,omitempty\"" - } "json:\"rank,omitempty\"" - Flash struct { - Duration struct { - Self float32 "json:\"self,omitempty\"" - Team float32 "json:\"team,omitempty\"" - Enemy float32 "json:\"enemy,omitempty\"" - } "json:\"duration,omitempty\"" - Total struct { - Team int "json:\"team,omitempty\"" - Enemy int "json:\"enemy,omitempty\"" - Self int "json:\"self,omitempty\"" - } "json:\"total,omitempty\"" - } "json:\"flash,omitempty\"" -}) { - m.extended = &skkgaaaallllg +// SetRankNew sets the "rank_new" field. +func (m *StatsMutation) SetRankNew(i int) { + m.rank_new = &i + m.addrank_new = nil } -// Extended returns the value of the "extended" field in the mutation. -func (m *StatsMutation) Extended() (r struct { - MultiKills struct { - Duo int "json:\"duo,omitempty\"" - Triple int "json:\"triple,omitempty\"" - Quad int "json:\"quad,omitempty\"" - Pent int "json:\"pent,omitempty\"" - } "json:\"multi_kills,omitempty\"" - Dmg struct { - Enemy int "json:\"enemy,omitempty\"" - Team int "json:\"team,omitempty\"" - UD struct { - HE int "json:\"he,omitempty\"" - Flames int "json:\"flames,omitempty\"" - Flash int "json:\"flash,omitempty\"" - Decoy int "json:\"decoy,omitempty\"" - Smoke int "json:\"smoke,omitempty\"" - } "json:\"ud,omitempty\"" - HitGroup struct { - Head int "json:\"head,omitempty\"" - Chest int "json:\"chest,omitempty\"" - Stomach int "json:\"stomach,omitempty\"" - LeftArm int "json:\"left_arm,omitempty\"" - RightArm int "json:\"right_arm,omitempty\"" - LeftLeg int "json:\"left_leg,omitempty\"" - RightLeg int "json:\"right_leg,omitempty\"" - Gear int "json:\"gear,omitempty\"" - } "json:\"hit_group,omitempty\"" - } "json:\"dmg,omitempty\"" - Crosshair string "json:\"crosshair,omitempty\"" - Color string "json:\"color,omitempty\"" - KAST int "json:\"kast,omitempty\"" - Rank struct { - Old int "json:\"old,omitempty\"" - New int "json:\"new,omitempty\"" - } "json:\"rank,omitempty\"" - Flash struct { - Duration struct { - Self float32 "json:\"self,omitempty\"" - Team float32 "json:\"team,omitempty\"" - Enemy float32 "json:\"enemy,omitempty\"" - } "json:\"duration,omitempty\"" - Total struct { - Team int "json:\"team,omitempty\"" - Enemy int "json:\"enemy,omitempty\"" - Self int "json:\"self,omitempty\"" - } "json:\"total,omitempty\"" - } "json:\"flash,omitempty\"" -}, exists bool) { - v := m.extended +// RankNew returns the value of the "rank_new" field in the mutation. +func (m *StatsMutation) RankNew() (r int, exists bool) { + v := m.rank_new if v == nil { return } return *v, true } -// OldExtended returns the old "extended" field's value of the Stats entity. +// OldRankNew returns the old "rank_new" field's value of the Stats entity. // If the Stats 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 *StatsMutation) OldExtended(ctx context.Context) (v struct { - MultiKills struct { - Duo int "json:\"duo,omitempty\"" - Triple int "json:\"triple,omitempty\"" - Quad int "json:\"quad,omitempty\"" - Pent int "json:\"pent,omitempty\"" - } "json:\"multi_kills,omitempty\"" - Dmg struct { - Enemy int "json:\"enemy,omitempty\"" - Team int "json:\"team,omitempty\"" - UD struct { - HE int "json:\"he,omitempty\"" - Flames int "json:\"flames,omitempty\"" - Flash int "json:\"flash,omitempty\"" - Decoy int "json:\"decoy,omitempty\"" - Smoke int "json:\"smoke,omitempty\"" - } "json:\"ud,omitempty\"" - HitGroup struct { - Head int "json:\"head,omitempty\"" - Chest int "json:\"chest,omitempty\"" - Stomach int "json:\"stomach,omitempty\"" - LeftArm int "json:\"left_arm,omitempty\"" - RightArm int "json:\"right_arm,omitempty\"" - LeftLeg int "json:\"left_leg,omitempty\"" - RightLeg int "json:\"right_leg,omitempty\"" - Gear int "json:\"gear,omitempty\"" - } "json:\"hit_group,omitempty\"" - } "json:\"dmg,omitempty\"" - Crosshair string "json:\"crosshair,omitempty\"" - Color string "json:\"color,omitempty\"" - KAST int "json:\"kast,omitempty\"" - Rank struct { - Old int "json:\"old,omitempty\"" - New int "json:\"new,omitempty\"" - } "json:\"rank,omitempty\"" - Flash struct { - Duration struct { - Self float32 "json:\"self,omitempty\"" - Team float32 "json:\"team,omitempty\"" - Enemy float32 "json:\"enemy,omitempty\"" - } "json:\"duration,omitempty\"" - Total struct { - Team int "json:\"team,omitempty\"" - Enemy int "json:\"enemy,omitempty\"" - Self int "json:\"self,omitempty\"" - } "json:\"total,omitempty\"" - } "json:\"flash,omitempty\"" -}, err error) { +func (m *StatsMutation) OldRankNew(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { - return v, fmt.Errorf("OldExtended is only allowed on UpdateOne operations") + return v, fmt.Errorf("OldRankNew is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, fmt.Errorf("OldExtended requires an ID field in the mutation") + return v, fmt.Errorf("OldRankNew requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldExtended: %w", err) + return v, fmt.Errorf("querying old value for OldRankNew: %w", err) } - return oldValue.Extended, nil + return oldValue.RankNew, nil } -// ClearExtended clears the value of the "extended" field. -func (m *StatsMutation) ClearExtended() { - m.extended = nil - m.clearedFields[stats.FieldExtended] = struct{}{} +// AddRankNew adds i to the "rank_new" field. +func (m *StatsMutation) AddRankNew(i int) { + if m.addrank_new != nil { + *m.addrank_new += i + } else { + m.addrank_new = &i + } } -// ExtendedCleared returns if the "extended" field was cleared in this mutation. -func (m *StatsMutation) ExtendedCleared() bool { - _, ok := m.clearedFields[stats.FieldExtended] +// AddedRankNew returns the value that was added to the "rank_new" field in this mutation. +func (m *StatsMutation) AddedRankNew() (r int, exists bool) { + v := m.addrank_new + if v == nil { + return + } + return *v, true +} + +// ClearRankNew clears the value of the "rank_new" field. +func (m *StatsMutation) ClearRankNew() { + m.rank_new = nil + m.addrank_new = nil + m.clearedFields[stats.FieldRankNew] = struct{}{} +} + +// RankNewCleared returns if the "rank_new" field was cleared in this mutation. +func (m *StatsMutation) RankNewCleared() bool { + _, ok := m.clearedFields[stats.FieldRankNew] return ok } -// ResetExtended resets all changes to the "extended" field. -func (m *StatsMutation) ResetExtended() { - m.extended = nil - delete(m.clearedFields, stats.FieldExtended) +// ResetRankNew resets all changes to the "rank_new" field. +func (m *StatsMutation) ResetRankNew() { + m.rank_new = nil + m.addrank_new = nil + delete(m.clearedFields, stats.FieldRankNew) +} + +// SetRankOld sets the "rank_old" field. +func (m *StatsMutation) SetRankOld(i int) { + m.rank_old = &i + m.addrank_old = nil +} + +// RankOld returns the value of the "rank_old" field in the mutation. +func (m *StatsMutation) RankOld() (r int, exists bool) { + v := m.rank_old + if v == nil { + return + } + return *v, true +} + +// OldRankOld returns the old "rank_old" field's value of the Stats entity. +// If the Stats 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 *StatsMutation) OldRankOld(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldRankOld is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldRankOld requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRankOld: %w", err) + } + return oldValue.RankOld, nil +} + +// AddRankOld adds i to the "rank_old" field. +func (m *StatsMutation) AddRankOld(i int) { + if m.addrank_old != nil { + *m.addrank_old += i + } else { + m.addrank_old = &i + } +} + +// AddedRankOld returns the value that was added to the "rank_old" field in this mutation. +func (m *StatsMutation) AddedRankOld() (r int, exists bool) { + v := m.addrank_old + if v == nil { + return + } + return *v, true +} + +// ClearRankOld clears the value of the "rank_old" field. +func (m *StatsMutation) ClearRankOld() { + m.rank_old = nil + m.addrank_old = nil + m.clearedFields[stats.FieldRankOld] = struct{}{} +} + +// RankOldCleared returns if the "rank_old" field was cleared in this mutation. +func (m *StatsMutation) RankOldCleared() bool { + _, ok := m.clearedFields[stats.FieldRankOld] + return ok +} + +// ResetRankOld resets all changes to the "rank_old" field. +func (m *StatsMutation) ResetRankOld() { + m.rank_old = nil + m.addrank_old = nil + delete(m.clearedFields, stats.FieldRankOld) +} + +// SetMk2 sets the "mk_2" field. +func (m *StatsMutation) SetMk2(u uint) { + m.mk_2 = &u + m.addmk_2 = nil +} + +// Mk2 returns the value of the "mk_2" field in the mutation. +func (m *StatsMutation) Mk2() (r uint, exists bool) { + v := m.mk_2 + if v == nil { + return + } + return *v, true +} + +// OldMk2 returns the old "mk_2" field's value of the Stats entity. +// If the Stats 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 *StatsMutation) OldMk2(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldMk2 is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldMk2 requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMk2: %w", err) + } + return oldValue.Mk2, nil +} + +// AddMk2 adds u to the "mk_2" field. +func (m *StatsMutation) AddMk2(u uint) { + if m.addmk_2 != nil { + *m.addmk_2 += u + } else { + m.addmk_2 = &u + } +} + +// AddedMk2 returns the value that was added to the "mk_2" field in this mutation. +func (m *StatsMutation) AddedMk2() (r uint, exists bool) { + v := m.addmk_2 + if v == nil { + return + } + return *v, true +} + +// ClearMk2 clears the value of the "mk_2" field. +func (m *StatsMutation) ClearMk2() { + m.mk_2 = nil + m.addmk_2 = nil + m.clearedFields[stats.FieldMk2] = struct{}{} +} + +// Mk2Cleared returns if the "mk_2" field was cleared in this mutation. +func (m *StatsMutation) Mk2Cleared() bool { + _, ok := m.clearedFields[stats.FieldMk2] + return ok +} + +// ResetMk2 resets all changes to the "mk_2" field. +func (m *StatsMutation) ResetMk2() { + m.mk_2 = nil + m.addmk_2 = nil + delete(m.clearedFields, stats.FieldMk2) +} + +// SetMk3 sets the "mk_3" field. +func (m *StatsMutation) SetMk3(u uint) { + m.mk_3 = &u + m.addmk_3 = nil +} + +// Mk3 returns the value of the "mk_3" field in the mutation. +func (m *StatsMutation) Mk3() (r uint, exists bool) { + v := m.mk_3 + if v == nil { + return + } + return *v, true +} + +// OldMk3 returns the old "mk_3" field's value of the Stats entity. +// If the Stats 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 *StatsMutation) OldMk3(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldMk3 is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldMk3 requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMk3: %w", err) + } + return oldValue.Mk3, nil +} + +// AddMk3 adds u to the "mk_3" field. +func (m *StatsMutation) AddMk3(u uint) { + if m.addmk_3 != nil { + *m.addmk_3 += u + } else { + m.addmk_3 = &u + } +} + +// AddedMk3 returns the value that was added to the "mk_3" field in this mutation. +func (m *StatsMutation) AddedMk3() (r uint, exists bool) { + v := m.addmk_3 + if v == nil { + return + } + return *v, true +} + +// ClearMk3 clears the value of the "mk_3" field. +func (m *StatsMutation) ClearMk3() { + m.mk_3 = nil + m.addmk_3 = nil + m.clearedFields[stats.FieldMk3] = struct{}{} +} + +// Mk3Cleared returns if the "mk_3" field was cleared in this mutation. +func (m *StatsMutation) Mk3Cleared() bool { + _, ok := m.clearedFields[stats.FieldMk3] + return ok +} + +// ResetMk3 resets all changes to the "mk_3" field. +func (m *StatsMutation) ResetMk3() { + m.mk_3 = nil + m.addmk_3 = nil + delete(m.clearedFields, stats.FieldMk3) +} + +// SetMk4 sets the "mk_4" field. +func (m *StatsMutation) SetMk4(u uint) { + m.mk_4 = &u + m.addmk_4 = nil +} + +// Mk4 returns the value of the "mk_4" field in the mutation. +func (m *StatsMutation) Mk4() (r uint, exists bool) { + v := m.mk_4 + if v == nil { + return + } + return *v, true +} + +// OldMk4 returns the old "mk_4" field's value of the Stats entity. +// If the Stats 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 *StatsMutation) OldMk4(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldMk4 is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldMk4 requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMk4: %w", err) + } + return oldValue.Mk4, nil +} + +// AddMk4 adds u to the "mk_4" field. +func (m *StatsMutation) AddMk4(u uint) { + if m.addmk_4 != nil { + *m.addmk_4 += u + } else { + m.addmk_4 = &u + } +} + +// AddedMk4 returns the value that was added to the "mk_4" field in this mutation. +func (m *StatsMutation) AddedMk4() (r uint, exists bool) { + v := m.addmk_4 + if v == nil { + return + } + return *v, true +} + +// ClearMk4 clears the value of the "mk_4" field. +func (m *StatsMutation) ClearMk4() { + m.mk_4 = nil + m.addmk_4 = nil + m.clearedFields[stats.FieldMk4] = struct{}{} +} + +// Mk4Cleared returns if the "mk_4" field was cleared in this mutation. +func (m *StatsMutation) Mk4Cleared() bool { + _, ok := m.clearedFields[stats.FieldMk4] + return ok +} + +// ResetMk4 resets all changes to the "mk_4" field. +func (m *StatsMutation) ResetMk4() { + m.mk_4 = nil + m.addmk_4 = nil + delete(m.clearedFields, stats.FieldMk4) +} + +// SetMk5 sets the "mk_5" field. +func (m *StatsMutation) SetMk5(u uint) { + m.mk_5 = &u + m.addmk_5 = nil +} + +// Mk5 returns the value of the "mk_5" field in the mutation. +func (m *StatsMutation) Mk5() (r uint, exists bool) { + v := m.mk_5 + if v == nil { + return + } + return *v, true +} + +// OldMk5 returns the old "mk_5" field's value of the Stats entity. +// If the Stats 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 *StatsMutation) OldMk5(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldMk5 is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldMk5 requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMk5: %w", err) + } + return oldValue.Mk5, nil +} + +// AddMk5 adds u to the "mk_5" field. +func (m *StatsMutation) AddMk5(u uint) { + if m.addmk_5 != nil { + *m.addmk_5 += u + } else { + m.addmk_5 = &u + } +} + +// AddedMk5 returns the value that was added to the "mk_5" field in this mutation. +func (m *StatsMutation) AddedMk5() (r uint, exists bool) { + v := m.addmk_5 + if v == nil { + return + } + return *v, true +} + +// ClearMk5 clears the value of the "mk_5" field. +func (m *StatsMutation) ClearMk5() { + m.mk_5 = nil + m.addmk_5 = nil + m.clearedFields[stats.FieldMk5] = struct{}{} +} + +// Mk5Cleared returns if the "mk_5" field was cleared in this mutation. +func (m *StatsMutation) Mk5Cleared() bool { + _, ok := m.clearedFields[stats.FieldMk5] + return ok +} + +// ResetMk5 resets all changes to the "mk_5" field. +func (m *StatsMutation) ResetMk5() { + m.mk_5 = nil + m.addmk_5 = nil + delete(m.clearedFields, stats.FieldMk5) +} + +// SetDmgEnemy sets the "dmg_enemy" field. +func (m *StatsMutation) SetDmgEnemy(u uint) { + m.dmg_enemy = &u + m.adddmg_enemy = nil +} + +// DmgEnemy returns the value of the "dmg_enemy" field in the mutation. +func (m *StatsMutation) DmgEnemy() (r uint, exists bool) { + v := m.dmg_enemy + if v == nil { + return + } + return *v, true +} + +// OldDmgEnemy returns the old "dmg_enemy" field's value of the Stats entity. +// If the Stats 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 *StatsMutation) OldDmgEnemy(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldDmgEnemy is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldDmgEnemy requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDmgEnemy: %w", err) + } + return oldValue.DmgEnemy, nil +} + +// AddDmgEnemy adds u to the "dmg_enemy" field. +func (m *StatsMutation) AddDmgEnemy(u uint) { + if m.adddmg_enemy != nil { + *m.adddmg_enemy += u + } else { + m.adddmg_enemy = &u + } +} + +// AddedDmgEnemy returns the value that was added to the "dmg_enemy" field in this mutation. +func (m *StatsMutation) AddedDmgEnemy() (r uint, exists bool) { + v := m.adddmg_enemy + if v == nil { + return + } + return *v, true +} + +// ClearDmgEnemy clears the value of the "dmg_enemy" field. +func (m *StatsMutation) ClearDmgEnemy() { + m.dmg_enemy = nil + m.adddmg_enemy = nil + m.clearedFields[stats.FieldDmgEnemy] = struct{}{} +} + +// DmgEnemyCleared returns if the "dmg_enemy" field was cleared in this mutation. +func (m *StatsMutation) DmgEnemyCleared() bool { + _, ok := m.clearedFields[stats.FieldDmgEnemy] + return ok +} + +// ResetDmgEnemy resets all changes to the "dmg_enemy" field. +func (m *StatsMutation) ResetDmgEnemy() { + m.dmg_enemy = nil + m.adddmg_enemy = nil + delete(m.clearedFields, stats.FieldDmgEnemy) +} + +// SetDmgTeam sets the "dmg_team" field. +func (m *StatsMutation) SetDmgTeam(u uint) { + m.dmg_team = &u + m.adddmg_team = nil +} + +// DmgTeam returns the value of the "dmg_team" field in the mutation. +func (m *StatsMutation) DmgTeam() (r uint, exists bool) { + v := m.dmg_team + if v == nil { + return + } + return *v, true +} + +// OldDmgTeam returns the old "dmg_team" field's value of the Stats entity. +// If the Stats 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 *StatsMutation) OldDmgTeam(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldDmgTeam is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldDmgTeam requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDmgTeam: %w", err) + } + return oldValue.DmgTeam, nil +} + +// AddDmgTeam adds u to the "dmg_team" field. +func (m *StatsMutation) AddDmgTeam(u uint) { + if m.adddmg_team != nil { + *m.adddmg_team += u + } else { + m.adddmg_team = &u + } +} + +// AddedDmgTeam returns the value that was added to the "dmg_team" field in this mutation. +func (m *StatsMutation) AddedDmgTeam() (r uint, exists bool) { + v := m.adddmg_team + if v == nil { + return + } + return *v, true +} + +// ClearDmgTeam clears the value of the "dmg_team" field. +func (m *StatsMutation) ClearDmgTeam() { + m.dmg_team = nil + m.adddmg_team = nil + m.clearedFields[stats.FieldDmgTeam] = struct{}{} +} + +// DmgTeamCleared returns if the "dmg_team" field was cleared in this mutation. +func (m *StatsMutation) DmgTeamCleared() bool { + _, ok := m.clearedFields[stats.FieldDmgTeam] + return ok +} + +// ResetDmgTeam resets all changes to the "dmg_team" field. +func (m *StatsMutation) ResetDmgTeam() { + m.dmg_team = nil + m.adddmg_team = nil + delete(m.clearedFields, stats.FieldDmgTeam) +} + +// SetUdHe sets the "ud_he" field. +func (m *StatsMutation) SetUdHe(u uint) { + m.ud_he = &u + m.addud_he = nil +} + +// UdHe returns the value of the "ud_he" field in the mutation. +func (m *StatsMutation) UdHe() (r uint, exists bool) { + v := m.ud_he + if v == nil { + return + } + return *v, true +} + +// OldUdHe returns the old "ud_he" field's value of the Stats entity. +// If the Stats 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 *StatsMutation) OldUdHe(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldUdHe is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldUdHe requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUdHe: %w", err) + } + return oldValue.UdHe, nil +} + +// AddUdHe adds u to the "ud_he" field. +func (m *StatsMutation) AddUdHe(u uint) { + if m.addud_he != nil { + *m.addud_he += u + } else { + m.addud_he = &u + } +} + +// AddedUdHe returns the value that was added to the "ud_he" field in this mutation. +func (m *StatsMutation) AddedUdHe() (r uint, exists bool) { + v := m.addud_he + if v == nil { + return + } + return *v, true +} + +// ClearUdHe clears the value of the "ud_he" field. +func (m *StatsMutation) ClearUdHe() { + m.ud_he = nil + m.addud_he = nil + m.clearedFields[stats.FieldUdHe] = struct{}{} +} + +// UdHeCleared returns if the "ud_he" field was cleared in this mutation. +func (m *StatsMutation) UdHeCleared() bool { + _, ok := m.clearedFields[stats.FieldUdHe] + return ok +} + +// ResetUdHe resets all changes to the "ud_he" field. +func (m *StatsMutation) ResetUdHe() { + m.ud_he = nil + m.addud_he = nil + delete(m.clearedFields, stats.FieldUdHe) +} + +// SetUdFlames sets the "ud_flames" field. +func (m *StatsMutation) SetUdFlames(u uint) { + m.ud_flames = &u + m.addud_flames = nil +} + +// UdFlames returns the value of the "ud_flames" field in the mutation. +func (m *StatsMutation) UdFlames() (r uint, exists bool) { + v := m.ud_flames + if v == nil { + return + } + return *v, true +} + +// OldUdFlames returns the old "ud_flames" field's value of the Stats entity. +// If the Stats 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 *StatsMutation) OldUdFlames(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldUdFlames is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldUdFlames requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUdFlames: %w", err) + } + return oldValue.UdFlames, nil +} + +// AddUdFlames adds u to the "ud_flames" field. +func (m *StatsMutation) AddUdFlames(u uint) { + if m.addud_flames != nil { + *m.addud_flames += u + } else { + m.addud_flames = &u + } +} + +// AddedUdFlames returns the value that was added to the "ud_flames" field in this mutation. +func (m *StatsMutation) AddedUdFlames() (r uint, exists bool) { + v := m.addud_flames + if v == nil { + return + } + return *v, true +} + +// ClearUdFlames clears the value of the "ud_flames" field. +func (m *StatsMutation) ClearUdFlames() { + m.ud_flames = nil + m.addud_flames = nil + m.clearedFields[stats.FieldUdFlames] = struct{}{} +} + +// UdFlamesCleared returns if the "ud_flames" field was cleared in this mutation. +func (m *StatsMutation) UdFlamesCleared() bool { + _, ok := m.clearedFields[stats.FieldUdFlames] + return ok +} + +// ResetUdFlames resets all changes to the "ud_flames" field. +func (m *StatsMutation) ResetUdFlames() { + m.ud_flames = nil + m.addud_flames = nil + delete(m.clearedFields, stats.FieldUdFlames) +} + +// SetUdFlash sets the "ud_flash" field. +func (m *StatsMutation) SetUdFlash(u uint) { + m.ud_flash = &u + m.addud_flash = nil +} + +// UdFlash returns the value of the "ud_flash" field in the mutation. +func (m *StatsMutation) UdFlash() (r uint, exists bool) { + v := m.ud_flash + if v == nil { + return + } + return *v, true +} + +// OldUdFlash returns the old "ud_flash" field's value of the Stats entity. +// If the Stats 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 *StatsMutation) OldUdFlash(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldUdFlash is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldUdFlash requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUdFlash: %w", err) + } + return oldValue.UdFlash, nil +} + +// AddUdFlash adds u to the "ud_flash" field. +func (m *StatsMutation) AddUdFlash(u uint) { + if m.addud_flash != nil { + *m.addud_flash += u + } else { + m.addud_flash = &u + } +} + +// AddedUdFlash returns the value that was added to the "ud_flash" field in this mutation. +func (m *StatsMutation) AddedUdFlash() (r uint, exists bool) { + v := m.addud_flash + if v == nil { + return + } + return *v, true +} + +// ClearUdFlash clears the value of the "ud_flash" field. +func (m *StatsMutation) ClearUdFlash() { + m.ud_flash = nil + m.addud_flash = nil + m.clearedFields[stats.FieldUdFlash] = struct{}{} +} + +// UdFlashCleared returns if the "ud_flash" field was cleared in this mutation. +func (m *StatsMutation) UdFlashCleared() bool { + _, ok := m.clearedFields[stats.FieldUdFlash] + return ok +} + +// ResetUdFlash resets all changes to the "ud_flash" field. +func (m *StatsMutation) ResetUdFlash() { + m.ud_flash = nil + m.addud_flash = nil + delete(m.clearedFields, stats.FieldUdFlash) +} + +// SetUdDecoy sets the "ud_decoy" field. +func (m *StatsMutation) SetUdDecoy(u uint) { + m.ud_decoy = &u + m.addud_decoy = nil +} + +// UdDecoy returns the value of the "ud_decoy" field in the mutation. +func (m *StatsMutation) UdDecoy() (r uint, exists bool) { + v := m.ud_decoy + if v == nil { + return + } + return *v, true +} + +// OldUdDecoy returns the old "ud_decoy" field's value of the Stats entity. +// If the Stats 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 *StatsMutation) OldUdDecoy(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldUdDecoy is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldUdDecoy requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUdDecoy: %w", err) + } + return oldValue.UdDecoy, nil +} + +// AddUdDecoy adds u to the "ud_decoy" field. +func (m *StatsMutation) AddUdDecoy(u uint) { + if m.addud_decoy != nil { + *m.addud_decoy += u + } else { + m.addud_decoy = &u + } +} + +// AddedUdDecoy returns the value that was added to the "ud_decoy" field in this mutation. +func (m *StatsMutation) AddedUdDecoy() (r uint, exists bool) { + v := m.addud_decoy + if v == nil { + return + } + return *v, true +} + +// ClearUdDecoy clears the value of the "ud_decoy" field. +func (m *StatsMutation) ClearUdDecoy() { + m.ud_decoy = nil + m.addud_decoy = nil + m.clearedFields[stats.FieldUdDecoy] = struct{}{} +} + +// UdDecoyCleared returns if the "ud_decoy" field was cleared in this mutation. +func (m *StatsMutation) UdDecoyCleared() bool { + _, ok := m.clearedFields[stats.FieldUdDecoy] + return ok +} + +// ResetUdDecoy resets all changes to the "ud_decoy" field. +func (m *StatsMutation) ResetUdDecoy() { + m.ud_decoy = nil + m.addud_decoy = nil + delete(m.clearedFields, stats.FieldUdDecoy) +} + +// SetUdSmoke sets the "ud_smoke" field. +func (m *StatsMutation) SetUdSmoke(u uint) { + m.ud_smoke = &u + m.addud_smoke = nil +} + +// UdSmoke returns the value of the "ud_smoke" field in the mutation. +func (m *StatsMutation) UdSmoke() (r uint, exists bool) { + v := m.ud_smoke + if v == nil { + return + } + return *v, true +} + +// OldUdSmoke returns the old "ud_smoke" field's value of the Stats entity. +// If the Stats 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 *StatsMutation) OldUdSmoke(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldUdSmoke is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldUdSmoke requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUdSmoke: %w", err) + } + return oldValue.UdSmoke, nil +} + +// AddUdSmoke adds u to the "ud_smoke" field. +func (m *StatsMutation) AddUdSmoke(u uint) { + if m.addud_smoke != nil { + *m.addud_smoke += u + } else { + m.addud_smoke = &u + } +} + +// AddedUdSmoke returns the value that was added to the "ud_smoke" field in this mutation. +func (m *StatsMutation) AddedUdSmoke() (r uint, exists bool) { + v := m.addud_smoke + if v == nil { + return + } + return *v, true +} + +// ClearUdSmoke clears the value of the "ud_smoke" field. +func (m *StatsMutation) ClearUdSmoke() { + m.ud_smoke = nil + m.addud_smoke = nil + m.clearedFields[stats.FieldUdSmoke] = struct{}{} +} + +// UdSmokeCleared returns if the "ud_smoke" field was cleared in this mutation. +func (m *StatsMutation) UdSmokeCleared() bool { + _, ok := m.clearedFields[stats.FieldUdSmoke] + return ok +} + +// ResetUdSmoke resets all changes to the "ud_smoke" field. +func (m *StatsMutation) ResetUdSmoke() { + m.ud_smoke = nil + m.addud_smoke = nil + delete(m.clearedFields, stats.FieldUdSmoke) +} + +// SetHitGroupHead sets the "hit_group_head" field. +func (m *StatsMutation) SetHitGroupHead(u uint) { + m.hit_group_head = &u + m.addhit_group_head = nil +} + +// HitGroupHead returns the value of the "hit_group_head" field in the mutation. +func (m *StatsMutation) HitGroupHead() (r uint, exists bool) { + v := m.hit_group_head + if v == nil { + return + } + return *v, true +} + +// OldHitGroupHead returns the old "hit_group_head" field's value of the Stats entity. +// If the Stats 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 *StatsMutation) OldHitGroupHead(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldHitGroupHead is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldHitGroupHead requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHitGroupHead: %w", err) + } + return oldValue.HitGroupHead, nil +} + +// AddHitGroupHead adds u to the "hit_group_head" field. +func (m *StatsMutation) AddHitGroupHead(u uint) { + if m.addhit_group_head != nil { + *m.addhit_group_head += u + } else { + m.addhit_group_head = &u + } +} + +// AddedHitGroupHead returns the value that was added to the "hit_group_head" field in this mutation. +func (m *StatsMutation) AddedHitGroupHead() (r uint, exists bool) { + v := m.addhit_group_head + if v == nil { + return + } + return *v, true +} + +// ClearHitGroupHead clears the value of the "hit_group_head" field. +func (m *StatsMutation) ClearHitGroupHead() { + m.hit_group_head = nil + m.addhit_group_head = nil + m.clearedFields[stats.FieldHitGroupHead] = struct{}{} +} + +// HitGroupHeadCleared returns if the "hit_group_head" field was cleared in this mutation. +func (m *StatsMutation) HitGroupHeadCleared() bool { + _, ok := m.clearedFields[stats.FieldHitGroupHead] + return ok +} + +// ResetHitGroupHead resets all changes to the "hit_group_head" field. +func (m *StatsMutation) ResetHitGroupHead() { + m.hit_group_head = nil + m.addhit_group_head = nil + delete(m.clearedFields, stats.FieldHitGroupHead) +} + +// SetHitGroupChest sets the "hit_group_chest" field. +func (m *StatsMutation) SetHitGroupChest(u uint) { + m.hit_group_chest = &u + m.addhit_group_chest = nil +} + +// HitGroupChest returns the value of the "hit_group_chest" field in the mutation. +func (m *StatsMutation) HitGroupChest() (r uint, exists bool) { + v := m.hit_group_chest + if v == nil { + return + } + return *v, true +} + +// OldHitGroupChest returns the old "hit_group_chest" field's value of the Stats entity. +// If the Stats 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 *StatsMutation) OldHitGroupChest(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldHitGroupChest is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldHitGroupChest requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHitGroupChest: %w", err) + } + return oldValue.HitGroupChest, nil +} + +// AddHitGroupChest adds u to the "hit_group_chest" field. +func (m *StatsMutation) AddHitGroupChest(u uint) { + if m.addhit_group_chest != nil { + *m.addhit_group_chest += u + } else { + m.addhit_group_chest = &u + } +} + +// AddedHitGroupChest returns the value that was added to the "hit_group_chest" field in this mutation. +func (m *StatsMutation) AddedHitGroupChest() (r uint, exists bool) { + v := m.addhit_group_chest + if v == nil { + return + } + return *v, true +} + +// ClearHitGroupChest clears the value of the "hit_group_chest" field. +func (m *StatsMutation) ClearHitGroupChest() { + m.hit_group_chest = nil + m.addhit_group_chest = nil + m.clearedFields[stats.FieldHitGroupChest] = struct{}{} +} + +// HitGroupChestCleared returns if the "hit_group_chest" field was cleared in this mutation. +func (m *StatsMutation) HitGroupChestCleared() bool { + _, ok := m.clearedFields[stats.FieldHitGroupChest] + return ok +} + +// ResetHitGroupChest resets all changes to the "hit_group_chest" field. +func (m *StatsMutation) ResetHitGroupChest() { + m.hit_group_chest = nil + m.addhit_group_chest = nil + delete(m.clearedFields, stats.FieldHitGroupChest) +} + +// SetHitGroupStomach sets the "hit_group_stomach" field. +func (m *StatsMutation) SetHitGroupStomach(u uint) { + m.hit_group_stomach = &u + m.addhit_group_stomach = nil +} + +// HitGroupStomach returns the value of the "hit_group_stomach" field in the mutation. +func (m *StatsMutation) HitGroupStomach() (r uint, exists bool) { + v := m.hit_group_stomach + if v == nil { + return + } + return *v, true +} + +// OldHitGroupStomach returns the old "hit_group_stomach" field's value of the Stats entity. +// If the Stats 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 *StatsMutation) OldHitGroupStomach(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldHitGroupStomach is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldHitGroupStomach requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHitGroupStomach: %w", err) + } + return oldValue.HitGroupStomach, nil +} + +// AddHitGroupStomach adds u to the "hit_group_stomach" field. +func (m *StatsMutation) AddHitGroupStomach(u uint) { + if m.addhit_group_stomach != nil { + *m.addhit_group_stomach += u + } else { + m.addhit_group_stomach = &u + } +} + +// AddedHitGroupStomach returns the value that was added to the "hit_group_stomach" field in this mutation. +func (m *StatsMutation) AddedHitGroupStomach() (r uint, exists bool) { + v := m.addhit_group_stomach + if v == nil { + return + } + return *v, true +} + +// ClearHitGroupStomach clears the value of the "hit_group_stomach" field. +func (m *StatsMutation) ClearHitGroupStomach() { + m.hit_group_stomach = nil + m.addhit_group_stomach = nil + m.clearedFields[stats.FieldHitGroupStomach] = struct{}{} +} + +// HitGroupStomachCleared returns if the "hit_group_stomach" field was cleared in this mutation. +func (m *StatsMutation) HitGroupStomachCleared() bool { + _, ok := m.clearedFields[stats.FieldHitGroupStomach] + return ok +} + +// ResetHitGroupStomach resets all changes to the "hit_group_stomach" field. +func (m *StatsMutation) ResetHitGroupStomach() { + m.hit_group_stomach = nil + m.addhit_group_stomach = nil + delete(m.clearedFields, stats.FieldHitGroupStomach) +} + +// SetHitGroupLeftArm sets the "hit_group_left_arm" field. +func (m *StatsMutation) SetHitGroupLeftArm(u uint) { + m.hit_group_left_arm = &u + m.addhit_group_left_arm = nil +} + +// HitGroupLeftArm returns the value of the "hit_group_left_arm" field in the mutation. +func (m *StatsMutation) HitGroupLeftArm() (r uint, exists bool) { + v := m.hit_group_left_arm + if v == nil { + return + } + return *v, true +} + +// OldHitGroupLeftArm returns the old "hit_group_left_arm" field's value of the Stats entity. +// If the Stats 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 *StatsMutation) OldHitGroupLeftArm(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldHitGroupLeftArm is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldHitGroupLeftArm requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHitGroupLeftArm: %w", err) + } + return oldValue.HitGroupLeftArm, nil +} + +// AddHitGroupLeftArm adds u to the "hit_group_left_arm" field. +func (m *StatsMutation) AddHitGroupLeftArm(u uint) { + if m.addhit_group_left_arm != nil { + *m.addhit_group_left_arm += u + } else { + m.addhit_group_left_arm = &u + } +} + +// AddedHitGroupLeftArm returns the value that was added to the "hit_group_left_arm" field in this mutation. +func (m *StatsMutation) AddedHitGroupLeftArm() (r uint, exists bool) { + v := m.addhit_group_left_arm + if v == nil { + return + } + return *v, true +} + +// ClearHitGroupLeftArm clears the value of the "hit_group_left_arm" field. +func (m *StatsMutation) ClearHitGroupLeftArm() { + m.hit_group_left_arm = nil + m.addhit_group_left_arm = nil + m.clearedFields[stats.FieldHitGroupLeftArm] = struct{}{} +} + +// HitGroupLeftArmCleared returns if the "hit_group_left_arm" field was cleared in this mutation. +func (m *StatsMutation) HitGroupLeftArmCleared() bool { + _, ok := m.clearedFields[stats.FieldHitGroupLeftArm] + return ok +} + +// ResetHitGroupLeftArm resets all changes to the "hit_group_left_arm" field. +func (m *StatsMutation) ResetHitGroupLeftArm() { + m.hit_group_left_arm = nil + m.addhit_group_left_arm = nil + delete(m.clearedFields, stats.FieldHitGroupLeftArm) +} + +// SetHitGroupRightArm sets the "hit_group_right_arm" field. +func (m *StatsMutation) SetHitGroupRightArm(u uint) { + m.hit_group_right_arm = &u + m.addhit_group_right_arm = nil +} + +// HitGroupRightArm returns the value of the "hit_group_right_arm" field in the mutation. +func (m *StatsMutation) HitGroupRightArm() (r uint, exists bool) { + v := m.hit_group_right_arm + if v == nil { + return + } + return *v, true +} + +// OldHitGroupRightArm returns the old "hit_group_right_arm" field's value of the Stats entity. +// If the Stats 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 *StatsMutation) OldHitGroupRightArm(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldHitGroupRightArm is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldHitGroupRightArm requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHitGroupRightArm: %w", err) + } + return oldValue.HitGroupRightArm, nil +} + +// AddHitGroupRightArm adds u to the "hit_group_right_arm" field. +func (m *StatsMutation) AddHitGroupRightArm(u uint) { + if m.addhit_group_right_arm != nil { + *m.addhit_group_right_arm += u + } else { + m.addhit_group_right_arm = &u + } +} + +// AddedHitGroupRightArm returns the value that was added to the "hit_group_right_arm" field in this mutation. +func (m *StatsMutation) AddedHitGroupRightArm() (r uint, exists bool) { + v := m.addhit_group_right_arm + if v == nil { + return + } + return *v, true +} + +// ClearHitGroupRightArm clears the value of the "hit_group_right_arm" field. +func (m *StatsMutation) ClearHitGroupRightArm() { + m.hit_group_right_arm = nil + m.addhit_group_right_arm = nil + m.clearedFields[stats.FieldHitGroupRightArm] = struct{}{} +} + +// HitGroupRightArmCleared returns if the "hit_group_right_arm" field was cleared in this mutation. +func (m *StatsMutation) HitGroupRightArmCleared() bool { + _, ok := m.clearedFields[stats.FieldHitGroupRightArm] + return ok +} + +// ResetHitGroupRightArm resets all changes to the "hit_group_right_arm" field. +func (m *StatsMutation) ResetHitGroupRightArm() { + m.hit_group_right_arm = nil + m.addhit_group_right_arm = nil + delete(m.clearedFields, stats.FieldHitGroupRightArm) +} + +// SetHitGroupLeftLeg sets the "hit_group_left_leg" field. +func (m *StatsMutation) SetHitGroupLeftLeg(u uint) { + m.hit_group_left_leg = &u + m.addhit_group_left_leg = nil +} + +// HitGroupLeftLeg returns the value of the "hit_group_left_leg" field in the mutation. +func (m *StatsMutation) HitGroupLeftLeg() (r uint, exists bool) { + v := m.hit_group_left_leg + if v == nil { + return + } + return *v, true +} + +// OldHitGroupLeftLeg returns the old "hit_group_left_leg" field's value of the Stats entity. +// If the Stats 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 *StatsMutation) OldHitGroupLeftLeg(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldHitGroupLeftLeg is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldHitGroupLeftLeg requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHitGroupLeftLeg: %w", err) + } + return oldValue.HitGroupLeftLeg, nil +} + +// AddHitGroupLeftLeg adds u to the "hit_group_left_leg" field. +func (m *StatsMutation) AddHitGroupLeftLeg(u uint) { + if m.addhit_group_left_leg != nil { + *m.addhit_group_left_leg += u + } else { + m.addhit_group_left_leg = &u + } +} + +// AddedHitGroupLeftLeg returns the value that was added to the "hit_group_left_leg" field in this mutation. +func (m *StatsMutation) AddedHitGroupLeftLeg() (r uint, exists bool) { + v := m.addhit_group_left_leg + if v == nil { + return + } + return *v, true +} + +// ClearHitGroupLeftLeg clears the value of the "hit_group_left_leg" field. +func (m *StatsMutation) ClearHitGroupLeftLeg() { + m.hit_group_left_leg = nil + m.addhit_group_left_leg = nil + m.clearedFields[stats.FieldHitGroupLeftLeg] = struct{}{} +} + +// HitGroupLeftLegCleared returns if the "hit_group_left_leg" field was cleared in this mutation. +func (m *StatsMutation) HitGroupLeftLegCleared() bool { + _, ok := m.clearedFields[stats.FieldHitGroupLeftLeg] + return ok +} + +// ResetHitGroupLeftLeg resets all changes to the "hit_group_left_leg" field. +func (m *StatsMutation) ResetHitGroupLeftLeg() { + m.hit_group_left_leg = nil + m.addhit_group_left_leg = nil + delete(m.clearedFields, stats.FieldHitGroupLeftLeg) +} + +// SetHitGroupRightLeg sets the "hit_group_right_leg" field. +func (m *StatsMutation) SetHitGroupRightLeg(u uint) { + m.hit_group_right_leg = &u + m.addhit_group_right_leg = nil +} + +// HitGroupRightLeg returns the value of the "hit_group_right_leg" field in the mutation. +func (m *StatsMutation) HitGroupRightLeg() (r uint, exists bool) { + v := m.hit_group_right_leg + if v == nil { + return + } + return *v, true +} + +// OldHitGroupRightLeg returns the old "hit_group_right_leg" field's value of the Stats entity. +// If the Stats 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 *StatsMutation) OldHitGroupRightLeg(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldHitGroupRightLeg is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldHitGroupRightLeg requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHitGroupRightLeg: %w", err) + } + return oldValue.HitGroupRightLeg, nil +} + +// AddHitGroupRightLeg adds u to the "hit_group_right_leg" field. +func (m *StatsMutation) AddHitGroupRightLeg(u uint) { + if m.addhit_group_right_leg != nil { + *m.addhit_group_right_leg += u + } else { + m.addhit_group_right_leg = &u + } +} + +// AddedHitGroupRightLeg returns the value that was added to the "hit_group_right_leg" field in this mutation. +func (m *StatsMutation) AddedHitGroupRightLeg() (r uint, exists bool) { + v := m.addhit_group_right_leg + if v == nil { + return + } + return *v, true +} + +// ClearHitGroupRightLeg clears the value of the "hit_group_right_leg" field. +func (m *StatsMutation) ClearHitGroupRightLeg() { + m.hit_group_right_leg = nil + m.addhit_group_right_leg = nil + m.clearedFields[stats.FieldHitGroupRightLeg] = struct{}{} +} + +// HitGroupRightLegCleared returns if the "hit_group_right_leg" field was cleared in this mutation. +func (m *StatsMutation) HitGroupRightLegCleared() bool { + _, ok := m.clearedFields[stats.FieldHitGroupRightLeg] + return ok +} + +// ResetHitGroupRightLeg resets all changes to the "hit_group_right_leg" field. +func (m *StatsMutation) ResetHitGroupRightLeg() { + m.hit_group_right_leg = nil + m.addhit_group_right_leg = nil + delete(m.clearedFields, stats.FieldHitGroupRightLeg) +} + +// SetHitGroupGear sets the "hit_group_gear" field. +func (m *StatsMutation) SetHitGroupGear(u uint) { + m.hit_group_gear = &u + m.addhit_group_gear = nil +} + +// HitGroupGear returns the value of the "hit_group_gear" field in the mutation. +func (m *StatsMutation) HitGroupGear() (r uint, exists bool) { + v := m.hit_group_gear + if v == nil { + return + } + return *v, true +} + +// OldHitGroupGear returns the old "hit_group_gear" field's value of the Stats entity. +// If the Stats 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 *StatsMutation) OldHitGroupGear(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldHitGroupGear is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldHitGroupGear requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHitGroupGear: %w", err) + } + return oldValue.HitGroupGear, nil +} + +// AddHitGroupGear adds u to the "hit_group_gear" field. +func (m *StatsMutation) AddHitGroupGear(u uint) { + if m.addhit_group_gear != nil { + *m.addhit_group_gear += u + } else { + m.addhit_group_gear = &u + } +} + +// AddedHitGroupGear returns the value that was added to the "hit_group_gear" field in this mutation. +func (m *StatsMutation) AddedHitGroupGear() (r uint, exists bool) { + v := m.addhit_group_gear + if v == nil { + return + } + return *v, true +} + +// ClearHitGroupGear clears the value of the "hit_group_gear" field. +func (m *StatsMutation) ClearHitGroupGear() { + m.hit_group_gear = nil + m.addhit_group_gear = nil + m.clearedFields[stats.FieldHitGroupGear] = struct{}{} +} + +// HitGroupGearCleared returns if the "hit_group_gear" field was cleared in this mutation. +func (m *StatsMutation) HitGroupGearCleared() bool { + _, ok := m.clearedFields[stats.FieldHitGroupGear] + return ok +} + +// ResetHitGroupGear resets all changes to the "hit_group_gear" field. +func (m *StatsMutation) ResetHitGroupGear() { + m.hit_group_gear = nil + m.addhit_group_gear = nil + delete(m.clearedFields, stats.FieldHitGroupGear) +} + +// SetCrosshair sets the "crosshair" field. +func (m *StatsMutation) SetCrosshair(s string) { + m.crosshair = &s +} + +// Crosshair returns the value of the "crosshair" field in the mutation. +func (m *StatsMutation) Crosshair() (r string, exists bool) { + v := m.crosshair + if v == nil { + return + } + return *v, true +} + +// OldCrosshair returns the old "crosshair" field's value of the Stats entity. +// If the Stats 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 *StatsMutation) OldCrosshair(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldCrosshair is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldCrosshair requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCrosshair: %w", err) + } + return oldValue.Crosshair, nil +} + +// ClearCrosshair clears the value of the "crosshair" field. +func (m *StatsMutation) ClearCrosshair() { + m.crosshair = nil + m.clearedFields[stats.FieldCrosshair] = struct{}{} +} + +// CrosshairCleared returns if the "crosshair" field was cleared in this mutation. +func (m *StatsMutation) CrosshairCleared() bool { + _, ok := m.clearedFields[stats.FieldCrosshair] + return ok +} + +// ResetCrosshair resets all changes to the "crosshair" field. +func (m *StatsMutation) ResetCrosshair() { + m.crosshair = nil + delete(m.clearedFields, stats.FieldCrosshair) +} + +// SetColor sets the "color" field. +func (m *StatsMutation) SetColor(s stats.Color) { + m.color = &s +} + +// Color returns the value of the "color" field in the mutation. +func (m *StatsMutation) Color() (r stats.Color, exists bool) { + v := m.color + if v == nil { + return + } + return *v, true +} + +// OldColor returns the old "color" field's value of the Stats entity. +// If the Stats 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 *StatsMutation) OldColor(ctx context.Context) (v stats.Color, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldColor is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldColor requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldColor: %w", err) + } + return oldValue.Color, nil +} + +// ClearColor clears the value of the "color" field. +func (m *StatsMutation) ClearColor() { + m.color = nil + m.clearedFields[stats.FieldColor] = struct{}{} +} + +// ColorCleared returns if the "color" field was cleared in this mutation. +func (m *StatsMutation) ColorCleared() bool { + _, ok := m.clearedFields[stats.FieldColor] + return ok +} + +// ResetColor resets all changes to the "color" field. +func (m *StatsMutation) ResetColor() { + m.color = nil + delete(m.clearedFields, stats.FieldColor) +} + +// SetKast sets the "kast" field. +func (m *StatsMutation) SetKast(i int) { + m.kast = &i + m.addkast = nil +} + +// Kast returns the value of the "kast" field in the mutation. +func (m *StatsMutation) Kast() (r int, exists bool) { + v := m.kast + if v == nil { + return + } + return *v, true +} + +// OldKast returns the old "kast" field's value of the Stats entity. +// If the Stats 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 *StatsMutation) OldKast(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldKast is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldKast requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldKast: %w", err) + } + return oldValue.Kast, nil +} + +// AddKast adds i to the "kast" field. +func (m *StatsMutation) AddKast(i int) { + if m.addkast != nil { + *m.addkast += i + } else { + m.addkast = &i + } +} + +// AddedKast returns the value that was added to the "kast" field in this mutation. +func (m *StatsMutation) AddedKast() (r int, exists bool) { + v := m.addkast + if v == nil { + return + } + return *v, true +} + +// ClearKast clears the value of the "kast" field. +func (m *StatsMutation) ClearKast() { + m.kast = nil + m.addkast = nil + m.clearedFields[stats.FieldKast] = struct{}{} +} + +// KastCleared returns if the "kast" field was cleared in this mutation. +func (m *StatsMutation) KastCleared() bool { + _, ok := m.clearedFields[stats.FieldKast] + return ok +} + +// ResetKast resets all changes to the "kast" field. +func (m *StatsMutation) ResetKast() { + m.kast = nil + m.addkast = nil + delete(m.clearedFields, stats.FieldKast) +} + +// SetFlashDurationSelf sets the "flash_duration_self" field. +func (m *StatsMutation) SetFlashDurationSelf(f float32) { + m.flash_duration_self = &f + m.addflash_duration_self = nil +} + +// FlashDurationSelf returns the value of the "flash_duration_self" field in the mutation. +func (m *StatsMutation) FlashDurationSelf() (r float32, exists bool) { + v := m.flash_duration_self + if v == nil { + return + } + return *v, true +} + +// OldFlashDurationSelf returns the old "flash_duration_self" field's value of the Stats entity. +// If the Stats 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 *StatsMutation) OldFlashDurationSelf(ctx context.Context) (v float32, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldFlashDurationSelf is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldFlashDurationSelf requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFlashDurationSelf: %w", err) + } + return oldValue.FlashDurationSelf, nil +} + +// AddFlashDurationSelf adds f to the "flash_duration_self" field. +func (m *StatsMutation) AddFlashDurationSelf(f float32) { + if m.addflash_duration_self != nil { + *m.addflash_duration_self += f + } else { + m.addflash_duration_self = &f + } +} + +// AddedFlashDurationSelf returns the value that was added to the "flash_duration_self" field in this mutation. +func (m *StatsMutation) AddedFlashDurationSelf() (r float32, exists bool) { + v := m.addflash_duration_self + if v == nil { + return + } + return *v, true +} + +// ClearFlashDurationSelf clears the value of the "flash_duration_self" field. +func (m *StatsMutation) ClearFlashDurationSelf() { + m.flash_duration_self = nil + m.addflash_duration_self = nil + m.clearedFields[stats.FieldFlashDurationSelf] = struct{}{} +} + +// FlashDurationSelfCleared returns if the "flash_duration_self" field was cleared in this mutation. +func (m *StatsMutation) FlashDurationSelfCleared() bool { + _, ok := m.clearedFields[stats.FieldFlashDurationSelf] + return ok +} + +// ResetFlashDurationSelf resets all changes to the "flash_duration_self" field. +func (m *StatsMutation) ResetFlashDurationSelf() { + m.flash_duration_self = nil + m.addflash_duration_self = nil + delete(m.clearedFields, stats.FieldFlashDurationSelf) +} + +// SetFlashDurationTeam sets the "flash_duration_team" field. +func (m *StatsMutation) SetFlashDurationTeam(f float32) { + m.flash_duration_team = &f + m.addflash_duration_team = nil +} + +// FlashDurationTeam returns the value of the "flash_duration_team" field in the mutation. +func (m *StatsMutation) FlashDurationTeam() (r float32, exists bool) { + v := m.flash_duration_team + if v == nil { + return + } + return *v, true +} + +// OldFlashDurationTeam returns the old "flash_duration_team" field's value of the Stats entity. +// If the Stats 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 *StatsMutation) OldFlashDurationTeam(ctx context.Context) (v float32, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldFlashDurationTeam is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldFlashDurationTeam requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFlashDurationTeam: %w", err) + } + return oldValue.FlashDurationTeam, nil +} + +// AddFlashDurationTeam adds f to the "flash_duration_team" field. +func (m *StatsMutation) AddFlashDurationTeam(f float32) { + if m.addflash_duration_team != nil { + *m.addflash_duration_team += f + } else { + m.addflash_duration_team = &f + } +} + +// AddedFlashDurationTeam returns the value that was added to the "flash_duration_team" field in this mutation. +func (m *StatsMutation) AddedFlashDurationTeam() (r float32, exists bool) { + v := m.addflash_duration_team + if v == nil { + return + } + return *v, true +} + +// ClearFlashDurationTeam clears the value of the "flash_duration_team" field. +func (m *StatsMutation) ClearFlashDurationTeam() { + m.flash_duration_team = nil + m.addflash_duration_team = nil + m.clearedFields[stats.FieldFlashDurationTeam] = struct{}{} +} + +// FlashDurationTeamCleared returns if the "flash_duration_team" field was cleared in this mutation. +func (m *StatsMutation) FlashDurationTeamCleared() bool { + _, ok := m.clearedFields[stats.FieldFlashDurationTeam] + return ok +} + +// ResetFlashDurationTeam resets all changes to the "flash_duration_team" field. +func (m *StatsMutation) ResetFlashDurationTeam() { + m.flash_duration_team = nil + m.addflash_duration_team = nil + delete(m.clearedFields, stats.FieldFlashDurationTeam) +} + +// SetFlashDurationEnemy sets the "flash_duration_enemy" field. +func (m *StatsMutation) SetFlashDurationEnemy(f float32) { + m.flash_duration_enemy = &f + m.addflash_duration_enemy = nil +} + +// FlashDurationEnemy returns the value of the "flash_duration_enemy" field in the mutation. +func (m *StatsMutation) FlashDurationEnemy() (r float32, exists bool) { + v := m.flash_duration_enemy + if v == nil { + return + } + return *v, true +} + +// OldFlashDurationEnemy returns the old "flash_duration_enemy" field's value of the Stats entity. +// If the Stats 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 *StatsMutation) OldFlashDurationEnemy(ctx context.Context) (v float32, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldFlashDurationEnemy is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldFlashDurationEnemy requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFlashDurationEnemy: %w", err) + } + return oldValue.FlashDurationEnemy, nil +} + +// AddFlashDurationEnemy adds f to the "flash_duration_enemy" field. +func (m *StatsMutation) AddFlashDurationEnemy(f float32) { + if m.addflash_duration_enemy != nil { + *m.addflash_duration_enemy += f + } else { + m.addflash_duration_enemy = &f + } +} + +// AddedFlashDurationEnemy returns the value that was added to the "flash_duration_enemy" field in this mutation. +func (m *StatsMutation) AddedFlashDurationEnemy() (r float32, exists bool) { + v := m.addflash_duration_enemy + if v == nil { + return + } + return *v, true +} + +// ClearFlashDurationEnemy clears the value of the "flash_duration_enemy" field. +func (m *StatsMutation) ClearFlashDurationEnemy() { + m.flash_duration_enemy = nil + m.addflash_duration_enemy = nil + m.clearedFields[stats.FieldFlashDurationEnemy] = struct{}{} +} + +// FlashDurationEnemyCleared returns if the "flash_duration_enemy" field was cleared in this mutation. +func (m *StatsMutation) FlashDurationEnemyCleared() bool { + _, ok := m.clearedFields[stats.FieldFlashDurationEnemy] + return ok +} + +// ResetFlashDurationEnemy resets all changes to the "flash_duration_enemy" field. +func (m *StatsMutation) ResetFlashDurationEnemy() { + m.flash_duration_enemy = nil + m.addflash_duration_enemy = nil + delete(m.clearedFields, stats.FieldFlashDurationEnemy) +} + +// SetFlashTotalSelf sets the "flash_total_self" field. +func (m *StatsMutation) SetFlashTotalSelf(u uint) { + m.flash_total_self = &u + m.addflash_total_self = nil +} + +// FlashTotalSelf returns the value of the "flash_total_self" field in the mutation. +func (m *StatsMutation) FlashTotalSelf() (r uint, exists bool) { + v := m.flash_total_self + if v == nil { + return + } + return *v, true +} + +// OldFlashTotalSelf returns the old "flash_total_self" field's value of the Stats entity. +// If the Stats 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 *StatsMutation) OldFlashTotalSelf(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldFlashTotalSelf is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldFlashTotalSelf requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFlashTotalSelf: %w", err) + } + return oldValue.FlashTotalSelf, nil +} + +// AddFlashTotalSelf adds u to the "flash_total_self" field. +func (m *StatsMutation) AddFlashTotalSelf(u uint) { + if m.addflash_total_self != nil { + *m.addflash_total_self += u + } else { + m.addflash_total_self = &u + } +} + +// AddedFlashTotalSelf returns the value that was added to the "flash_total_self" field in this mutation. +func (m *StatsMutation) AddedFlashTotalSelf() (r uint, exists bool) { + v := m.addflash_total_self + if v == nil { + return + } + return *v, true +} + +// ClearFlashTotalSelf clears the value of the "flash_total_self" field. +func (m *StatsMutation) ClearFlashTotalSelf() { + m.flash_total_self = nil + m.addflash_total_self = nil + m.clearedFields[stats.FieldFlashTotalSelf] = struct{}{} +} + +// FlashTotalSelfCleared returns if the "flash_total_self" field was cleared in this mutation. +func (m *StatsMutation) FlashTotalSelfCleared() bool { + _, ok := m.clearedFields[stats.FieldFlashTotalSelf] + return ok +} + +// ResetFlashTotalSelf resets all changes to the "flash_total_self" field. +func (m *StatsMutation) ResetFlashTotalSelf() { + m.flash_total_self = nil + m.addflash_total_self = nil + delete(m.clearedFields, stats.FieldFlashTotalSelf) +} + +// SetFlashTotalTeam sets the "flash_total_team" field. +func (m *StatsMutation) SetFlashTotalTeam(u uint) { + m.flash_total_team = &u + m.addflash_total_team = nil +} + +// FlashTotalTeam returns the value of the "flash_total_team" field in the mutation. +func (m *StatsMutation) FlashTotalTeam() (r uint, exists bool) { + v := m.flash_total_team + if v == nil { + return + } + return *v, true +} + +// OldFlashTotalTeam returns the old "flash_total_team" field's value of the Stats entity. +// If the Stats 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 *StatsMutation) OldFlashTotalTeam(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldFlashTotalTeam is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldFlashTotalTeam requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFlashTotalTeam: %w", err) + } + return oldValue.FlashTotalTeam, nil +} + +// AddFlashTotalTeam adds u to the "flash_total_team" field. +func (m *StatsMutation) AddFlashTotalTeam(u uint) { + if m.addflash_total_team != nil { + *m.addflash_total_team += u + } else { + m.addflash_total_team = &u + } +} + +// AddedFlashTotalTeam returns the value that was added to the "flash_total_team" field in this mutation. +func (m *StatsMutation) AddedFlashTotalTeam() (r uint, exists bool) { + v := m.addflash_total_team + if v == nil { + return + } + return *v, true +} + +// ClearFlashTotalTeam clears the value of the "flash_total_team" field. +func (m *StatsMutation) ClearFlashTotalTeam() { + m.flash_total_team = nil + m.addflash_total_team = nil + m.clearedFields[stats.FieldFlashTotalTeam] = struct{}{} +} + +// FlashTotalTeamCleared returns if the "flash_total_team" field was cleared in this mutation. +func (m *StatsMutation) FlashTotalTeamCleared() bool { + _, ok := m.clearedFields[stats.FieldFlashTotalTeam] + return ok +} + +// ResetFlashTotalTeam resets all changes to the "flash_total_team" field. +func (m *StatsMutation) ResetFlashTotalTeam() { + m.flash_total_team = nil + m.addflash_total_team = nil + delete(m.clearedFields, stats.FieldFlashTotalTeam) +} + +// SetFlashTotalEnemy sets the "flash_total_enemy" field. +func (m *StatsMutation) SetFlashTotalEnemy(u uint) { + m.flash_total_enemy = &u + m.addflash_total_enemy = nil +} + +// FlashTotalEnemy returns the value of the "flash_total_enemy" field in the mutation. +func (m *StatsMutation) FlashTotalEnemy() (r uint, exists bool) { + v := m.flash_total_enemy + if v == nil { + return + } + return *v, true +} + +// OldFlashTotalEnemy returns the old "flash_total_enemy" field's value of the Stats entity. +// If the Stats 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 *StatsMutation) OldFlashTotalEnemy(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldFlashTotalEnemy is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldFlashTotalEnemy requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFlashTotalEnemy: %w", err) + } + return oldValue.FlashTotalEnemy, nil +} + +// AddFlashTotalEnemy adds u to the "flash_total_enemy" field. +func (m *StatsMutation) AddFlashTotalEnemy(u uint) { + if m.addflash_total_enemy != nil { + *m.addflash_total_enemy += u + } else { + m.addflash_total_enemy = &u + } +} + +// AddedFlashTotalEnemy returns the value that was added to the "flash_total_enemy" field in this mutation. +func (m *StatsMutation) AddedFlashTotalEnemy() (r uint, exists bool) { + v := m.addflash_total_enemy + if v == nil { + return + } + return *v, true +} + +// ClearFlashTotalEnemy clears the value of the "flash_total_enemy" field. +func (m *StatsMutation) ClearFlashTotalEnemy() { + m.flash_total_enemy = nil + m.addflash_total_enemy = nil + m.clearedFields[stats.FieldFlashTotalEnemy] = struct{}{} +} + +// FlashTotalEnemyCleared returns if the "flash_total_enemy" field was cleared in this mutation. +func (m *StatsMutation) FlashTotalEnemyCleared() bool { + _, ok := m.clearedFields[stats.FieldFlashTotalEnemy] + return ok +} + +// ResetFlashTotalEnemy resets all changes to the "flash_total_enemy" field. +func (m *StatsMutation) ResetFlashTotalEnemy() { + m.flash_total_enemy = nil + m.addflash_total_enemy = nil + delete(m.clearedFields, stats.FieldFlashTotalEnemy) +} + +// SetMatchStats sets the "match_stats" field. +func (m *StatsMutation) SetMatchStats(u uint64) { + m.matches = &u +} + +// MatchStats returns the value of the "match_stats" field in the mutation. +func (m *StatsMutation) MatchStats() (r uint64, exists bool) { + v := m.matches + if v == nil { + return + } + return *v, true +} + +// OldMatchStats returns the old "match_stats" field's value of the Stats entity. +// If the Stats 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 *StatsMutation) OldMatchStats(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldMatchStats is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldMatchStats requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMatchStats: %w", err) + } + return oldValue.MatchStats, nil +} + +// ClearMatchStats clears the value of the "match_stats" field. +func (m *StatsMutation) ClearMatchStats() { + m.matches = nil + m.clearedFields[stats.FieldMatchStats] = struct{}{} +} + +// MatchStatsCleared returns if the "match_stats" field was cleared in this mutation. +func (m *StatsMutation) MatchStatsCleared() bool { + _, ok := m.clearedFields[stats.FieldMatchStats] + return ok +} + +// ResetMatchStats resets all changes to the "match_stats" field. +func (m *StatsMutation) ResetMatchStats() { + m.matches = nil + delete(m.clearedFields, stats.FieldMatchStats) +} + +// SetPlayerStats sets the "player_stats" field. +func (m *StatsMutation) SetPlayerStats(u uint64) { + m.players = &u +} + +// PlayerStats returns the value of the "player_stats" field in the mutation. +func (m *StatsMutation) PlayerStats() (r uint64, exists bool) { + v := m.players + if v == nil { + return + } + return *v, true +} + +// OldPlayerStats returns the old "player_stats" field's value of the Stats entity. +// If the Stats 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 *StatsMutation) OldPlayerStats(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldPlayerStats is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldPlayerStats requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPlayerStats: %w", err) + } + return oldValue.PlayerStats, nil +} + +// ClearPlayerStats clears the value of the "player_stats" field. +func (m *StatsMutation) ClearPlayerStats() { + m.players = nil + m.clearedFields[stats.FieldPlayerStats] = struct{}{} +} + +// PlayerStatsCleared returns if the "player_stats" field was cleared in this mutation. +func (m *StatsMutation) PlayerStatsCleared() bool { + _, ok := m.clearedFields[stats.FieldPlayerStats] + return ok +} + +// ResetPlayerStats resets all changes to the "player_stats" field. +func (m *StatsMutation) ResetPlayerStats() { + m.players = nil + delete(m.clearedFields, stats.FieldPlayerStats) } // SetMatchesID sets the "matches" edge to the Match entity by id. @@ -3204,7 +5258,7 @@ func (m *StatsMutation) ClearMatches() { // MatchesCleared reports if the "matches" edge to the Match entity was cleared. func (m *StatsMutation) MatchesCleared() bool { - return m.clearedmatches + return m.MatchStatsCleared() || m.clearedmatches } // MatchesID returns the "matches" edge ID in the mutation. @@ -3243,7 +5297,7 @@ func (m *StatsMutation) ClearPlayers() { // PlayersCleared reports if the "players" edge to the Player entity was cleared. func (m *StatsMutation) PlayersCleared() bool { - return m.clearedplayers + return m.PlayerStatsCleared() || m.clearedplayers } // PlayersID returns the "players" edge ID in the mutation. @@ -3270,6 +5324,60 @@ func (m *StatsMutation) ResetPlayers() { m.clearedplayers = false } +// AddWeaponStatIDs adds the "weapon_stats" edge to the WeaponStats entity by ids. +func (m *StatsMutation) AddWeaponStatIDs(ids ...int) { + if m.weapon_stats == nil { + m.weapon_stats = make(map[int]struct{}) + } + for i := range ids { + m.weapon_stats[ids[i]] = struct{}{} + } +} + +// ClearWeaponStats clears the "weapon_stats" edge to the WeaponStats entity. +func (m *StatsMutation) ClearWeaponStats() { + m.clearedweapon_stats = true +} + +// WeaponStatsCleared reports if the "weapon_stats" edge to the WeaponStats entity was cleared. +func (m *StatsMutation) WeaponStatsCleared() bool { + return m.clearedweapon_stats +} + +// RemoveWeaponStatIDs removes the "weapon_stats" edge to the WeaponStats entity by IDs. +func (m *StatsMutation) RemoveWeaponStatIDs(ids ...int) { + if m.removedweapon_stats == nil { + m.removedweapon_stats = make(map[int]struct{}) + } + for i := range ids { + delete(m.weapon_stats, ids[i]) + m.removedweapon_stats[ids[i]] = struct{}{} + } +} + +// RemovedWeaponStats returns the removed IDs of the "weapon_stats" edge to the WeaponStats entity. +func (m *StatsMutation) RemovedWeaponStatsIDs() (ids []int) { + for id := range m.removedweapon_stats { + ids = append(ids, id) + } + return +} + +// WeaponStatsIDs returns the "weapon_stats" edge IDs in the mutation. +func (m *StatsMutation) WeaponStatsIDs() (ids []int) { + for id := range m.weapon_stats { + ids = append(ids, id) + } + return +} + +// ResetWeaponStats resets all changes to the "weapon_stats" edge. +func (m *StatsMutation) ResetWeaponStats() { + m.weapon_stats = nil + m.clearedweapon_stats = false + m.removedweapon_stats = nil +} + // Where appends a list predicates to the StatsMutation builder. func (m *StatsMutation) Where(ps ...predicate.Stats) { m.predicates = append(m.predicates, ps...) @@ -3289,7 +5397,7 @@ func (m *StatsMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *StatsMutation) Fields() []string { - fields := make([]string, 0, 8) + fields := make([]string, 0, 39) if m.team_id != nil { fields = append(fields, stats.FieldTeamID) } @@ -3311,8 +5419,101 @@ func (m *StatsMutation) Fields() []string { if m.score != nil { fields = append(fields, stats.FieldScore) } - if m.extended != nil { - fields = append(fields, stats.FieldExtended) + if m.rank_new != nil { + fields = append(fields, stats.FieldRankNew) + } + if m.rank_old != nil { + fields = append(fields, stats.FieldRankOld) + } + if m.mk_2 != nil { + fields = append(fields, stats.FieldMk2) + } + if m.mk_3 != nil { + fields = append(fields, stats.FieldMk3) + } + if m.mk_4 != nil { + fields = append(fields, stats.FieldMk4) + } + if m.mk_5 != nil { + fields = append(fields, stats.FieldMk5) + } + if m.dmg_enemy != nil { + fields = append(fields, stats.FieldDmgEnemy) + } + if m.dmg_team != nil { + fields = append(fields, stats.FieldDmgTeam) + } + if m.ud_he != nil { + fields = append(fields, stats.FieldUdHe) + } + if m.ud_flames != nil { + fields = append(fields, stats.FieldUdFlames) + } + if m.ud_flash != nil { + fields = append(fields, stats.FieldUdFlash) + } + if m.ud_decoy != nil { + fields = append(fields, stats.FieldUdDecoy) + } + if m.ud_smoke != nil { + fields = append(fields, stats.FieldUdSmoke) + } + if m.hit_group_head != nil { + fields = append(fields, stats.FieldHitGroupHead) + } + if m.hit_group_chest != nil { + fields = append(fields, stats.FieldHitGroupChest) + } + if m.hit_group_stomach != nil { + fields = append(fields, stats.FieldHitGroupStomach) + } + if m.hit_group_left_arm != nil { + fields = append(fields, stats.FieldHitGroupLeftArm) + } + if m.hit_group_right_arm != nil { + fields = append(fields, stats.FieldHitGroupRightArm) + } + if m.hit_group_left_leg != nil { + fields = append(fields, stats.FieldHitGroupLeftLeg) + } + if m.hit_group_right_leg != nil { + fields = append(fields, stats.FieldHitGroupRightLeg) + } + if m.hit_group_gear != nil { + fields = append(fields, stats.FieldHitGroupGear) + } + if m.crosshair != nil { + fields = append(fields, stats.FieldCrosshair) + } + if m.color != nil { + fields = append(fields, stats.FieldColor) + } + if m.kast != nil { + fields = append(fields, stats.FieldKast) + } + if m.flash_duration_self != nil { + fields = append(fields, stats.FieldFlashDurationSelf) + } + if m.flash_duration_team != nil { + fields = append(fields, stats.FieldFlashDurationTeam) + } + if m.flash_duration_enemy != nil { + fields = append(fields, stats.FieldFlashDurationEnemy) + } + if m.flash_total_self != nil { + fields = append(fields, stats.FieldFlashTotalSelf) + } + if m.flash_total_team != nil { + fields = append(fields, stats.FieldFlashTotalTeam) + } + if m.flash_total_enemy != nil { + fields = append(fields, stats.FieldFlashTotalEnemy) + } + if m.matches != nil { + fields = append(fields, stats.FieldMatchStats) + } + if m.players != nil { + fields = append(fields, stats.FieldPlayerStats) } return fields } @@ -3336,8 +5537,70 @@ func (m *StatsMutation) Field(name string) (ent.Value, bool) { return m.Mvp() case stats.FieldScore: return m.Score() - case stats.FieldExtended: - return m.Extended() + case stats.FieldRankNew: + return m.RankNew() + case stats.FieldRankOld: + return m.RankOld() + case stats.FieldMk2: + return m.Mk2() + case stats.FieldMk3: + return m.Mk3() + case stats.FieldMk4: + return m.Mk4() + case stats.FieldMk5: + return m.Mk5() + case stats.FieldDmgEnemy: + return m.DmgEnemy() + case stats.FieldDmgTeam: + return m.DmgTeam() + case stats.FieldUdHe: + return m.UdHe() + case stats.FieldUdFlames: + return m.UdFlames() + case stats.FieldUdFlash: + return m.UdFlash() + case stats.FieldUdDecoy: + return m.UdDecoy() + case stats.FieldUdSmoke: + return m.UdSmoke() + case stats.FieldHitGroupHead: + return m.HitGroupHead() + case stats.FieldHitGroupChest: + return m.HitGroupChest() + case stats.FieldHitGroupStomach: + return m.HitGroupStomach() + case stats.FieldHitGroupLeftArm: + return m.HitGroupLeftArm() + case stats.FieldHitGroupRightArm: + return m.HitGroupRightArm() + case stats.FieldHitGroupLeftLeg: + return m.HitGroupLeftLeg() + case stats.FieldHitGroupRightLeg: + return m.HitGroupRightLeg() + case stats.FieldHitGroupGear: + return m.HitGroupGear() + case stats.FieldCrosshair: + return m.Crosshair() + case stats.FieldColor: + return m.Color() + case stats.FieldKast: + return m.Kast() + case stats.FieldFlashDurationSelf: + return m.FlashDurationSelf() + case stats.FieldFlashDurationTeam: + return m.FlashDurationTeam() + case stats.FieldFlashDurationEnemy: + return m.FlashDurationEnemy() + case stats.FieldFlashTotalSelf: + return m.FlashTotalSelf() + case stats.FieldFlashTotalTeam: + return m.FlashTotalTeam() + case stats.FieldFlashTotalEnemy: + return m.FlashTotalEnemy() + case stats.FieldMatchStats: + return m.MatchStats() + case stats.FieldPlayerStats: + return m.PlayerStats() } return nil, false } @@ -3361,8 +5624,70 @@ func (m *StatsMutation) OldField(ctx context.Context, name string) (ent.Value, e return m.OldMvp(ctx) case stats.FieldScore: return m.OldScore(ctx) - case stats.FieldExtended: - return m.OldExtended(ctx) + case stats.FieldRankNew: + return m.OldRankNew(ctx) + case stats.FieldRankOld: + return m.OldRankOld(ctx) + case stats.FieldMk2: + return m.OldMk2(ctx) + case stats.FieldMk3: + return m.OldMk3(ctx) + case stats.FieldMk4: + return m.OldMk4(ctx) + case stats.FieldMk5: + return m.OldMk5(ctx) + case stats.FieldDmgEnemy: + return m.OldDmgEnemy(ctx) + case stats.FieldDmgTeam: + return m.OldDmgTeam(ctx) + case stats.FieldUdHe: + return m.OldUdHe(ctx) + case stats.FieldUdFlames: + return m.OldUdFlames(ctx) + case stats.FieldUdFlash: + return m.OldUdFlash(ctx) + case stats.FieldUdDecoy: + return m.OldUdDecoy(ctx) + case stats.FieldUdSmoke: + return m.OldUdSmoke(ctx) + case stats.FieldHitGroupHead: + return m.OldHitGroupHead(ctx) + case stats.FieldHitGroupChest: + return m.OldHitGroupChest(ctx) + case stats.FieldHitGroupStomach: + return m.OldHitGroupStomach(ctx) + case stats.FieldHitGroupLeftArm: + return m.OldHitGroupLeftArm(ctx) + case stats.FieldHitGroupRightArm: + return m.OldHitGroupRightArm(ctx) + case stats.FieldHitGroupLeftLeg: + return m.OldHitGroupLeftLeg(ctx) + case stats.FieldHitGroupRightLeg: + return m.OldHitGroupRightLeg(ctx) + case stats.FieldHitGroupGear: + return m.OldHitGroupGear(ctx) + case stats.FieldCrosshair: + return m.OldCrosshair(ctx) + case stats.FieldColor: + return m.OldColor(ctx) + case stats.FieldKast: + return m.OldKast(ctx) + case stats.FieldFlashDurationSelf: + return m.OldFlashDurationSelf(ctx) + case stats.FieldFlashDurationTeam: + return m.OldFlashDurationTeam(ctx) + case stats.FieldFlashDurationEnemy: + return m.OldFlashDurationEnemy(ctx) + case stats.FieldFlashTotalSelf: + return m.OldFlashTotalSelf(ctx) + case stats.FieldFlashTotalTeam: + return m.OldFlashTotalTeam(ctx) + case stats.FieldFlashTotalEnemy: + return m.OldFlashTotalEnemy(ctx) + case stats.FieldMatchStats: + return m.OldMatchStats(ctx) + case stats.FieldPlayerStats: + return m.OldPlayerStats(ctx) } return nil, fmt.Errorf("unknown Stats field %s", name) } @@ -3408,7 +5733,7 @@ func (m *StatsMutation) SetField(name string, value ent.Value) error { m.SetHeadshot(v) return nil case stats.FieldMvp: - v, ok := value.(int) + v, ok := value.(uint) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } @@ -3421,59 +5746,229 @@ func (m *StatsMutation) SetField(name string, value ent.Value) error { } m.SetScore(v) return nil - case stats.FieldExtended: - v, ok := value.(struct { - MultiKills struct { - Duo int "json:\"duo,omitempty\"" - Triple int "json:\"triple,omitempty\"" - Quad int "json:\"quad,omitempty\"" - Pent int "json:\"pent,omitempty\"" - } "json:\"multi_kills,omitempty\"" - Dmg struct { - Enemy int "json:\"enemy,omitempty\"" - Team int "json:\"team,omitempty\"" - UD struct { - HE int "json:\"he,omitempty\"" - Flames int "json:\"flames,omitempty\"" - Flash int "json:\"flash,omitempty\"" - Decoy int "json:\"decoy,omitempty\"" - Smoke int "json:\"smoke,omitempty\"" - } "json:\"ud,omitempty\"" - HitGroup struct { - Head int "json:\"head,omitempty\"" - Chest int "json:\"chest,omitempty\"" - Stomach int "json:\"stomach,omitempty\"" - LeftArm int "json:\"left_arm,omitempty\"" - RightArm int "json:\"right_arm,omitempty\"" - LeftLeg int "json:\"left_leg,omitempty\"" - RightLeg int "json:\"right_leg,omitempty\"" - Gear int "json:\"gear,omitempty\"" - } "json:\"hit_group,omitempty\"" - } "json:\"dmg,omitempty\"" - Crosshair string "json:\"crosshair,omitempty\"" - Color string "json:\"color,omitempty\"" - KAST int "json:\"kast,omitempty\"" - Rank struct { - Old int "json:\"old,omitempty\"" - New int "json:\"new,omitempty\"" - } "json:\"rank,omitempty\"" - Flash struct { - Duration struct { - Self float32 "json:\"self,omitempty\"" - Team float32 "json:\"team,omitempty\"" - Enemy float32 "json:\"enemy,omitempty\"" - } "json:\"duration,omitempty\"" - Total struct { - Team int "json:\"team,omitempty\"" - Enemy int "json:\"enemy,omitempty\"" - Self int "json:\"self,omitempty\"" - } "json:\"total,omitempty\"" - } "json:\"flash,omitempty\"" - }) + case stats.FieldRankNew: + v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetExtended(v) + m.SetRankNew(v) + return nil + case stats.FieldRankOld: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRankOld(v) + return nil + case stats.FieldMk2: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMk2(v) + return nil + case stats.FieldMk3: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMk3(v) + return nil + case stats.FieldMk4: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMk4(v) + return nil + case stats.FieldMk5: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMk5(v) + return nil + case stats.FieldDmgEnemy: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDmgEnemy(v) + return nil + case stats.FieldDmgTeam: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDmgTeam(v) + return nil + case stats.FieldUdHe: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUdHe(v) + return nil + case stats.FieldUdFlames: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUdFlames(v) + return nil + case stats.FieldUdFlash: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUdFlash(v) + return nil + case stats.FieldUdDecoy: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUdDecoy(v) + return nil + case stats.FieldUdSmoke: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUdSmoke(v) + return nil + case stats.FieldHitGroupHead: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHitGroupHead(v) + return nil + case stats.FieldHitGroupChest: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHitGroupChest(v) + return nil + case stats.FieldHitGroupStomach: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHitGroupStomach(v) + return nil + case stats.FieldHitGroupLeftArm: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHitGroupLeftArm(v) + return nil + case stats.FieldHitGroupRightArm: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHitGroupRightArm(v) + return nil + case stats.FieldHitGroupLeftLeg: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHitGroupLeftLeg(v) + return nil + case stats.FieldHitGroupRightLeg: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHitGroupRightLeg(v) + return nil + case stats.FieldHitGroupGear: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHitGroupGear(v) + return nil + case stats.FieldCrosshair: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCrosshair(v) + return nil + case stats.FieldColor: + v, ok := value.(stats.Color) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetColor(v) + return nil + case stats.FieldKast: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetKast(v) + return nil + case stats.FieldFlashDurationSelf: + v, ok := value.(float32) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFlashDurationSelf(v) + return nil + case stats.FieldFlashDurationTeam: + v, ok := value.(float32) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFlashDurationTeam(v) + return nil + case stats.FieldFlashDurationEnemy: + v, ok := value.(float32) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFlashDurationEnemy(v) + return nil + case stats.FieldFlashTotalSelf: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFlashTotalSelf(v) + return nil + case stats.FieldFlashTotalTeam: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFlashTotalTeam(v) + return nil + case stats.FieldFlashTotalEnemy: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFlashTotalEnemy(v) + return nil + case stats.FieldMatchStats: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMatchStats(v) + return nil + case stats.FieldPlayerStats: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPlayerStats(v) return nil } return fmt.Errorf("unknown Stats field %s", name) @@ -3504,6 +5999,90 @@ func (m *StatsMutation) AddedFields() []string { if m.addscore != nil { fields = append(fields, stats.FieldScore) } + if m.addrank_new != nil { + fields = append(fields, stats.FieldRankNew) + } + if m.addrank_old != nil { + fields = append(fields, stats.FieldRankOld) + } + if m.addmk_2 != nil { + fields = append(fields, stats.FieldMk2) + } + if m.addmk_3 != nil { + fields = append(fields, stats.FieldMk3) + } + if m.addmk_4 != nil { + fields = append(fields, stats.FieldMk4) + } + if m.addmk_5 != nil { + fields = append(fields, stats.FieldMk5) + } + if m.adddmg_enemy != nil { + fields = append(fields, stats.FieldDmgEnemy) + } + if m.adddmg_team != nil { + fields = append(fields, stats.FieldDmgTeam) + } + if m.addud_he != nil { + fields = append(fields, stats.FieldUdHe) + } + if m.addud_flames != nil { + fields = append(fields, stats.FieldUdFlames) + } + if m.addud_flash != nil { + fields = append(fields, stats.FieldUdFlash) + } + if m.addud_decoy != nil { + fields = append(fields, stats.FieldUdDecoy) + } + if m.addud_smoke != nil { + fields = append(fields, stats.FieldUdSmoke) + } + if m.addhit_group_head != nil { + fields = append(fields, stats.FieldHitGroupHead) + } + if m.addhit_group_chest != nil { + fields = append(fields, stats.FieldHitGroupChest) + } + if m.addhit_group_stomach != nil { + fields = append(fields, stats.FieldHitGroupStomach) + } + if m.addhit_group_left_arm != nil { + fields = append(fields, stats.FieldHitGroupLeftArm) + } + if m.addhit_group_right_arm != nil { + fields = append(fields, stats.FieldHitGroupRightArm) + } + if m.addhit_group_left_leg != nil { + fields = append(fields, stats.FieldHitGroupLeftLeg) + } + if m.addhit_group_right_leg != nil { + fields = append(fields, stats.FieldHitGroupRightLeg) + } + if m.addhit_group_gear != nil { + fields = append(fields, stats.FieldHitGroupGear) + } + if m.addkast != nil { + fields = append(fields, stats.FieldKast) + } + if m.addflash_duration_self != nil { + fields = append(fields, stats.FieldFlashDurationSelf) + } + if m.addflash_duration_team != nil { + fields = append(fields, stats.FieldFlashDurationTeam) + } + if m.addflash_duration_enemy != nil { + fields = append(fields, stats.FieldFlashDurationEnemy) + } + if m.addflash_total_self != nil { + fields = append(fields, stats.FieldFlashTotalSelf) + } + if m.addflash_total_team != nil { + fields = append(fields, stats.FieldFlashTotalTeam) + } + if m.addflash_total_enemy != nil { + fields = append(fields, stats.FieldFlashTotalEnemy) + } return fields } @@ -3526,6 +6105,62 @@ func (m *StatsMutation) AddedField(name string) (ent.Value, bool) { return m.AddedMvp() case stats.FieldScore: return m.AddedScore() + case stats.FieldRankNew: + return m.AddedRankNew() + case stats.FieldRankOld: + return m.AddedRankOld() + case stats.FieldMk2: + return m.AddedMk2() + case stats.FieldMk3: + return m.AddedMk3() + case stats.FieldMk4: + return m.AddedMk4() + case stats.FieldMk5: + return m.AddedMk5() + case stats.FieldDmgEnemy: + return m.AddedDmgEnemy() + case stats.FieldDmgTeam: + return m.AddedDmgTeam() + case stats.FieldUdHe: + return m.AddedUdHe() + case stats.FieldUdFlames: + return m.AddedUdFlames() + case stats.FieldUdFlash: + return m.AddedUdFlash() + case stats.FieldUdDecoy: + return m.AddedUdDecoy() + case stats.FieldUdSmoke: + return m.AddedUdSmoke() + case stats.FieldHitGroupHead: + return m.AddedHitGroupHead() + case stats.FieldHitGroupChest: + return m.AddedHitGroupChest() + case stats.FieldHitGroupStomach: + return m.AddedHitGroupStomach() + case stats.FieldHitGroupLeftArm: + return m.AddedHitGroupLeftArm() + case stats.FieldHitGroupRightArm: + return m.AddedHitGroupRightArm() + case stats.FieldHitGroupLeftLeg: + return m.AddedHitGroupLeftLeg() + case stats.FieldHitGroupRightLeg: + return m.AddedHitGroupRightLeg() + case stats.FieldHitGroupGear: + return m.AddedHitGroupGear() + case stats.FieldKast: + return m.AddedKast() + case stats.FieldFlashDurationSelf: + return m.AddedFlashDurationSelf() + case stats.FieldFlashDurationTeam: + return m.AddedFlashDurationTeam() + case stats.FieldFlashDurationEnemy: + return m.AddedFlashDurationEnemy() + case stats.FieldFlashTotalSelf: + return m.AddedFlashTotalSelf() + case stats.FieldFlashTotalTeam: + return m.AddedFlashTotalTeam() + case stats.FieldFlashTotalEnemy: + return m.AddedFlashTotalEnemy() } return nil, false } @@ -3571,7 +6206,7 @@ func (m *StatsMutation) AddField(name string, value ent.Value) error { m.AddHeadshot(v) return nil case stats.FieldMvp: - v, ok := value.(int) + v, ok := value.(uint) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } @@ -3584,6 +6219,202 @@ func (m *StatsMutation) AddField(name string, value ent.Value) error { } m.AddScore(v) return nil + case stats.FieldRankNew: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddRankNew(v) + return nil + case stats.FieldRankOld: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddRankOld(v) + return nil + case stats.FieldMk2: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddMk2(v) + return nil + case stats.FieldMk3: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddMk3(v) + return nil + case stats.FieldMk4: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddMk4(v) + return nil + case stats.FieldMk5: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddMk5(v) + return nil + case stats.FieldDmgEnemy: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddDmgEnemy(v) + return nil + case stats.FieldDmgTeam: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddDmgTeam(v) + return nil + case stats.FieldUdHe: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddUdHe(v) + return nil + case stats.FieldUdFlames: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddUdFlames(v) + return nil + case stats.FieldUdFlash: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddUdFlash(v) + return nil + case stats.FieldUdDecoy: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddUdDecoy(v) + return nil + case stats.FieldUdSmoke: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddUdSmoke(v) + return nil + case stats.FieldHitGroupHead: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddHitGroupHead(v) + return nil + case stats.FieldHitGroupChest: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddHitGroupChest(v) + return nil + case stats.FieldHitGroupStomach: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddHitGroupStomach(v) + return nil + case stats.FieldHitGroupLeftArm: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddHitGroupLeftArm(v) + return nil + case stats.FieldHitGroupRightArm: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddHitGroupRightArm(v) + return nil + case stats.FieldHitGroupLeftLeg: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddHitGroupLeftLeg(v) + return nil + case stats.FieldHitGroupRightLeg: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddHitGroupRightLeg(v) + return nil + case stats.FieldHitGroupGear: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddHitGroupGear(v) + return nil + case stats.FieldKast: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddKast(v) + return nil + case stats.FieldFlashDurationSelf: + v, ok := value.(float32) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddFlashDurationSelf(v) + return nil + case stats.FieldFlashDurationTeam: + v, ok := value.(float32) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddFlashDurationTeam(v) + return nil + case stats.FieldFlashDurationEnemy: + v, ok := value.(float32) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddFlashDurationEnemy(v) + return nil + case stats.FieldFlashTotalSelf: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddFlashTotalSelf(v) + return nil + case stats.FieldFlashTotalTeam: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddFlashTotalTeam(v) + return nil + case stats.FieldFlashTotalEnemy: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddFlashTotalEnemy(v) + return nil } return fmt.Errorf("unknown Stats numeric field %s", name) } @@ -3592,8 +6423,101 @@ func (m *StatsMutation) AddField(name string, value ent.Value) error { // mutation. func (m *StatsMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(stats.FieldExtended) { - fields = append(fields, stats.FieldExtended) + if m.FieldCleared(stats.FieldRankNew) { + fields = append(fields, stats.FieldRankNew) + } + if m.FieldCleared(stats.FieldRankOld) { + fields = append(fields, stats.FieldRankOld) + } + if m.FieldCleared(stats.FieldMk2) { + fields = append(fields, stats.FieldMk2) + } + if m.FieldCleared(stats.FieldMk3) { + fields = append(fields, stats.FieldMk3) + } + if m.FieldCleared(stats.FieldMk4) { + fields = append(fields, stats.FieldMk4) + } + if m.FieldCleared(stats.FieldMk5) { + fields = append(fields, stats.FieldMk5) + } + if m.FieldCleared(stats.FieldDmgEnemy) { + fields = append(fields, stats.FieldDmgEnemy) + } + if m.FieldCleared(stats.FieldDmgTeam) { + fields = append(fields, stats.FieldDmgTeam) + } + if m.FieldCleared(stats.FieldUdHe) { + fields = append(fields, stats.FieldUdHe) + } + if m.FieldCleared(stats.FieldUdFlames) { + fields = append(fields, stats.FieldUdFlames) + } + if m.FieldCleared(stats.FieldUdFlash) { + fields = append(fields, stats.FieldUdFlash) + } + if m.FieldCleared(stats.FieldUdDecoy) { + fields = append(fields, stats.FieldUdDecoy) + } + if m.FieldCleared(stats.FieldUdSmoke) { + fields = append(fields, stats.FieldUdSmoke) + } + if m.FieldCleared(stats.FieldHitGroupHead) { + fields = append(fields, stats.FieldHitGroupHead) + } + if m.FieldCleared(stats.FieldHitGroupChest) { + fields = append(fields, stats.FieldHitGroupChest) + } + if m.FieldCleared(stats.FieldHitGroupStomach) { + fields = append(fields, stats.FieldHitGroupStomach) + } + if m.FieldCleared(stats.FieldHitGroupLeftArm) { + fields = append(fields, stats.FieldHitGroupLeftArm) + } + if m.FieldCleared(stats.FieldHitGroupRightArm) { + fields = append(fields, stats.FieldHitGroupRightArm) + } + if m.FieldCleared(stats.FieldHitGroupLeftLeg) { + fields = append(fields, stats.FieldHitGroupLeftLeg) + } + if m.FieldCleared(stats.FieldHitGroupRightLeg) { + fields = append(fields, stats.FieldHitGroupRightLeg) + } + if m.FieldCleared(stats.FieldHitGroupGear) { + fields = append(fields, stats.FieldHitGroupGear) + } + if m.FieldCleared(stats.FieldCrosshair) { + fields = append(fields, stats.FieldCrosshair) + } + if m.FieldCleared(stats.FieldColor) { + fields = append(fields, stats.FieldColor) + } + if m.FieldCleared(stats.FieldKast) { + fields = append(fields, stats.FieldKast) + } + if m.FieldCleared(stats.FieldFlashDurationSelf) { + fields = append(fields, stats.FieldFlashDurationSelf) + } + if m.FieldCleared(stats.FieldFlashDurationTeam) { + fields = append(fields, stats.FieldFlashDurationTeam) + } + if m.FieldCleared(stats.FieldFlashDurationEnemy) { + fields = append(fields, stats.FieldFlashDurationEnemy) + } + if m.FieldCleared(stats.FieldFlashTotalSelf) { + fields = append(fields, stats.FieldFlashTotalSelf) + } + if m.FieldCleared(stats.FieldFlashTotalTeam) { + fields = append(fields, stats.FieldFlashTotalTeam) + } + if m.FieldCleared(stats.FieldFlashTotalEnemy) { + fields = append(fields, stats.FieldFlashTotalEnemy) + } + if m.FieldCleared(stats.FieldMatchStats) { + fields = append(fields, stats.FieldMatchStats) + } + if m.FieldCleared(stats.FieldPlayerStats) { + fields = append(fields, stats.FieldPlayerStats) } return fields } @@ -3609,8 +6533,101 @@ func (m *StatsMutation) FieldCleared(name string) bool { // error if the field is not defined in the schema. func (m *StatsMutation) ClearField(name string) error { switch name { - case stats.FieldExtended: - m.ClearExtended() + case stats.FieldRankNew: + m.ClearRankNew() + return nil + case stats.FieldRankOld: + m.ClearRankOld() + return nil + case stats.FieldMk2: + m.ClearMk2() + return nil + case stats.FieldMk3: + m.ClearMk3() + return nil + case stats.FieldMk4: + m.ClearMk4() + return nil + case stats.FieldMk5: + m.ClearMk5() + return nil + case stats.FieldDmgEnemy: + m.ClearDmgEnemy() + return nil + case stats.FieldDmgTeam: + m.ClearDmgTeam() + return nil + case stats.FieldUdHe: + m.ClearUdHe() + return nil + case stats.FieldUdFlames: + m.ClearUdFlames() + return nil + case stats.FieldUdFlash: + m.ClearUdFlash() + return nil + case stats.FieldUdDecoy: + m.ClearUdDecoy() + return nil + case stats.FieldUdSmoke: + m.ClearUdSmoke() + return nil + case stats.FieldHitGroupHead: + m.ClearHitGroupHead() + return nil + case stats.FieldHitGroupChest: + m.ClearHitGroupChest() + return nil + case stats.FieldHitGroupStomach: + m.ClearHitGroupStomach() + return nil + case stats.FieldHitGroupLeftArm: + m.ClearHitGroupLeftArm() + return nil + case stats.FieldHitGroupRightArm: + m.ClearHitGroupRightArm() + return nil + case stats.FieldHitGroupLeftLeg: + m.ClearHitGroupLeftLeg() + return nil + case stats.FieldHitGroupRightLeg: + m.ClearHitGroupRightLeg() + return nil + case stats.FieldHitGroupGear: + m.ClearHitGroupGear() + return nil + case stats.FieldCrosshair: + m.ClearCrosshair() + return nil + case stats.FieldColor: + m.ClearColor() + return nil + case stats.FieldKast: + m.ClearKast() + return nil + case stats.FieldFlashDurationSelf: + m.ClearFlashDurationSelf() + return nil + case stats.FieldFlashDurationTeam: + m.ClearFlashDurationTeam() + return nil + case stats.FieldFlashDurationEnemy: + m.ClearFlashDurationEnemy() + return nil + case stats.FieldFlashTotalSelf: + m.ClearFlashTotalSelf() + return nil + case stats.FieldFlashTotalTeam: + m.ClearFlashTotalTeam() + return nil + case stats.FieldFlashTotalEnemy: + m.ClearFlashTotalEnemy() + return nil + case stats.FieldMatchStats: + m.ClearMatchStats() + return nil + case stats.FieldPlayerStats: + m.ClearPlayerStats() return nil } return fmt.Errorf("unknown Stats nullable field %s", name) @@ -3641,8 +6658,101 @@ func (m *StatsMutation) ResetField(name string) error { case stats.FieldScore: m.ResetScore() return nil - case stats.FieldExtended: - m.ResetExtended() + case stats.FieldRankNew: + m.ResetRankNew() + return nil + case stats.FieldRankOld: + m.ResetRankOld() + return nil + case stats.FieldMk2: + m.ResetMk2() + return nil + case stats.FieldMk3: + m.ResetMk3() + return nil + case stats.FieldMk4: + m.ResetMk4() + return nil + case stats.FieldMk5: + m.ResetMk5() + return nil + case stats.FieldDmgEnemy: + m.ResetDmgEnemy() + return nil + case stats.FieldDmgTeam: + m.ResetDmgTeam() + return nil + case stats.FieldUdHe: + m.ResetUdHe() + return nil + case stats.FieldUdFlames: + m.ResetUdFlames() + return nil + case stats.FieldUdFlash: + m.ResetUdFlash() + return nil + case stats.FieldUdDecoy: + m.ResetUdDecoy() + return nil + case stats.FieldUdSmoke: + m.ResetUdSmoke() + return nil + case stats.FieldHitGroupHead: + m.ResetHitGroupHead() + return nil + case stats.FieldHitGroupChest: + m.ResetHitGroupChest() + return nil + case stats.FieldHitGroupStomach: + m.ResetHitGroupStomach() + return nil + case stats.FieldHitGroupLeftArm: + m.ResetHitGroupLeftArm() + return nil + case stats.FieldHitGroupRightArm: + m.ResetHitGroupRightArm() + return nil + case stats.FieldHitGroupLeftLeg: + m.ResetHitGroupLeftLeg() + return nil + case stats.FieldHitGroupRightLeg: + m.ResetHitGroupRightLeg() + return nil + case stats.FieldHitGroupGear: + m.ResetHitGroupGear() + return nil + case stats.FieldCrosshair: + m.ResetCrosshair() + return nil + case stats.FieldColor: + m.ResetColor() + return nil + case stats.FieldKast: + m.ResetKast() + return nil + case stats.FieldFlashDurationSelf: + m.ResetFlashDurationSelf() + return nil + case stats.FieldFlashDurationTeam: + m.ResetFlashDurationTeam() + return nil + case stats.FieldFlashDurationEnemy: + m.ResetFlashDurationEnemy() + return nil + case stats.FieldFlashTotalSelf: + m.ResetFlashTotalSelf() + return nil + case stats.FieldFlashTotalTeam: + m.ResetFlashTotalTeam() + return nil + case stats.FieldFlashTotalEnemy: + m.ResetFlashTotalEnemy() + return nil + case stats.FieldMatchStats: + m.ResetMatchStats() + return nil + case stats.FieldPlayerStats: + m.ResetPlayerStats() return nil } return fmt.Errorf("unknown Stats field %s", name) @@ -3650,13 +6760,16 @@ func (m *StatsMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *StatsMutation) AddedEdges() []string { - edges := make([]string, 0, 2) + edges := make([]string, 0, 3) if m.matches != nil { edges = append(edges, stats.EdgeMatches) } if m.players != nil { edges = append(edges, stats.EdgePlayers) } + if m.weapon_stats != nil { + edges = append(edges, stats.EdgeWeaponStats) + } return edges } @@ -3672,13 +6785,22 @@ func (m *StatsMutation) AddedIDs(name string) []ent.Value { if id := m.players; id != nil { return []ent.Value{*id} } + case stats.EdgeWeaponStats: + ids := make([]ent.Value, 0, len(m.weapon_stats)) + for id := range m.weapon_stats { + ids = append(ids, id) + } + return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *StatsMutation) RemovedEdges() []string { - edges := make([]string, 0, 2) + edges := make([]string, 0, 3) + if m.removedweapon_stats != nil { + edges = append(edges, stats.EdgeWeaponStats) + } return edges } @@ -3686,19 +6808,28 @@ func (m *StatsMutation) RemovedEdges() []string { // the given name in this mutation. func (m *StatsMutation) RemovedIDs(name string) []ent.Value { switch name { + case stats.EdgeWeaponStats: + ids := make([]ent.Value, 0, len(m.removedweapon_stats)) + for id := range m.removedweapon_stats { + ids = append(ids, id) + } + return ids } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. func (m *StatsMutation) ClearedEdges() []string { - edges := make([]string, 0, 2) + edges := make([]string, 0, 3) if m.clearedmatches { edges = append(edges, stats.EdgeMatches) } if m.clearedplayers { edges = append(edges, stats.EdgePlayers) } + if m.clearedweapon_stats { + edges = append(edges, stats.EdgeWeaponStats) + } return edges } @@ -3710,6 +6841,8 @@ func (m *StatsMutation) EdgeCleared(name string) bool { return m.clearedmatches case stats.EdgePlayers: return m.clearedplayers + case stats.EdgeWeaponStats: + return m.clearedweapon_stats } return false } @@ -3738,6 +6871,667 @@ func (m *StatsMutation) ResetEdge(name string) error { case stats.EdgePlayers: m.ResetPlayers() return nil + case stats.EdgeWeaponStats: + m.ResetWeaponStats() + return nil } return fmt.Errorf("unknown Stats edge %s", name) } + +// WeaponStatsMutation represents an operation that mutates the WeaponStats nodes in the graph. +type WeaponStatsMutation struct { + config + op Op + typ string + id *int + victim *uint64 + addvictim *uint64 + dmg *uint + adddmg *uint + eq_type *int + addeq_type *int + hit_group *int + addhit_group *int + clearedFields map[string]struct{} + stat *int + clearedstat bool + done bool + oldValue func(context.Context) (*WeaponStats, error) + predicates []predicate.WeaponStats +} + +var _ ent.Mutation = (*WeaponStatsMutation)(nil) + +// weaponstatsOption allows management of the mutation configuration using functional options. +type weaponstatsOption func(*WeaponStatsMutation) + +// newWeaponStatsMutation creates new mutation for the WeaponStats entity. +func newWeaponStatsMutation(c config, op Op, opts ...weaponstatsOption) *WeaponStatsMutation { + m := &WeaponStatsMutation{ + config: c, + op: op, + typ: TypeWeaponStats, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withWeaponStatsID sets the ID field of the mutation. +func withWeaponStatsID(id int) weaponstatsOption { + return func(m *WeaponStatsMutation) { + var ( + err error + once sync.Once + value *WeaponStats + ) + m.oldValue = func(ctx context.Context) (*WeaponStats, error) { + once.Do(func() { + if m.done { + err = fmt.Errorf("querying old values post mutation is not allowed") + } else { + value, err = m.Client().WeaponStats.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withWeaponStats sets the old WeaponStats of the mutation. +func withWeaponStats(node *WeaponStats) weaponstatsOption { + return func(m *WeaponStatsMutation) { + m.oldValue = func(context.Context) (*WeaponStats, 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 WeaponStatsMutation) 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 WeaponStatsMutation) 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 *WeaponStatsMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// SetVictim sets the "victim" field. +func (m *WeaponStatsMutation) SetVictim(u uint64) { + m.victim = &u + m.addvictim = nil +} + +// Victim returns the value of the "victim" field in the mutation. +func (m *WeaponStatsMutation) Victim() (r uint64, exists bool) { + v := m.victim + if v == nil { + return + } + return *v, true +} + +// OldVictim returns the old "victim" field's value of the WeaponStats entity. +// If the WeaponStats 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 *WeaponStatsMutation) OldVictim(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldVictim is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldVictim requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldVictim: %w", err) + } + return oldValue.Victim, nil +} + +// AddVictim adds u to the "victim" field. +func (m *WeaponStatsMutation) AddVictim(u uint64) { + if m.addvictim != nil { + *m.addvictim += u + } else { + m.addvictim = &u + } +} + +// AddedVictim returns the value that was added to the "victim" field in this mutation. +func (m *WeaponStatsMutation) AddedVictim() (r uint64, exists bool) { + v := m.addvictim + if v == nil { + return + } + return *v, true +} + +// ResetVictim resets all changes to the "victim" field. +func (m *WeaponStatsMutation) ResetVictim() { + m.victim = nil + m.addvictim = nil +} + +// SetDmg sets the "dmg" field. +func (m *WeaponStatsMutation) SetDmg(u uint) { + m.dmg = &u + m.adddmg = nil +} + +// Dmg returns the value of the "dmg" field in the mutation. +func (m *WeaponStatsMutation) Dmg() (r uint, exists bool) { + v := m.dmg + if v == nil { + return + } + return *v, true +} + +// OldDmg returns the old "dmg" field's value of the WeaponStats entity. +// If the WeaponStats 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 *WeaponStatsMutation) OldDmg(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldDmg is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldDmg requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDmg: %w", err) + } + return oldValue.Dmg, nil +} + +// AddDmg adds u to the "dmg" field. +func (m *WeaponStatsMutation) AddDmg(u uint) { + if m.adddmg != nil { + *m.adddmg += u + } else { + m.adddmg = &u + } +} + +// AddedDmg returns the value that was added to the "dmg" field in this mutation. +func (m *WeaponStatsMutation) AddedDmg() (r uint, exists bool) { + v := m.adddmg + if v == nil { + return + } + return *v, true +} + +// ResetDmg resets all changes to the "dmg" field. +func (m *WeaponStatsMutation) ResetDmg() { + m.dmg = nil + m.adddmg = nil +} + +// SetEqType sets the "eq_type" field. +func (m *WeaponStatsMutation) SetEqType(i int) { + m.eq_type = &i + m.addeq_type = nil +} + +// EqType returns the value of the "eq_type" field in the mutation. +func (m *WeaponStatsMutation) EqType() (r int, exists bool) { + v := m.eq_type + if v == nil { + return + } + return *v, true +} + +// OldEqType returns the old "eq_type" field's value of the WeaponStats entity. +// If the WeaponStats 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 *WeaponStatsMutation) OldEqType(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldEqType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldEqType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldEqType: %w", err) + } + return oldValue.EqType, nil +} + +// AddEqType adds i to the "eq_type" field. +func (m *WeaponStatsMutation) AddEqType(i int) { + if m.addeq_type != nil { + *m.addeq_type += i + } else { + m.addeq_type = &i + } +} + +// AddedEqType returns the value that was added to the "eq_type" field in this mutation. +func (m *WeaponStatsMutation) AddedEqType() (r int, exists bool) { + v := m.addeq_type + if v == nil { + return + } + return *v, true +} + +// ResetEqType resets all changes to the "eq_type" field. +func (m *WeaponStatsMutation) ResetEqType() { + m.eq_type = nil + m.addeq_type = nil +} + +// SetHitGroup sets the "hit_group" field. +func (m *WeaponStatsMutation) SetHitGroup(i int) { + m.hit_group = &i + m.addhit_group = nil +} + +// HitGroup returns the value of the "hit_group" field in the mutation. +func (m *WeaponStatsMutation) HitGroup() (r int, exists bool) { + v := m.hit_group + if v == nil { + return + } + return *v, true +} + +// OldHitGroup returns the old "hit_group" field's value of the WeaponStats entity. +// If the WeaponStats 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 *WeaponStatsMutation) OldHitGroup(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldHitGroup is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldHitGroup requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHitGroup: %w", err) + } + return oldValue.HitGroup, nil +} + +// AddHitGroup adds i to the "hit_group" field. +func (m *WeaponStatsMutation) AddHitGroup(i int) { + if m.addhit_group != nil { + *m.addhit_group += i + } else { + m.addhit_group = &i + } +} + +// AddedHitGroup returns the value that was added to the "hit_group" field in this mutation. +func (m *WeaponStatsMutation) AddedHitGroup() (r int, exists bool) { + v := m.addhit_group + if v == nil { + return + } + return *v, true +} + +// ResetHitGroup resets all changes to the "hit_group" field. +func (m *WeaponStatsMutation) ResetHitGroup() { + m.hit_group = nil + m.addhit_group = nil +} + +// SetStatID sets the "stat" edge to the Stats entity by id. +func (m *WeaponStatsMutation) SetStatID(id int) { + m.stat = &id +} + +// ClearStat clears the "stat" edge to the Stats entity. +func (m *WeaponStatsMutation) ClearStat() { + m.clearedstat = true +} + +// StatCleared reports if the "stat" edge to the Stats entity was cleared. +func (m *WeaponStatsMutation) StatCleared() bool { + return m.clearedstat +} + +// StatID returns the "stat" edge ID in the mutation. +func (m *WeaponStatsMutation) 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 *WeaponStatsMutation) StatIDs() (ids []int) { + if id := m.stat; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetStat resets all changes to the "stat" edge. +func (m *WeaponStatsMutation) ResetStat() { + m.stat = nil + m.clearedstat = false +} + +// Where appends a list predicates to the WeaponStatsMutation builder. +func (m *WeaponStatsMutation) Where(ps ...predicate.WeaponStats) { + m.predicates = append(m.predicates, ps...) +} + +// Op returns the operation name. +func (m *WeaponStatsMutation) Op() Op { + return m.op +} + +// Type returns the node type of this mutation (WeaponStats). +func (m *WeaponStatsMutation) 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 *WeaponStatsMutation) Fields() []string { + fields := make([]string, 0, 4) + if m.victim != nil { + fields = append(fields, weaponstats.FieldVictim) + } + if m.dmg != nil { + fields = append(fields, weaponstats.FieldDmg) + } + if m.eq_type != nil { + fields = append(fields, weaponstats.FieldEqType) + } + if m.hit_group != nil { + fields = append(fields, weaponstats.FieldHitGroup) + } + 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 *WeaponStatsMutation) Field(name string) (ent.Value, bool) { + switch name { + case weaponstats.FieldVictim: + return m.Victim() + case weaponstats.FieldDmg: + return m.Dmg() + case weaponstats.FieldEqType: + return m.EqType() + case weaponstats.FieldHitGroup: + return m.HitGroup() + } + 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 *WeaponStatsMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case weaponstats.FieldVictim: + return m.OldVictim(ctx) + case weaponstats.FieldDmg: + return m.OldDmg(ctx) + case weaponstats.FieldEqType: + return m.OldEqType(ctx) + case weaponstats.FieldHitGroup: + return m.OldHitGroup(ctx) + } + return nil, fmt.Errorf("unknown WeaponStats 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 *WeaponStatsMutation) SetField(name string, value ent.Value) error { + switch name { + case weaponstats.FieldVictim: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVictim(v) + return nil + case weaponstats.FieldDmg: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDmg(v) + return nil + case weaponstats.FieldEqType: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetEqType(v) + return nil + case weaponstats.FieldHitGroup: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHitGroup(v) + return nil + } + return fmt.Errorf("unknown WeaponStats field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *WeaponStatsMutation) AddedFields() []string { + var fields []string + if m.addvictim != nil { + fields = append(fields, weaponstats.FieldVictim) + } + if m.adddmg != nil { + fields = append(fields, weaponstats.FieldDmg) + } + if m.addeq_type != nil { + fields = append(fields, weaponstats.FieldEqType) + } + if m.addhit_group != nil { + fields = append(fields, weaponstats.FieldHitGroup) + } + 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 *WeaponStatsMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case weaponstats.FieldVictim: + return m.AddedVictim() + case weaponstats.FieldDmg: + return m.AddedDmg() + case weaponstats.FieldEqType: + return m.AddedEqType() + case weaponstats.FieldHitGroup: + return m.AddedHitGroup() + } + 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 *WeaponStatsMutation) AddField(name string, value ent.Value) error { + switch name { + case weaponstats.FieldVictim: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddVictim(v) + return nil + case weaponstats.FieldDmg: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddDmg(v) + return nil + case weaponstats.FieldEqType: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddEqType(v) + return nil + case weaponstats.FieldHitGroup: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddHitGroup(v) + return nil + } + return fmt.Errorf("unknown WeaponStats numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *WeaponStatsMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *WeaponStatsMutation) 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 *WeaponStatsMutation) ClearField(name string) error { + return fmt.Errorf("unknown WeaponStats 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 *WeaponStatsMutation) ResetField(name string) error { + switch name { + case weaponstats.FieldVictim: + m.ResetVictim() + return nil + case weaponstats.FieldDmg: + m.ResetDmg() + return nil + case weaponstats.FieldEqType: + m.ResetEqType() + return nil + case weaponstats.FieldHitGroup: + m.ResetHitGroup() + return nil + } + return fmt.Errorf("unknown WeaponStats field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *WeaponStatsMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.stat != nil { + edges = append(edges, weaponstats.EdgeStat) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *WeaponStatsMutation) AddedIDs(name string) []ent.Value { + switch name { + case weaponstats.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 *WeaponStatsMutation) 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 *WeaponStatsMutation) RemovedIDs(name string) []ent.Value { + switch name { + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *WeaponStatsMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.clearedstat { + edges = append(edges, weaponstats.EdgeStat) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *WeaponStatsMutation) EdgeCleared(name string) bool { + switch name { + case weaponstats.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 *WeaponStatsMutation) ClearEdge(name string) error { + switch name { + case weaponstats.EdgeStat: + m.ClearStat() + return nil + } + return fmt.Errorf("unknown WeaponStats 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 *WeaponStatsMutation) ResetEdge(name string) error { + switch name { + case weaponstats.EdgeStat: + m.ResetStat() + return nil + } + return fmt.Errorf("unknown WeaponStats edge %s", name) +} diff --git a/ent/player.go b/ent/player.go index c5fa84e..6fd9e90 100644 --- a/ent/player.go +++ b/ent/player.go @@ -36,6 +36,8 @@ type Player struct { SharecodeUpdated time.Time `json:"-"` // AuthCode holds the value of the "auth_code" field. AuthCode string `json:"-"` + // ProfileCreated holds the value of the "profile_created" field. + ProfileCreated time.Time `json:"profile_created,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the PlayerQuery when eager-loading is set. Edges PlayerEdges `json:"edges"` @@ -81,7 +83,7 @@ func (*Player) scanValues(columns []string) ([]interface{}, error) { values[i] = new(sql.NullInt64) case player.FieldName, player.FieldAvatarURL, player.FieldVanityURL, player.FieldVanityURLReal, player.FieldAuthCode: values[i] = new(sql.NullString) - case player.FieldVacDate, player.FieldSteamUpdated, player.FieldSharecodeUpdated: + case player.FieldVacDate, player.FieldSteamUpdated, player.FieldSharecodeUpdated, player.FieldProfileCreated: values[i] = new(sql.NullTime) default: return nil, fmt.Errorf("unexpected column %q for type Player", columns[i]) @@ -164,6 +166,12 @@ func (pl *Player) assignValues(columns []string, values []interface{}) error { } else if value.Valid { pl.AuthCode = value.String } + case player.FieldProfileCreated: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field profile_created", values[i]) + } else if value.Valid { + pl.ProfileCreated = value.Time + } } } return nil @@ -221,6 +229,8 @@ func (pl *Player) String() string { builder.WriteString(", sharecode_updated=") builder.WriteString(pl.SharecodeUpdated.Format(time.ANSIC)) builder.WriteString(", auth_code=") + builder.WriteString(", profile_created=") + builder.WriteString(pl.ProfileCreated.Format(time.ANSIC)) builder.WriteByte(')') return builder.String() } diff --git a/ent/player/player.go b/ent/player/player.go index 0c2354a..a6f8336 100644 --- a/ent/player/player.go +++ b/ent/player/player.go @@ -31,6 +31,8 @@ const ( FieldSharecodeUpdated = "sharecode_updated" // FieldAuthCode holds the string denoting the auth_code field in the database. FieldAuthCode = "auth_code" + // FieldProfileCreated holds the string denoting the profile_created field in the database. + FieldProfileCreated = "profile_created" // EdgeStats holds the string denoting the stats edge name in mutations. EdgeStats = "stats" // EdgeMatches holds the string denoting the matches edge name in mutations. @@ -64,6 +66,7 @@ var Columns = []string{ FieldSteamUpdated, FieldSharecodeUpdated, FieldAuthCode, + FieldProfileCreated, } var ( diff --git a/ent/player/where.go b/ent/player/where.go index 57e33f7..45b59ed 100644 --- a/ent/player/where.go +++ b/ent/player/where.go @@ -163,6 +163,13 @@ func AuthCode(v string) predicate.Player { }) } +// ProfileCreated applies equality check predicate on the "profile_created" field. It's identical to ProfileCreatedEQ. +func ProfileCreated(v time.Time) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldProfileCreated), v)) + }) +} + // NameEQ applies the EQ predicate on the "name" field. func NameEQ(v string) predicate.Player { return predicate.Player(func(s *sql.Selector) { @@ -1148,6 +1155,96 @@ func AuthCodeContainsFold(v string) predicate.Player { }) } +// ProfileCreatedEQ applies the EQ predicate on the "profile_created" field. +func ProfileCreatedEQ(v time.Time) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldProfileCreated), v)) + }) +} + +// ProfileCreatedNEQ applies the NEQ predicate on the "profile_created" field. +func ProfileCreatedNEQ(v time.Time) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldProfileCreated), v)) + }) +} + +// ProfileCreatedIn applies the In predicate on the "profile_created" field. +func ProfileCreatedIn(vs ...time.Time) predicate.Player { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Player(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldProfileCreated), v...)) + }) +} + +// ProfileCreatedNotIn applies the NotIn predicate on the "profile_created" field. +func ProfileCreatedNotIn(vs ...time.Time) predicate.Player { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Player(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldProfileCreated), v...)) + }) +} + +// ProfileCreatedGT applies the GT predicate on the "profile_created" field. +func ProfileCreatedGT(v time.Time) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldProfileCreated), v)) + }) +} + +// ProfileCreatedGTE applies the GTE predicate on the "profile_created" field. +func ProfileCreatedGTE(v time.Time) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldProfileCreated), v)) + }) +} + +// ProfileCreatedLT applies the LT predicate on the "profile_created" field. +func ProfileCreatedLT(v time.Time) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldProfileCreated), v)) + }) +} + +// ProfileCreatedLTE applies the LTE predicate on the "profile_created" field. +func ProfileCreatedLTE(v time.Time) predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldProfileCreated), v)) + }) +} + +// ProfileCreatedIsNil applies the IsNil predicate on the "profile_created" field. +func ProfileCreatedIsNil() predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldProfileCreated))) + }) +} + +// ProfileCreatedNotNil applies the NotNil predicate on the "profile_created" field. +func ProfileCreatedNotNil() predicate.Player { + return predicate.Player(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldProfileCreated))) + }) +} + // HasStats applies the HasEdge predicate on the "stats" edge. func HasStats() predicate.Player { return predicate.Player(func(s *sql.Selector) { diff --git a/ent/player_create.go b/ent/player_create.go index 490aac5..0239bf8 100644 --- a/ent/player_create.go +++ b/ent/player_create.go @@ -162,6 +162,20 @@ func (pc *PlayerCreate) SetNillableAuthCode(s *string) *PlayerCreate { return pc } +// SetProfileCreated sets the "profile_created" field. +func (pc *PlayerCreate) SetProfileCreated(t time.Time) *PlayerCreate { + pc.mutation.SetProfileCreated(t) + return pc +} + +// SetNillableProfileCreated sets the "profile_created" field if the given value is not nil. +func (pc *PlayerCreate) SetNillableProfileCreated(t *time.Time) *PlayerCreate { + if t != nil { + pc.SetProfileCreated(*t) + } + return pc +} + // SetID sets the "id" field. func (pc *PlayerCreate) SetID(u uint64) *PlayerCreate { pc.mutation.SetID(u) @@ -400,6 +414,14 @@ func (pc *PlayerCreate) createSpec() (*Player, *sqlgraph.CreateSpec) { }) _node.AuthCode = value } + if value, ok := pc.mutation.ProfileCreated(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeTime, + Value: value, + Column: player.FieldProfileCreated, + }) + _node.ProfileCreated = value + } if nodes := pc.mutation.StatsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, diff --git a/ent/player_query.go b/ent/player_query.go index 92d8974..8a931ec 100644 --- a/ent/player_query.go +++ b/ent/player_query.go @@ -423,7 +423,6 @@ func (pq *PlayerQuery) sqlAll(ctx context.Context) ([]*Player, error) { nodeids[nodes[i].ID] = nodes[i] nodes[i].Edges.Stats = []*Stats{} } - query.withFKs = true query.Where(predicate.Stats(func(s *sql.Selector) { s.Where(sql.InValues(player.StatsColumn, fks...)) })) @@ -432,13 +431,10 @@ func (pq *PlayerQuery) sqlAll(ctx context.Context) ([]*Player, error) { return nil, err } for _, n := range neighbors { - fk := n.player_stats - if fk == nil { - return nil, fmt.Errorf(`foreign-key "player_stats" is nil for node %v`, n.ID) - } - node, ok := nodeids[*fk] + fk := n.PlayerStats + node, ok := nodeids[fk] if !ok { - return nil, fmt.Errorf(`unexpected foreign-key "player_stats" returned %v for node %v`, *fk, n.ID) + return nil, fmt.Errorf(`unexpected foreign-key "player_stats" returned %v for node %v`, fk, n.ID) } node.Edges.Stats = append(node.Edges.Stats, n) } diff --git a/ent/player_update.go b/ent/player_update.go index de39def..afa4597 100644 --- a/ent/player_update.go +++ b/ent/player_update.go @@ -224,6 +224,26 @@ func (pu *PlayerUpdate) ClearAuthCode() *PlayerUpdate { return pu } +// SetProfileCreated sets the "profile_created" field. +func (pu *PlayerUpdate) SetProfileCreated(t time.Time) *PlayerUpdate { + pu.mutation.SetProfileCreated(t) + return pu +} + +// SetNillableProfileCreated sets the "profile_created" field if the given value is not nil. +func (pu *PlayerUpdate) SetNillableProfileCreated(t *time.Time) *PlayerUpdate { + if t != nil { + pu.SetProfileCreated(*t) + } + return pu +} + +// ClearProfileCreated clears the value of the "profile_created" field. +func (pu *PlayerUpdate) ClearProfileCreated() *PlayerUpdate { + pu.mutation.ClearProfileCreated() + return pu +} + // AddStatIDs adds the "stats" edge to the Stats entity by IDs. func (pu *PlayerUpdate) AddStatIDs(ids ...int) *PlayerUpdate { pu.mutation.AddStatIDs(ids...) @@ -498,6 +518,19 @@ func (pu *PlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { Column: player.FieldAuthCode, }) } + if value, ok := pu.mutation.ProfileCreated(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeTime, + Value: value, + Column: player.FieldProfileCreated, + }) + } + if pu.mutation.ProfileCreatedCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeTime, + Column: player.FieldProfileCreated, + }) + } if pu.mutation.StatsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, @@ -820,6 +853,26 @@ func (puo *PlayerUpdateOne) ClearAuthCode() *PlayerUpdateOne { return puo } +// SetProfileCreated sets the "profile_created" field. +func (puo *PlayerUpdateOne) SetProfileCreated(t time.Time) *PlayerUpdateOne { + puo.mutation.SetProfileCreated(t) + return puo +} + +// SetNillableProfileCreated sets the "profile_created" field if the given value is not nil. +func (puo *PlayerUpdateOne) SetNillableProfileCreated(t *time.Time) *PlayerUpdateOne { + if t != nil { + puo.SetProfileCreated(*t) + } + return puo +} + +// ClearProfileCreated clears the value of the "profile_created" field. +func (puo *PlayerUpdateOne) ClearProfileCreated() *PlayerUpdateOne { + puo.mutation.ClearProfileCreated() + return puo +} + // AddStatIDs adds the "stats" edge to the Stats entity by IDs. func (puo *PlayerUpdateOne) AddStatIDs(ids ...int) *PlayerUpdateOne { puo.mutation.AddStatIDs(ids...) @@ -1118,6 +1171,19 @@ func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err err Column: player.FieldAuthCode, }) } + if value, ok := puo.mutation.ProfileCreated(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeTime, + Value: value, + Column: player.FieldProfileCreated, + }) + } + if puo.mutation.ProfileCreatedCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeTime, + Column: player.FieldProfileCreated, + }) + } if puo.mutation.StatsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, diff --git a/ent/predicate/predicate.go b/ent/predicate/predicate.go index 34f3942..c09b837 100644 --- a/ent/predicate/predicate.go +++ b/ent/predicate/predicate.go @@ -14,3 +14,6 @@ type Player func(*sql.Selector) // Stats is the predicate function for stats builders. type Stats func(*sql.Selector) + +// WeaponStats is the predicate function for weaponstats builders. +type WeaponStats func(*sql.Selector) diff --git a/ent/schema/player.go b/ent/schema/player.go index f256fdd..c5af4cf 100644 --- a/ent/schema/player.go +++ b/ent/schema/player.go @@ -28,6 +28,7 @@ func (Player) Fields() []ent.Field { }).StructTag(`json:"-"`), field.Time("sharecode_updated").Optional().StructTag(`json:"-"`), field.String("auth_code").Optional().Sensitive(), + field.Time("profile_created").Optional(), } } diff --git a/ent/schema/stats.go b/ent/schema/stats.go index 131ba2d..b8dfc04 100644 --- a/ent/schema/stats.go +++ b/ent/schema/stats.go @@ -19,63 +19,48 @@ func (Stats) Fields() []ent.Field { field.Int("deaths"), field.Int("assists"), field.Int("headshot"), - field.Int("mvp"), + field.Uint("mvp"), field.Int("score"), - field.JSON("extended", struct { - MultiKills struct { - Duo int `json:"duo,omitempty"` - Triple int `json:"triple,omitempty"` - Quad int `json:"quad,omitempty"` - Pent int `json:"pent,omitempty"` - } `json:"multi_kills,omitempty"` - Dmg struct { - Enemy int `json:"enemy,omitempty"` - Team int `json:"team,omitempty"` - UD struct { - HE int `json:"he,omitempty"` - Flames int `json:"flames,omitempty"` - Flash int `json:"flash,omitempty"` - Decoy int `json:"decoy,omitempty"` - Smoke int `json:"smoke,omitempty"` - } `json:"ud,omitempty"` - HitGroup struct { - Head int `json:"head,omitempty"` - Chest int `json:"chest,omitempty"` - Stomach int `json:"stomach,omitempty"` - LeftArm int `json:"left_arm,omitempty"` - RightArm int `json:"right_arm,omitempty"` - LeftLeg int `json:"left_leg,omitempty"` - RightLeg int `json:"right_leg,omitempty"` - Gear int `json:"gear,omitempty"` - } `json:"hit_group,omitempty"` - } `json:"dmg,omitempty"` - Crosshair string `json:"crosshair,omitempty"` - Color string `json:"color,omitempty"` - KAST int `json:"kast,omitempty"` - Rank struct { - Old int `json:"old,omitempty"` - New int `json:"new,omitempty"` - } `json:"rank,omitempty"` - Flash struct { - Duration struct { - Self float32 `json:"self,omitempty"` - Team float32 `json:"team,omitempty"` - Enemy float32 `json:"enemy,omitempty"` - } `json:"duration,omitempty"` - Total struct { - Team int `json:"team,omitempty"` - Enemy int `json:"enemy,omitempty"` - Self int `json:"self,omitempty"` - } `json:"total,omitempty"` - } `json:"flash,omitempty"` - }{}).Optional(), + field.Int("rank_new").Optional(), + field.Int("rank_old").Optional(), + field.Uint("mk_2").Optional(), + field.Uint("mk_3").Optional(), + field.Uint("mk_4").Optional(), + field.Uint("mk_5").Optional(), + field.Uint("dmg_enemy").Optional(), + field.Uint("dmg_team").Optional(), + field.Uint("ud_he").Optional(), + field.Uint("ud_flames").Optional(), + field.Uint("ud_flash").Optional(), + field.Uint("ud_decoy").Optional(), + field.Uint("ud_smoke").Optional(), + field.Uint("hit_group_head").Optional(), + field.Uint("hit_group_chest").Optional(), + field.Uint("hit_group_stomach").Optional(), + field.Uint("hit_group_left_arm").Optional(), + field.Uint("hit_group_right_arm").Optional(), + field.Uint("hit_group_left_leg").Optional(), + field.Uint("hit_group_right_leg").Optional(), + field.Uint("hit_group_gear").Optional(), + field.String("crosshair").Optional(), + field.Enum("color").Optional().Values("green", "yellow", "purple", "blue", "orange", "grey"), + field.Int("kast").Optional(), + field.Float32("flash_duration_self").Optional(), + field.Float32("flash_duration_team").Optional(), + field.Float32("flash_duration_enemy").Optional(), + field.Uint("flash_total_self").Optional(), + field.Uint("flash_total_team").Optional(), + field.Uint("flash_total_enemy").Optional(), + field.Uint64("match_stats").Optional(), + field.Uint64("player_stats").Optional(), } } // Edges of the Stats. func (Stats) Edges() []ent.Edge { return []ent.Edge{ - edge.From("matches", Match.Type).Ref("stats").Unique(), - edge.From("players", Player.Type).Ref("stats").Unique(), + edge.From("matches", Match.Type).Ref("stats").Unique().Field("match_stats"), + edge.From("players", Player.Type).Ref("stats").Unique().Field("player_stats"), + edge.To("weapon_stats", WeaponStats.Type), } } diff --git a/ent/schema/weaponstats.go b/ent/schema/weaponstats.go new file mode 100644 index 0000000..25dac93 --- /dev/null +++ b/ent/schema/weaponstats.go @@ -0,0 +1,29 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" +) + +// WeaponStats holds the schema definition for the WeaponStats entity. +type WeaponStats struct { + ent.Schema +} + +// Fields of the WeaponStats. +func (WeaponStats) Fields() []ent.Field { + return []ent.Field{ + field.Uint64("victim"), + field.Uint("dmg"), + field.Int("eq_type"), + field.Int("hit_group"), + } +} + +// Edges of the WeaponStats. +func (WeaponStats) Edges() []ent.Edge { + return []ent.Edge{ + edge.From("stat", Stats.Type).Ref("weapon_stats").Unique(), + } +} diff --git a/ent/stats.go b/ent/stats.go index f7589bc..1d9bd90 100644 --- a/ent/stats.go +++ b/ent/stats.go @@ -6,7 +6,6 @@ import ( "csgowtfd/ent/match" "csgowtfd/ent/player" "csgowtfd/ent/stats" - "encoding/json" "fmt" "strings" @@ -29,63 +28,76 @@ type Stats struct { // Headshot holds the value of the "headshot" field. Headshot int `json:"headshot,omitempty"` // Mvp holds the value of the "mvp" field. - Mvp int `json:"mvp,omitempty"` + Mvp uint `json:"mvp,omitempty"` // Score holds the value of the "score" field. Score int `json:"score,omitempty"` - // Extended holds the value of the "extended" field. - Extended struct { - MultiKills struct { - Duo int "json:\"duo,omitempty\"" - Triple int "json:\"triple,omitempty\"" - Quad int "json:\"quad,omitempty\"" - Pent int "json:\"pent,omitempty\"" - } "json:\"multi_kills,omitempty\"" - Dmg struct { - Enemy int "json:\"enemy,omitempty\"" - Team int "json:\"team,omitempty\"" - UD struct { - HE int "json:\"he,omitempty\"" - Flames int "json:\"flames,omitempty\"" - Flash int "json:\"flash,omitempty\"" - Decoy int "json:\"decoy,omitempty\"" - Smoke int "json:\"smoke,omitempty\"" - } "json:\"ud,omitempty\"" - HitGroup struct { - Head int "json:\"head,omitempty\"" - Chest int "json:\"chest,omitempty\"" - Stomach int "json:\"stomach,omitempty\"" - LeftArm int "json:\"left_arm,omitempty\"" - RightArm int "json:\"right_arm,omitempty\"" - LeftLeg int "json:\"left_leg,omitempty\"" - RightLeg int "json:\"right_leg,omitempty\"" - Gear int "json:\"gear,omitempty\"" - } "json:\"hit_group,omitempty\"" - } "json:\"dmg,omitempty\"" - Crosshair string "json:\"crosshair,omitempty\"" - Color string "json:\"color,omitempty\"" - KAST int "json:\"kast,omitempty\"" - Rank struct { - Old int "json:\"old,omitempty\"" - New int "json:\"new,omitempty\"" - } "json:\"rank,omitempty\"" - Flash struct { - Duration struct { - Self float32 "json:\"self,omitempty\"" - Team float32 "json:\"team,omitempty\"" - Enemy float32 "json:\"enemy,omitempty\"" - } "json:\"duration,omitempty\"" - Total struct { - Team int "json:\"team,omitempty\"" - Enemy int "json:\"enemy,omitempty\"" - Self int "json:\"self,omitempty\"" - } "json:\"total,omitempty\"" - } "json:\"flash,omitempty\"" - } `json:"extended,omitempty"` + // RankNew holds the value of the "rank_new" field. + RankNew int `json:"rank_new,omitempty"` + // RankOld holds the value of the "rank_old" field. + RankOld int `json:"rank_old,omitempty"` + // Mk2 holds the value of the "mk_2" field. + Mk2 uint `json:"mk_2,omitempty"` + // Mk3 holds the value of the "mk_3" field. + Mk3 uint `json:"mk_3,omitempty"` + // Mk4 holds the value of the "mk_4" field. + Mk4 uint `json:"mk_4,omitempty"` + // Mk5 holds the value of the "mk_5" field. + Mk5 uint `json:"mk_5,omitempty"` + // DmgEnemy holds the value of the "dmg_enemy" field. + DmgEnemy uint `json:"dmg_enemy,omitempty"` + // DmgTeam holds the value of the "dmg_team" field. + DmgTeam uint `json:"dmg_team,omitempty"` + // UdHe holds the value of the "ud_he" field. + UdHe uint `json:"ud_he,omitempty"` + // UdFlames holds the value of the "ud_flames" field. + UdFlames uint `json:"ud_flames,omitempty"` + // UdFlash holds the value of the "ud_flash" field. + UdFlash uint `json:"ud_flash,omitempty"` + // UdDecoy holds the value of the "ud_decoy" field. + UdDecoy uint `json:"ud_decoy,omitempty"` + // UdSmoke holds the value of the "ud_smoke" field. + UdSmoke uint `json:"ud_smoke,omitempty"` + // HitGroupHead holds the value of the "hit_group_head" field. + HitGroupHead uint `json:"hit_group_head,omitempty"` + // HitGroupChest holds the value of the "hit_group_chest" field. + HitGroupChest uint `json:"hit_group_chest,omitempty"` + // HitGroupStomach holds the value of the "hit_group_stomach" field. + HitGroupStomach uint `json:"hit_group_stomach,omitempty"` + // HitGroupLeftArm holds the value of the "hit_group_left_arm" field. + HitGroupLeftArm uint `json:"hit_group_left_arm,omitempty"` + // HitGroupRightArm holds the value of the "hit_group_right_arm" field. + HitGroupRightArm uint `json:"hit_group_right_arm,omitempty"` + // HitGroupLeftLeg holds the value of the "hit_group_left_leg" field. + HitGroupLeftLeg uint `json:"hit_group_left_leg,omitempty"` + // HitGroupRightLeg holds the value of the "hit_group_right_leg" field. + HitGroupRightLeg uint `json:"hit_group_right_leg,omitempty"` + // HitGroupGear holds the value of the "hit_group_gear" field. + HitGroupGear uint `json:"hit_group_gear,omitempty"` + // Crosshair holds the value of the "crosshair" field. + Crosshair string `json:"crosshair,omitempty"` + // Color holds the value of the "color" field. + Color stats.Color `json:"color,omitempty"` + // Kast holds the value of the "kast" field. + Kast int `json:"kast,omitempty"` + // FlashDurationSelf holds the value of the "flash_duration_self" field. + FlashDurationSelf float32 `json:"flash_duration_self,omitempty"` + // FlashDurationTeam holds the value of the "flash_duration_team" field. + FlashDurationTeam float32 `json:"flash_duration_team,omitempty"` + // FlashDurationEnemy holds the value of the "flash_duration_enemy" field. + FlashDurationEnemy float32 `json:"flash_duration_enemy,omitempty"` + // FlashTotalSelf holds the value of the "flash_total_self" field. + FlashTotalSelf uint `json:"flash_total_self,omitempty"` + // FlashTotalTeam holds the value of the "flash_total_team" field. + FlashTotalTeam uint `json:"flash_total_team,omitempty"` + // FlashTotalEnemy holds the value of the "flash_total_enemy" field. + FlashTotalEnemy uint `json:"flash_total_enemy,omitempty"` + // MatchStats holds the value of the "match_stats" field. + MatchStats uint64 `json:"match_stats,omitempty"` + // PlayerStats holds the value of the "player_stats" field. + PlayerStats uint64 `json:"player_stats,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the StatsQuery when eager-loading is set. - Edges StatsEdges `json:"edges"` - match_stats *uint64 - player_stats *uint64 + Edges StatsEdges `json:"edges"` } // StatsEdges holds the relations/edges for other nodes in the graph. @@ -94,9 +106,11 @@ type StatsEdges struct { Matches *Match `json:"matches,omitempty"` // Players holds the value of the players edge. Players *Player `json:"players,omitempty"` + // WeaponStats holds the value of the weapon_stats edge. + WeaponStats []*WeaponStats `json:"weapon_stats,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [2]bool + loadedTypes [3]bool } // MatchesOrErr returns the Matches value or an error if the edge @@ -127,19 +141,26 @@ func (e StatsEdges) PlayersOrErr() (*Player, error) { return nil, &NotLoadedError{edge: "players"} } +// WeaponStatsOrErr returns the WeaponStats value or an error if the edge +// was not loaded in eager-loading. +func (e StatsEdges) WeaponStatsOrErr() ([]*WeaponStats, error) { + if e.loadedTypes[2] { + return e.WeaponStats, nil + } + return nil, &NotLoadedError{edge: "weapon_stats"} +} + // scanValues returns the types for scanning values from sql.Rows. func (*Stats) scanValues(columns []string) ([]interface{}, error) { values := make([]interface{}, len(columns)) for i := range columns { switch columns[i] { - case stats.FieldExtended: - values[i] = new([]byte) - case stats.FieldID, stats.FieldTeamID, stats.FieldKills, stats.FieldDeaths, stats.FieldAssists, stats.FieldHeadshot, stats.FieldMvp, stats.FieldScore: - values[i] = new(sql.NullInt64) - case stats.ForeignKeys[0]: // match_stats - values[i] = new(sql.NullInt64) - case stats.ForeignKeys[1]: // player_stats + case stats.FieldFlashDurationSelf, stats.FieldFlashDurationTeam, stats.FieldFlashDurationEnemy: + values[i] = new(sql.NullFloat64) + case stats.FieldID, stats.FieldTeamID, stats.FieldKills, stats.FieldDeaths, stats.FieldAssists, stats.FieldHeadshot, stats.FieldMvp, stats.FieldScore, stats.FieldRankNew, stats.FieldRankOld, stats.FieldMk2, stats.FieldMk3, stats.FieldMk4, stats.FieldMk5, stats.FieldDmgEnemy, stats.FieldDmgTeam, stats.FieldUdHe, stats.FieldUdFlames, stats.FieldUdFlash, stats.FieldUdDecoy, stats.FieldUdSmoke, stats.FieldHitGroupHead, stats.FieldHitGroupChest, stats.FieldHitGroupStomach, stats.FieldHitGroupLeftArm, stats.FieldHitGroupRightArm, stats.FieldHitGroupLeftLeg, stats.FieldHitGroupRightLeg, stats.FieldHitGroupGear, stats.FieldKast, stats.FieldFlashTotalSelf, stats.FieldFlashTotalTeam, stats.FieldFlashTotalEnemy, stats.FieldMatchStats, stats.FieldPlayerStats: values[i] = new(sql.NullInt64) + case stats.FieldCrosshair, stats.FieldColor: + values[i] = new(sql.NullString) default: return nil, fmt.Errorf("unexpected column %q for type Stats", columns[i]) } @@ -195,7 +216,7 @@ func (s *Stats) assignValues(columns []string, values []interface{}) error { if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field mvp", values[i]) } else if value.Valid { - s.Mvp = int(value.Int64) + s.Mvp = uint(value.Int64) } case stats.FieldScore: if value, ok := values[i].(*sql.NullInt64); !ok { @@ -203,27 +224,197 @@ func (s *Stats) assignValues(columns []string, values []interface{}) error { } else if value.Valid { s.Score = int(value.Int64) } - case stats.FieldExtended: - if value, ok := values[i].(*[]byte); !ok { - return fmt.Errorf("unexpected type %T for field extended", values[i]) - } else if value != nil && len(*value) > 0 { - if err := json.Unmarshal(*value, &s.Extended); err != nil { - return fmt.Errorf("unmarshal field extended: %w", err) - } - } - case stats.ForeignKeys[0]: + case stats.FieldRankNew: if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for edge-field match_stats", value) + return fmt.Errorf("unexpected type %T for field rank_new", values[i]) } else if value.Valid { - s.match_stats = new(uint64) - *s.match_stats = uint64(value.Int64) + s.RankNew = int(value.Int64) } - case stats.ForeignKeys[1]: + case stats.FieldRankOld: if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for edge-field player_stats", value) + return fmt.Errorf("unexpected type %T for field rank_old", values[i]) } else if value.Valid { - s.player_stats = new(uint64) - *s.player_stats = uint64(value.Int64) + s.RankOld = int(value.Int64) + } + case stats.FieldMk2: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field mk_2", values[i]) + } else if value.Valid { + s.Mk2 = uint(value.Int64) + } + case stats.FieldMk3: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field mk_3", values[i]) + } else if value.Valid { + s.Mk3 = uint(value.Int64) + } + case stats.FieldMk4: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field mk_4", values[i]) + } else if value.Valid { + s.Mk4 = uint(value.Int64) + } + case stats.FieldMk5: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field mk_5", values[i]) + } else if value.Valid { + s.Mk5 = uint(value.Int64) + } + case stats.FieldDmgEnemy: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field dmg_enemy", values[i]) + } else if value.Valid { + s.DmgEnemy = uint(value.Int64) + } + case stats.FieldDmgTeam: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field dmg_team", values[i]) + } else if value.Valid { + s.DmgTeam = uint(value.Int64) + } + case stats.FieldUdHe: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field ud_he", values[i]) + } else if value.Valid { + s.UdHe = uint(value.Int64) + } + case stats.FieldUdFlames: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field ud_flames", values[i]) + } else if value.Valid { + s.UdFlames = uint(value.Int64) + } + case stats.FieldUdFlash: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field ud_flash", values[i]) + } else if value.Valid { + s.UdFlash = uint(value.Int64) + } + case stats.FieldUdDecoy: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field ud_decoy", values[i]) + } else if value.Valid { + s.UdDecoy = uint(value.Int64) + } + case stats.FieldUdSmoke: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field ud_smoke", values[i]) + } else if value.Valid { + s.UdSmoke = uint(value.Int64) + } + case stats.FieldHitGroupHead: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field hit_group_head", values[i]) + } else if value.Valid { + s.HitGroupHead = uint(value.Int64) + } + case stats.FieldHitGroupChest: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field hit_group_chest", values[i]) + } else if value.Valid { + s.HitGroupChest = uint(value.Int64) + } + case stats.FieldHitGroupStomach: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field hit_group_stomach", values[i]) + } else if value.Valid { + s.HitGroupStomach = uint(value.Int64) + } + case stats.FieldHitGroupLeftArm: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field hit_group_left_arm", values[i]) + } else if value.Valid { + s.HitGroupLeftArm = uint(value.Int64) + } + case stats.FieldHitGroupRightArm: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field hit_group_right_arm", values[i]) + } else if value.Valid { + s.HitGroupRightArm = uint(value.Int64) + } + case stats.FieldHitGroupLeftLeg: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field hit_group_left_leg", values[i]) + } else if value.Valid { + s.HitGroupLeftLeg = uint(value.Int64) + } + case stats.FieldHitGroupRightLeg: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field hit_group_right_leg", values[i]) + } else if value.Valid { + s.HitGroupRightLeg = uint(value.Int64) + } + case stats.FieldHitGroupGear: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field hit_group_gear", values[i]) + } else if value.Valid { + s.HitGroupGear = uint(value.Int64) + } + case stats.FieldCrosshair: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field crosshair", values[i]) + } else if value.Valid { + s.Crosshair = value.String + } + case stats.FieldColor: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field color", values[i]) + } else if value.Valid { + s.Color = stats.Color(value.String) + } + case stats.FieldKast: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field kast", values[i]) + } else if value.Valid { + s.Kast = int(value.Int64) + } + case stats.FieldFlashDurationSelf: + if value, ok := values[i].(*sql.NullFloat64); !ok { + return fmt.Errorf("unexpected type %T for field flash_duration_self", values[i]) + } else if value.Valid { + s.FlashDurationSelf = float32(value.Float64) + } + case stats.FieldFlashDurationTeam: + if value, ok := values[i].(*sql.NullFloat64); !ok { + return fmt.Errorf("unexpected type %T for field flash_duration_team", values[i]) + } else if value.Valid { + s.FlashDurationTeam = float32(value.Float64) + } + case stats.FieldFlashDurationEnemy: + if value, ok := values[i].(*sql.NullFloat64); !ok { + return fmt.Errorf("unexpected type %T for field flash_duration_enemy", values[i]) + } else if value.Valid { + s.FlashDurationEnemy = float32(value.Float64) + } + case stats.FieldFlashTotalSelf: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field flash_total_self", values[i]) + } else if value.Valid { + s.FlashTotalSelf = uint(value.Int64) + } + case stats.FieldFlashTotalTeam: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field flash_total_team", values[i]) + } else if value.Valid { + s.FlashTotalTeam = uint(value.Int64) + } + case stats.FieldFlashTotalEnemy: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field flash_total_enemy", values[i]) + } else if value.Valid { + s.FlashTotalEnemy = uint(value.Int64) + } + case stats.FieldMatchStats: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field match_stats", values[i]) + } else if value.Valid { + s.MatchStats = uint64(value.Int64) + } + case stats.FieldPlayerStats: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field player_stats", values[i]) + } else if value.Valid { + s.PlayerStats = uint64(value.Int64) } } } @@ -240,6 +431,11 @@ func (s *Stats) QueryPlayers() *PlayerQuery { return (&StatsClient{config: s.config}).QueryPlayers(s) } +// QueryWeaponStats queries the "weapon_stats" edge of the Stats entity. +func (s *Stats) QueryWeaponStats() *WeaponStatsQuery { + return (&StatsClient{config: s.config}).QueryWeaponStats(s) +} + // Update returns a builder for updating 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. @@ -277,8 +473,70 @@ func (s *Stats) String() string { builder.WriteString(fmt.Sprintf("%v", s.Mvp)) builder.WriteString(", score=") builder.WriteString(fmt.Sprintf("%v", s.Score)) - builder.WriteString(", extended=") - builder.WriteString(fmt.Sprintf("%v", s.Extended)) + builder.WriteString(", rank_new=") + builder.WriteString(fmt.Sprintf("%v", s.RankNew)) + builder.WriteString(", rank_old=") + builder.WriteString(fmt.Sprintf("%v", s.RankOld)) + builder.WriteString(", mk_2=") + builder.WriteString(fmt.Sprintf("%v", s.Mk2)) + builder.WriteString(", mk_3=") + builder.WriteString(fmt.Sprintf("%v", s.Mk3)) + builder.WriteString(", mk_4=") + builder.WriteString(fmt.Sprintf("%v", s.Mk4)) + builder.WriteString(", mk_5=") + builder.WriteString(fmt.Sprintf("%v", s.Mk5)) + builder.WriteString(", dmg_enemy=") + builder.WriteString(fmt.Sprintf("%v", s.DmgEnemy)) + builder.WriteString(", dmg_team=") + builder.WriteString(fmt.Sprintf("%v", s.DmgTeam)) + builder.WriteString(", ud_he=") + builder.WriteString(fmt.Sprintf("%v", s.UdHe)) + builder.WriteString(", ud_flames=") + builder.WriteString(fmt.Sprintf("%v", s.UdFlames)) + builder.WriteString(", ud_flash=") + builder.WriteString(fmt.Sprintf("%v", s.UdFlash)) + builder.WriteString(", ud_decoy=") + builder.WriteString(fmt.Sprintf("%v", s.UdDecoy)) + builder.WriteString(", ud_smoke=") + builder.WriteString(fmt.Sprintf("%v", s.UdSmoke)) + builder.WriteString(", hit_group_head=") + builder.WriteString(fmt.Sprintf("%v", s.HitGroupHead)) + builder.WriteString(", hit_group_chest=") + builder.WriteString(fmt.Sprintf("%v", s.HitGroupChest)) + builder.WriteString(", hit_group_stomach=") + builder.WriteString(fmt.Sprintf("%v", s.HitGroupStomach)) + builder.WriteString(", hit_group_left_arm=") + builder.WriteString(fmt.Sprintf("%v", s.HitGroupLeftArm)) + builder.WriteString(", hit_group_right_arm=") + builder.WriteString(fmt.Sprintf("%v", s.HitGroupRightArm)) + builder.WriteString(", hit_group_left_leg=") + builder.WriteString(fmt.Sprintf("%v", s.HitGroupLeftLeg)) + builder.WriteString(", hit_group_right_leg=") + builder.WriteString(fmt.Sprintf("%v", s.HitGroupRightLeg)) + builder.WriteString(", hit_group_gear=") + builder.WriteString(fmt.Sprintf("%v", s.HitGroupGear)) + builder.WriteString(", crosshair=") + builder.WriteString(s.Crosshair) + builder.WriteString(", color=") + builder.WriteString(fmt.Sprintf("%v", s.Color)) + builder.WriteString(", kast=") + builder.WriteString(fmt.Sprintf("%v", s.Kast)) + builder.WriteString(", flash_duration_self=") + builder.WriteString(fmt.Sprintf("%v", s.FlashDurationSelf)) + builder.WriteString(", flash_duration_team=") + builder.WriteString(fmt.Sprintf("%v", s.FlashDurationTeam)) + builder.WriteString(", flash_duration_enemy=") + builder.WriteString(fmt.Sprintf("%v", s.FlashDurationEnemy)) + builder.WriteString(", flash_total_self=") + builder.WriteString(fmt.Sprintf("%v", s.FlashTotalSelf)) + builder.WriteString(", flash_total_team=") + builder.WriteString(fmt.Sprintf("%v", s.FlashTotalTeam)) + builder.WriteString(", flash_total_enemy=") + builder.WriteString(fmt.Sprintf("%v", s.FlashTotalEnemy)) + builder.WriteString(", match_stats=") + builder.WriteString(fmt.Sprintf("%v", s.MatchStats)) + builder.WriteString(", player_stats=") + builder.WriteString(fmt.Sprintf("%v", s.PlayerStats)) builder.WriteByte(')') return builder.String() } diff --git a/ent/stats/stats.go b/ent/stats/stats.go index 3790f37..dd16ac2 100644 --- a/ent/stats/stats.go +++ b/ent/stats/stats.go @@ -2,6 +2,10 @@ package stats +import ( + "fmt" +) + const ( // Label holds the string label denoting the stats type in the database. Label = "stats" @@ -21,12 +25,76 @@ const ( FieldMvp = "mvp" // FieldScore holds the string denoting the score field in the database. FieldScore = "score" - // FieldExtended holds the string denoting the extended field in the database. - FieldExtended = "extended" + // FieldRankNew holds the string denoting the rank_new field in the database. + FieldRankNew = "rank_new" + // FieldRankOld holds the string denoting the rank_old field in the database. + FieldRankOld = "rank_old" + // FieldMk2 holds the string denoting the mk_2 field in the database. + FieldMk2 = "mk_2" + // FieldMk3 holds the string denoting the mk_3 field in the database. + FieldMk3 = "mk_3" + // FieldMk4 holds the string denoting the mk_4 field in the database. + FieldMk4 = "mk_4" + // FieldMk5 holds the string denoting the mk_5 field in the database. + FieldMk5 = "mk_5" + // FieldDmgEnemy holds the string denoting the dmg_enemy field in the database. + FieldDmgEnemy = "dmg_enemy" + // FieldDmgTeam holds the string denoting the dmg_team field in the database. + FieldDmgTeam = "dmg_team" + // FieldUdHe holds the string denoting the ud_he field in the database. + FieldUdHe = "ud_he" + // FieldUdFlames holds the string denoting the ud_flames field in the database. + FieldUdFlames = "ud_flames" + // FieldUdFlash holds the string denoting the ud_flash field in the database. + FieldUdFlash = "ud_flash" + // FieldUdDecoy holds the string denoting the ud_decoy field in the database. + FieldUdDecoy = "ud_decoy" + // FieldUdSmoke holds the string denoting the ud_smoke field in the database. + FieldUdSmoke = "ud_smoke" + // FieldHitGroupHead holds the string denoting the hit_group_head field in the database. + FieldHitGroupHead = "hit_group_head" + // FieldHitGroupChest holds the string denoting the hit_group_chest field in the database. + FieldHitGroupChest = "hit_group_chest" + // FieldHitGroupStomach holds the string denoting the hit_group_stomach field in the database. + FieldHitGroupStomach = "hit_group_stomach" + // FieldHitGroupLeftArm holds the string denoting the hit_group_left_arm field in the database. + FieldHitGroupLeftArm = "hit_group_left_arm" + // FieldHitGroupRightArm holds the string denoting the hit_group_right_arm field in the database. + FieldHitGroupRightArm = "hit_group_right_arm" + // FieldHitGroupLeftLeg holds the string denoting the hit_group_left_leg field in the database. + FieldHitGroupLeftLeg = "hit_group_left_leg" + // FieldHitGroupRightLeg holds the string denoting the hit_group_right_leg field in the database. + FieldHitGroupRightLeg = "hit_group_right_leg" + // FieldHitGroupGear holds the string denoting the hit_group_gear field in the database. + FieldHitGroupGear = "hit_group_gear" + // FieldCrosshair holds the string denoting the crosshair field in the database. + FieldCrosshair = "crosshair" + // FieldColor holds the string denoting the color field in the database. + FieldColor = "color" + // FieldKast holds the string denoting the kast field in the database. + FieldKast = "kast" + // FieldFlashDurationSelf holds the string denoting the flash_duration_self field in the database. + FieldFlashDurationSelf = "flash_duration_self" + // FieldFlashDurationTeam holds the string denoting the flash_duration_team field in the database. + FieldFlashDurationTeam = "flash_duration_team" + // FieldFlashDurationEnemy holds the string denoting the flash_duration_enemy field in the database. + FieldFlashDurationEnemy = "flash_duration_enemy" + // FieldFlashTotalSelf holds the string denoting the flash_total_self field in the database. + FieldFlashTotalSelf = "flash_total_self" + // FieldFlashTotalTeam holds the string denoting the flash_total_team field in the database. + FieldFlashTotalTeam = "flash_total_team" + // FieldFlashTotalEnemy holds the string denoting the flash_total_enemy field in the database. + FieldFlashTotalEnemy = "flash_total_enemy" + // FieldMatchStats holds the string denoting the match_stats field in the database. + FieldMatchStats = "match_stats" + // FieldPlayerStats holds the string denoting the player_stats field in the database. + FieldPlayerStats = "player_stats" // EdgeMatches holds the string denoting the matches edge name in mutations. EdgeMatches = "matches" // EdgePlayers holds the string denoting the players edge name in mutations. EdgePlayers = "players" + // EdgeWeaponStats holds the string denoting the weapon_stats edge name in mutations. + EdgeWeaponStats = "weapon_stats" // Table holds the table name of the stats in the database. Table = "stats" // MatchesTable is the table that holds the matches relation/edge. @@ -43,6 +111,13 @@ const ( PlayersInverseTable = "players" // PlayersColumn is the table column denoting the players relation/edge. PlayersColumn = "player_stats" + // WeaponStatsTable is the table that holds the weapon_stats relation/edge. + WeaponStatsTable = "weapon_stats" + // WeaponStatsInverseTable is the table name for the WeaponStats entity. + // It exists in this package in order to avoid circular dependency with the "weaponstats" package. + WeaponStatsInverseTable = "weapon_stats" + // WeaponStatsColumn is the table column denoting the weapon_stats relation/edge. + WeaponStatsColumn = "stats_weapon_stats" ) // Columns holds all SQL columns for stats fields. @@ -55,14 +130,38 @@ var Columns = []string{ FieldHeadshot, FieldMvp, FieldScore, - FieldExtended, -} - -// ForeignKeys holds the SQL foreign-keys that are owned by the "stats" -// table and are not defined as standalone fields in the schema. -var ForeignKeys = []string{ - "match_stats", - "player_stats", + FieldRankNew, + FieldRankOld, + FieldMk2, + FieldMk3, + FieldMk4, + FieldMk5, + FieldDmgEnemy, + FieldDmgTeam, + FieldUdHe, + FieldUdFlames, + FieldUdFlash, + FieldUdDecoy, + FieldUdSmoke, + FieldHitGroupHead, + FieldHitGroupChest, + FieldHitGroupStomach, + FieldHitGroupLeftArm, + FieldHitGroupRightArm, + FieldHitGroupLeftLeg, + FieldHitGroupRightLeg, + FieldHitGroupGear, + FieldCrosshair, + FieldColor, + FieldKast, + FieldFlashDurationSelf, + FieldFlashDurationTeam, + FieldFlashDurationEnemy, + FieldFlashTotalSelf, + FieldFlashTotalTeam, + FieldFlashTotalEnemy, + FieldMatchStats, + FieldPlayerStats, } // ValidColumn reports if the column name is valid (part of the table columns). @@ -72,10 +171,32 @@ func ValidColumn(column string) bool { return true } } - for i := range ForeignKeys { - if column == ForeignKeys[i] { - return true - } - } return false } + +// Color defines the type for the "color" enum field. +type Color string + +// Color values. +const ( + ColorGreen Color = "green" + ColorYellow Color = "yellow" + ColorPurple Color = "purple" + ColorBlue Color = "blue" + ColorOrange Color = "orange" + ColorGrey Color = "grey" +) + +func (c Color) String() string { + return string(c) +} + +// ColorValidator is a validator for the "color" field enum values. It is called by the builders before save. +func ColorValidator(c Color) error { + switch c { + case ColorGreen, ColorYellow, ColorPurple, ColorBlue, ColorOrange, ColorGrey: + return nil + default: + return fmt.Errorf("stats: invalid enum value for color field: %q", c) + } +} diff --git a/ent/stats/where.go b/ent/stats/where.go index 3024885..e79d5b0 100644 --- a/ent/stats/where.go +++ b/ent/stats/where.go @@ -128,7 +128,7 @@ func Headshot(v int) predicate.Stats { } // Mvp applies equality check predicate on the "mvp" field. It's identical to MvpEQ. -func Mvp(v int) predicate.Stats { +func Mvp(v uint) predicate.Stats { return predicate.Stats(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldMvp), v)) }) @@ -141,6 +141,223 @@ func Score(v int) predicate.Stats { }) } +// RankNew applies equality check predicate on the "rank_new" field. It's identical to RankNewEQ. +func RankNew(v int) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldRankNew), v)) + }) +} + +// RankOld applies equality check predicate on the "rank_old" field. It's identical to RankOldEQ. +func RankOld(v int) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldRankOld), v)) + }) +} + +// Mk2 applies equality check predicate on the "mk_2" field. It's identical to Mk2EQ. +func Mk2(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldMk2), v)) + }) +} + +// Mk3 applies equality check predicate on the "mk_3" field. It's identical to Mk3EQ. +func Mk3(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldMk3), v)) + }) +} + +// Mk4 applies equality check predicate on the "mk_4" field. It's identical to Mk4EQ. +func Mk4(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldMk4), v)) + }) +} + +// Mk5 applies equality check predicate on the "mk_5" field. It's identical to Mk5EQ. +func Mk5(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldMk5), v)) + }) +} + +// DmgEnemy applies equality check predicate on the "dmg_enemy" field. It's identical to DmgEnemyEQ. +func DmgEnemy(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldDmgEnemy), v)) + }) +} + +// DmgTeam applies equality check predicate on the "dmg_team" field. It's identical to DmgTeamEQ. +func DmgTeam(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldDmgTeam), v)) + }) +} + +// UdHe applies equality check predicate on the "ud_he" field. It's identical to UdHeEQ. +func UdHe(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldUdHe), v)) + }) +} + +// UdFlames applies equality check predicate on the "ud_flames" field. It's identical to UdFlamesEQ. +func UdFlames(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldUdFlames), v)) + }) +} + +// UdFlash applies equality check predicate on the "ud_flash" field. It's identical to UdFlashEQ. +func UdFlash(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldUdFlash), v)) + }) +} + +// UdDecoy applies equality check predicate on the "ud_decoy" field. It's identical to UdDecoyEQ. +func UdDecoy(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldUdDecoy), v)) + }) +} + +// UdSmoke applies equality check predicate on the "ud_smoke" field. It's identical to UdSmokeEQ. +func UdSmoke(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldUdSmoke), v)) + }) +} + +// HitGroupHead applies equality check predicate on the "hit_group_head" field. It's identical to HitGroupHeadEQ. +func HitGroupHead(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldHitGroupHead), v)) + }) +} + +// HitGroupChest applies equality check predicate on the "hit_group_chest" field. It's identical to HitGroupChestEQ. +func HitGroupChest(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldHitGroupChest), v)) + }) +} + +// HitGroupStomach applies equality check predicate on the "hit_group_stomach" field. It's identical to HitGroupStomachEQ. +func HitGroupStomach(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldHitGroupStomach), v)) + }) +} + +// HitGroupLeftArm applies equality check predicate on the "hit_group_left_arm" field. It's identical to HitGroupLeftArmEQ. +func HitGroupLeftArm(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldHitGroupLeftArm), v)) + }) +} + +// HitGroupRightArm applies equality check predicate on the "hit_group_right_arm" field. It's identical to HitGroupRightArmEQ. +func HitGroupRightArm(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldHitGroupRightArm), v)) + }) +} + +// HitGroupLeftLeg applies equality check predicate on the "hit_group_left_leg" field. It's identical to HitGroupLeftLegEQ. +func HitGroupLeftLeg(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldHitGroupLeftLeg), v)) + }) +} + +// HitGroupRightLeg applies equality check predicate on the "hit_group_right_leg" field. It's identical to HitGroupRightLegEQ. +func HitGroupRightLeg(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldHitGroupRightLeg), v)) + }) +} + +// HitGroupGear applies equality check predicate on the "hit_group_gear" field. It's identical to HitGroupGearEQ. +func HitGroupGear(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldHitGroupGear), v)) + }) +} + +// Crosshair applies equality check predicate on the "crosshair" field. It's identical to CrosshairEQ. +func Crosshair(v string) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldCrosshair), v)) + }) +} + +// Kast applies equality check predicate on the "kast" field. It's identical to KastEQ. +func Kast(v int) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldKast), v)) + }) +} + +// FlashDurationSelf applies equality check predicate on the "flash_duration_self" field. It's identical to FlashDurationSelfEQ. +func FlashDurationSelf(v float32) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldFlashDurationSelf), v)) + }) +} + +// FlashDurationTeam applies equality check predicate on the "flash_duration_team" field. It's identical to FlashDurationTeamEQ. +func FlashDurationTeam(v float32) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldFlashDurationTeam), v)) + }) +} + +// FlashDurationEnemy applies equality check predicate on the "flash_duration_enemy" field. It's identical to FlashDurationEnemyEQ. +func FlashDurationEnemy(v float32) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldFlashDurationEnemy), v)) + }) +} + +// FlashTotalSelf applies equality check predicate on the "flash_total_self" field. It's identical to FlashTotalSelfEQ. +func FlashTotalSelf(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldFlashTotalSelf), v)) + }) +} + +// FlashTotalTeam applies equality check predicate on the "flash_total_team" field. It's identical to FlashTotalTeamEQ. +func FlashTotalTeam(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldFlashTotalTeam), v)) + }) +} + +// FlashTotalEnemy applies equality check predicate on the "flash_total_enemy" field. It's identical to FlashTotalEnemyEQ. +func FlashTotalEnemy(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldFlashTotalEnemy), v)) + }) +} + +// MatchStats applies equality check predicate on the "match_stats" field. It's identical to MatchStatsEQ. +func MatchStats(v uint64) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldMatchStats), v)) + }) +} + +// PlayerStats applies equality check predicate on the "player_stats" field. It's identical to PlayerStatsEQ. +func PlayerStats(v uint64) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldPlayerStats), v)) + }) +} + // TeamIDEQ applies the EQ predicate on the "team_id" field. func TeamIDEQ(v int) predicate.Stats { return predicate.Stats(func(s *sql.Selector) { @@ -522,21 +739,21 @@ func HeadshotLTE(v int) predicate.Stats { } // MvpEQ applies the EQ predicate on the "mvp" field. -func MvpEQ(v int) predicate.Stats { +func MvpEQ(v uint) predicate.Stats { return predicate.Stats(func(s *sql.Selector) { s.Where(sql.EQ(s.C(FieldMvp), v)) }) } // MvpNEQ applies the NEQ predicate on the "mvp" field. -func MvpNEQ(v int) predicate.Stats { +func MvpNEQ(v uint) predicate.Stats { return predicate.Stats(func(s *sql.Selector) { s.Where(sql.NEQ(s.C(FieldMvp), v)) }) } // MvpIn applies the In predicate on the "mvp" field. -func MvpIn(vs ...int) predicate.Stats { +func MvpIn(vs ...uint) predicate.Stats { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] @@ -553,7 +770,7 @@ func MvpIn(vs ...int) predicate.Stats { } // MvpNotIn applies the NotIn predicate on the "mvp" field. -func MvpNotIn(vs ...int) predicate.Stats { +func MvpNotIn(vs ...uint) predicate.Stats { v := make([]interface{}, len(vs)) for i := range v { v[i] = vs[i] @@ -570,28 +787,28 @@ func MvpNotIn(vs ...int) predicate.Stats { } // MvpGT applies the GT predicate on the "mvp" field. -func MvpGT(v int) predicate.Stats { +func MvpGT(v uint) predicate.Stats { return predicate.Stats(func(s *sql.Selector) { s.Where(sql.GT(s.C(FieldMvp), v)) }) } // MvpGTE applies the GTE predicate on the "mvp" field. -func MvpGTE(v int) predicate.Stats { +func MvpGTE(v uint) predicate.Stats { return predicate.Stats(func(s *sql.Selector) { s.Where(sql.GTE(s.C(FieldMvp), v)) }) } // MvpLT applies the LT predicate on the "mvp" field. -func MvpLT(v int) predicate.Stats { +func MvpLT(v uint) predicate.Stats { return predicate.Stats(func(s *sql.Selector) { s.Where(sql.LT(s.C(FieldMvp), v)) }) } // MvpLTE applies the LTE predicate on the "mvp" field. -func MvpLTE(v int) predicate.Stats { +func MvpLTE(v uint) predicate.Stats { return predicate.Stats(func(s *sql.Selector) { s.Where(sql.LTE(s.C(FieldMvp), v)) }) @@ -673,17 +890,2834 @@ func ScoreLTE(v int) predicate.Stats { }) } -// ExtendedIsNil applies the IsNil predicate on the "extended" field. -func ExtendedIsNil() predicate.Stats { +// RankNewEQ applies the EQ predicate on the "rank_new" field. +func RankNewEQ(v int) predicate.Stats { return predicate.Stats(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldExtended))) + s.Where(sql.EQ(s.C(FieldRankNew), v)) }) } -// ExtendedNotNil applies the NotNil predicate on the "extended" field. -func ExtendedNotNil() predicate.Stats { +// RankNewNEQ applies the NEQ predicate on the "rank_new" field. +func RankNewNEQ(v int) predicate.Stats { return predicate.Stats(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldExtended))) + s.Where(sql.NEQ(s.C(FieldRankNew), v)) + }) +} + +// RankNewIn applies the In predicate on the "rank_new" field. +func RankNewIn(vs ...int) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldRankNew), v...)) + }) +} + +// RankNewNotIn applies the NotIn predicate on the "rank_new" field. +func RankNewNotIn(vs ...int) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldRankNew), v...)) + }) +} + +// RankNewGT applies the GT predicate on the "rank_new" field. +func RankNewGT(v int) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldRankNew), v)) + }) +} + +// RankNewGTE applies the GTE predicate on the "rank_new" field. +func RankNewGTE(v int) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldRankNew), v)) + }) +} + +// RankNewLT applies the LT predicate on the "rank_new" field. +func RankNewLT(v int) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldRankNew), v)) + }) +} + +// RankNewLTE applies the LTE predicate on the "rank_new" field. +func RankNewLTE(v int) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldRankNew), v)) + }) +} + +// RankNewIsNil applies the IsNil predicate on the "rank_new" field. +func RankNewIsNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldRankNew))) + }) +} + +// RankNewNotNil applies the NotNil predicate on the "rank_new" field. +func RankNewNotNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldRankNew))) + }) +} + +// RankOldEQ applies the EQ predicate on the "rank_old" field. +func RankOldEQ(v int) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldRankOld), v)) + }) +} + +// RankOldNEQ applies the NEQ predicate on the "rank_old" field. +func RankOldNEQ(v int) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldRankOld), v)) + }) +} + +// RankOldIn applies the In predicate on the "rank_old" field. +func RankOldIn(vs ...int) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldRankOld), v...)) + }) +} + +// RankOldNotIn applies the NotIn predicate on the "rank_old" field. +func RankOldNotIn(vs ...int) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldRankOld), v...)) + }) +} + +// RankOldGT applies the GT predicate on the "rank_old" field. +func RankOldGT(v int) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldRankOld), v)) + }) +} + +// RankOldGTE applies the GTE predicate on the "rank_old" field. +func RankOldGTE(v int) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldRankOld), v)) + }) +} + +// RankOldLT applies the LT predicate on the "rank_old" field. +func RankOldLT(v int) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldRankOld), v)) + }) +} + +// RankOldLTE applies the LTE predicate on the "rank_old" field. +func RankOldLTE(v int) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldRankOld), v)) + }) +} + +// RankOldIsNil applies the IsNil predicate on the "rank_old" field. +func RankOldIsNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldRankOld))) + }) +} + +// RankOldNotNil applies the NotNil predicate on the "rank_old" field. +func RankOldNotNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldRankOld))) + }) +} + +// Mk2EQ applies the EQ predicate on the "mk_2" field. +func Mk2EQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldMk2), v)) + }) +} + +// Mk2NEQ applies the NEQ predicate on the "mk_2" field. +func Mk2NEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldMk2), v)) + }) +} + +// Mk2In applies the In predicate on the "mk_2" field. +func Mk2In(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldMk2), v...)) + }) +} + +// Mk2NotIn applies the NotIn predicate on the "mk_2" field. +func Mk2NotIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldMk2), v...)) + }) +} + +// Mk2GT applies the GT predicate on the "mk_2" field. +func Mk2GT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldMk2), v)) + }) +} + +// Mk2GTE applies the GTE predicate on the "mk_2" field. +func Mk2GTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldMk2), v)) + }) +} + +// Mk2LT applies the LT predicate on the "mk_2" field. +func Mk2LT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldMk2), v)) + }) +} + +// Mk2LTE applies the LTE predicate on the "mk_2" field. +func Mk2LTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldMk2), v)) + }) +} + +// Mk2IsNil applies the IsNil predicate on the "mk_2" field. +func Mk2IsNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldMk2))) + }) +} + +// Mk2NotNil applies the NotNil predicate on the "mk_2" field. +func Mk2NotNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldMk2))) + }) +} + +// Mk3EQ applies the EQ predicate on the "mk_3" field. +func Mk3EQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldMk3), v)) + }) +} + +// Mk3NEQ applies the NEQ predicate on the "mk_3" field. +func Mk3NEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldMk3), v)) + }) +} + +// Mk3In applies the In predicate on the "mk_3" field. +func Mk3In(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldMk3), v...)) + }) +} + +// Mk3NotIn applies the NotIn predicate on the "mk_3" field. +func Mk3NotIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldMk3), v...)) + }) +} + +// Mk3GT applies the GT predicate on the "mk_3" field. +func Mk3GT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldMk3), v)) + }) +} + +// Mk3GTE applies the GTE predicate on the "mk_3" field. +func Mk3GTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldMk3), v)) + }) +} + +// Mk3LT applies the LT predicate on the "mk_3" field. +func Mk3LT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldMk3), v)) + }) +} + +// Mk3LTE applies the LTE predicate on the "mk_3" field. +func Mk3LTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldMk3), v)) + }) +} + +// Mk3IsNil applies the IsNil predicate on the "mk_3" field. +func Mk3IsNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldMk3))) + }) +} + +// Mk3NotNil applies the NotNil predicate on the "mk_3" field. +func Mk3NotNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldMk3))) + }) +} + +// Mk4EQ applies the EQ predicate on the "mk_4" field. +func Mk4EQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldMk4), v)) + }) +} + +// Mk4NEQ applies the NEQ predicate on the "mk_4" field. +func Mk4NEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldMk4), v)) + }) +} + +// Mk4In applies the In predicate on the "mk_4" field. +func Mk4In(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldMk4), v...)) + }) +} + +// Mk4NotIn applies the NotIn predicate on the "mk_4" field. +func Mk4NotIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldMk4), v...)) + }) +} + +// Mk4GT applies the GT predicate on the "mk_4" field. +func Mk4GT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldMk4), v)) + }) +} + +// Mk4GTE applies the GTE predicate on the "mk_4" field. +func Mk4GTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldMk4), v)) + }) +} + +// Mk4LT applies the LT predicate on the "mk_4" field. +func Mk4LT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldMk4), v)) + }) +} + +// Mk4LTE applies the LTE predicate on the "mk_4" field. +func Mk4LTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldMk4), v)) + }) +} + +// Mk4IsNil applies the IsNil predicate on the "mk_4" field. +func Mk4IsNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldMk4))) + }) +} + +// Mk4NotNil applies the NotNil predicate on the "mk_4" field. +func Mk4NotNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldMk4))) + }) +} + +// Mk5EQ applies the EQ predicate on the "mk_5" field. +func Mk5EQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldMk5), v)) + }) +} + +// Mk5NEQ applies the NEQ predicate on the "mk_5" field. +func Mk5NEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldMk5), v)) + }) +} + +// Mk5In applies the In predicate on the "mk_5" field. +func Mk5In(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldMk5), v...)) + }) +} + +// Mk5NotIn applies the NotIn predicate on the "mk_5" field. +func Mk5NotIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldMk5), v...)) + }) +} + +// Mk5GT applies the GT predicate on the "mk_5" field. +func Mk5GT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldMk5), v)) + }) +} + +// Mk5GTE applies the GTE predicate on the "mk_5" field. +func Mk5GTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldMk5), v)) + }) +} + +// Mk5LT applies the LT predicate on the "mk_5" field. +func Mk5LT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldMk5), v)) + }) +} + +// Mk5LTE applies the LTE predicate on the "mk_5" field. +func Mk5LTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldMk5), v)) + }) +} + +// Mk5IsNil applies the IsNil predicate on the "mk_5" field. +func Mk5IsNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldMk5))) + }) +} + +// Mk5NotNil applies the NotNil predicate on the "mk_5" field. +func Mk5NotNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldMk5))) + }) +} + +// DmgEnemyEQ applies the EQ predicate on the "dmg_enemy" field. +func DmgEnemyEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldDmgEnemy), v)) + }) +} + +// DmgEnemyNEQ applies the NEQ predicate on the "dmg_enemy" field. +func DmgEnemyNEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldDmgEnemy), v)) + }) +} + +// DmgEnemyIn applies the In predicate on the "dmg_enemy" field. +func DmgEnemyIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldDmgEnemy), v...)) + }) +} + +// DmgEnemyNotIn applies the NotIn predicate on the "dmg_enemy" field. +func DmgEnemyNotIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldDmgEnemy), v...)) + }) +} + +// DmgEnemyGT applies the GT predicate on the "dmg_enemy" field. +func DmgEnemyGT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldDmgEnemy), v)) + }) +} + +// DmgEnemyGTE applies the GTE predicate on the "dmg_enemy" field. +func DmgEnemyGTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldDmgEnemy), v)) + }) +} + +// DmgEnemyLT applies the LT predicate on the "dmg_enemy" field. +func DmgEnemyLT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldDmgEnemy), v)) + }) +} + +// DmgEnemyLTE applies the LTE predicate on the "dmg_enemy" field. +func DmgEnemyLTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldDmgEnemy), v)) + }) +} + +// DmgEnemyIsNil applies the IsNil predicate on the "dmg_enemy" field. +func DmgEnemyIsNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldDmgEnemy))) + }) +} + +// DmgEnemyNotNil applies the NotNil predicate on the "dmg_enemy" field. +func DmgEnemyNotNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldDmgEnemy))) + }) +} + +// DmgTeamEQ applies the EQ predicate on the "dmg_team" field. +func DmgTeamEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldDmgTeam), v)) + }) +} + +// DmgTeamNEQ applies the NEQ predicate on the "dmg_team" field. +func DmgTeamNEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldDmgTeam), v)) + }) +} + +// DmgTeamIn applies the In predicate on the "dmg_team" field. +func DmgTeamIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldDmgTeam), v...)) + }) +} + +// DmgTeamNotIn applies the NotIn predicate on the "dmg_team" field. +func DmgTeamNotIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldDmgTeam), v...)) + }) +} + +// DmgTeamGT applies the GT predicate on the "dmg_team" field. +func DmgTeamGT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldDmgTeam), v)) + }) +} + +// DmgTeamGTE applies the GTE predicate on the "dmg_team" field. +func DmgTeamGTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldDmgTeam), v)) + }) +} + +// DmgTeamLT applies the LT predicate on the "dmg_team" field. +func DmgTeamLT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldDmgTeam), v)) + }) +} + +// DmgTeamLTE applies the LTE predicate on the "dmg_team" field. +func DmgTeamLTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldDmgTeam), v)) + }) +} + +// DmgTeamIsNil applies the IsNil predicate on the "dmg_team" field. +func DmgTeamIsNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldDmgTeam))) + }) +} + +// DmgTeamNotNil applies the NotNil predicate on the "dmg_team" field. +func DmgTeamNotNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldDmgTeam))) + }) +} + +// UdHeEQ applies the EQ predicate on the "ud_he" field. +func UdHeEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldUdHe), v)) + }) +} + +// UdHeNEQ applies the NEQ predicate on the "ud_he" field. +func UdHeNEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldUdHe), v)) + }) +} + +// UdHeIn applies the In predicate on the "ud_he" field. +func UdHeIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldUdHe), v...)) + }) +} + +// UdHeNotIn applies the NotIn predicate on the "ud_he" field. +func UdHeNotIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldUdHe), v...)) + }) +} + +// UdHeGT applies the GT predicate on the "ud_he" field. +func UdHeGT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldUdHe), v)) + }) +} + +// UdHeGTE applies the GTE predicate on the "ud_he" field. +func UdHeGTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldUdHe), v)) + }) +} + +// UdHeLT applies the LT predicate on the "ud_he" field. +func UdHeLT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldUdHe), v)) + }) +} + +// UdHeLTE applies the LTE predicate on the "ud_he" field. +func UdHeLTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldUdHe), v)) + }) +} + +// UdHeIsNil applies the IsNil predicate on the "ud_he" field. +func UdHeIsNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldUdHe))) + }) +} + +// UdHeNotNil applies the NotNil predicate on the "ud_he" field. +func UdHeNotNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldUdHe))) + }) +} + +// UdFlamesEQ applies the EQ predicate on the "ud_flames" field. +func UdFlamesEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldUdFlames), v)) + }) +} + +// UdFlamesNEQ applies the NEQ predicate on the "ud_flames" field. +func UdFlamesNEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldUdFlames), v)) + }) +} + +// UdFlamesIn applies the In predicate on the "ud_flames" field. +func UdFlamesIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldUdFlames), v...)) + }) +} + +// UdFlamesNotIn applies the NotIn predicate on the "ud_flames" field. +func UdFlamesNotIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldUdFlames), v...)) + }) +} + +// UdFlamesGT applies the GT predicate on the "ud_flames" field. +func UdFlamesGT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldUdFlames), v)) + }) +} + +// UdFlamesGTE applies the GTE predicate on the "ud_flames" field. +func UdFlamesGTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldUdFlames), v)) + }) +} + +// UdFlamesLT applies the LT predicate on the "ud_flames" field. +func UdFlamesLT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldUdFlames), v)) + }) +} + +// UdFlamesLTE applies the LTE predicate on the "ud_flames" field. +func UdFlamesLTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldUdFlames), v)) + }) +} + +// UdFlamesIsNil applies the IsNil predicate on the "ud_flames" field. +func UdFlamesIsNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldUdFlames))) + }) +} + +// UdFlamesNotNil applies the NotNil predicate on the "ud_flames" field. +func UdFlamesNotNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldUdFlames))) + }) +} + +// UdFlashEQ applies the EQ predicate on the "ud_flash" field. +func UdFlashEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldUdFlash), v)) + }) +} + +// UdFlashNEQ applies the NEQ predicate on the "ud_flash" field. +func UdFlashNEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldUdFlash), v)) + }) +} + +// UdFlashIn applies the In predicate on the "ud_flash" field. +func UdFlashIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldUdFlash), v...)) + }) +} + +// UdFlashNotIn applies the NotIn predicate on the "ud_flash" field. +func UdFlashNotIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldUdFlash), v...)) + }) +} + +// UdFlashGT applies the GT predicate on the "ud_flash" field. +func UdFlashGT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldUdFlash), v)) + }) +} + +// UdFlashGTE applies the GTE predicate on the "ud_flash" field. +func UdFlashGTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldUdFlash), v)) + }) +} + +// UdFlashLT applies the LT predicate on the "ud_flash" field. +func UdFlashLT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldUdFlash), v)) + }) +} + +// UdFlashLTE applies the LTE predicate on the "ud_flash" field. +func UdFlashLTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldUdFlash), v)) + }) +} + +// UdFlashIsNil applies the IsNil predicate on the "ud_flash" field. +func UdFlashIsNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldUdFlash))) + }) +} + +// UdFlashNotNil applies the NotNil predicate on the "ud_flash" field. +func UdFlashNotNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldUdFlash))) + }) +} + +// UdDecoyEQ applies the EQ predicate on the "ud_decoy" field. +func UdDecoyEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldUdDecoy), v)) + }) +} + +// UdDecoyNEQ applies the NEQ predicate on the "ud_decoy" field. +func UdDecoyNEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldUdDecoy), v)) + }) +} + +// UdDecoyIn applies the In predicate on the "ud_decoy" field. +func UdDecoyIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldUdDecoy), v...)) + }) +} + +// UdDecoyNotIn applies the NotIn predicate on the "ud_decoy" field. +func UdDecoyNotIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldUdDecoy), v...)) + }) +} + +// UdDecoyGT applies the GT predicate on the "ud_decoy" field. +func UdDecoyGT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldUdDecoy), v)) + }) +} + +// UdDecoyGTE applies the GTE predicate on the "ud_decoy" field. +func UdDecoyGTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldUdDecoy), v)) + }) +} + +// UdDecoyLT applies the LT predicate on the "ud_decoy" field. +func UdDecoyLT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldUdDecoy), v)) + }) +} + +// UdDecoyLTE applies the LTE predicate on the "ud_decoy" field. +func UdDecoyLTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldUdDecoy), v)) + }) +} + +// UdDecoyIsNil applies the IsNil predicate on the "ud_decoy" field. +func UdDecoyIsNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldUdDecoy))) + }) +} + +// UdDecoyNotNil applies the NotNil predicate on the "ud_decoy" field. +func UdDecoyNotNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldUdDecoy))) + }) +} + +// UdSmokeEQ applies the EQ predicate on the "ud_smoke" field. +func UdSmokeEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldUdSmoke), v)) + }) +} + +// UdSmokeNEQ applies the NEQ predicate on the "ud_smoke" field. +func UdSmokeNEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldUdSmoke), v)) + }) +} + +// UdSmokeIn applies the In predicate on the "ud_smoke" field. +func UdSmokeIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldUdSmoke), v...)) + }) +} + +// UdSmokeNotIn applies the NotIn predicate on the "ud_smoke" field. +func UdSmokeNotIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldUdSmoke), v...)) + }) +} + +// UdSmokeGT applies the GT predicate on the "ud_smoke" field. +func UdSmokeGT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldUdSmoke), v)) + }) +} + +// UdSmokeGTE applies the GTE predicate on the "ud_smoke" field. +func UdSmokeGTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldUdSmoke), v)) + }) +} + +// UdSmokeLT applies the LT predicate on the "ud_smoke" field. +func UdSmokeLT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldUdSmoke), v)) + }) +} + +// UdSmokeLTE applies the LTE predicate on the "ud_smoke" field. +func UdSmokeLTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldUdSmoke), v)) + }) +} + +// UdSmokeIsNil applies the IsNil predicate on the "ud_smoke" field. +func UdSmokeIsNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldUdSmoke))) + }) +} + +// UdSmokeNotNil applies the NotNil predicate on the "ud_smoke" field. +func UdSmokeNotNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldUdSmoke))) + }) +} + +// HitGroupHeadEQ applies the EQ predicate on the "hit_group_head" field. +func HitGroupHeadEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldHitGroupHead), v)) + }) +} + +// HitGroupHeadNEQ applies the NEQ predicate on the "hit_group_head" field. +func HitGroupHeadNEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldHitGroupHead), v)) + }) +} + +// HitGroupHeadIn applies the In predicate on the "hit_group_head" field. +func HitGroupHeadIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldHitGroupHead), v...)) + }) +} + +// HitGroupHeadNotIn applies the NotIn predicate on the "hit_group_head" field. +func HitGroupHeadNotIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldHitGroupHead), v...)) + }) +} + +// HitGroupHeadGT applies the GT predicate on the "hit_group_head" field. +func HitGroupHeadGT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldHitGroupHead), v)) + }) +} + +// HitGroupHeadGTE applies the GTE predicate on the "hit_group_head" field. +func HitGroupHeadGTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldHitGroupHead), v)) + }) +} + +// HitGroupHeadLT applies the LT predicate on the "hit_group_head" field. +func HitGroupHeadLT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldHitGroupHead), v)) + }) +} + +// HitGroupHeadLTE applies the LTE predicate on the "hit_group_head" field. +func HitGroupHeadLTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldHitGroupHead), v)) + }) +} + +// HitGroupHeadIsNil applies the IsNil predicate on the "hit_group_head" field. +func HitGroupHeadIsNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldHitGroupHead))) + }) +} + +// HitGroupHeadNotNil applies the NotNil predicate on the "hit_group_head" field. +func HitGroupHeadNotNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldHitGroupHead))) + }) +} + +// HitGroupChestEQ applies the EQ predicate on the "hit_group_chest" field. +func HitGroupChestEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldHitGroupChest), v)) + }) +} + +// HitGroupChestNEQ applies the NEQ predicate on the "hit_group_chest" field. +func HitGroupChestNEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldHitGroupChest), v)) + }) +} + +// HitGroupChestIn applies the In predicate on the "hit_group_chest" field. +func HitGroupChestIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldHitGroupChest), v...)) + }) +} + +// HitGroupChestNotIn applies the NotIn predicate on the "hit_group_chest" field. +func HitGroupChestNotIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldHitGroupChest), v...)) + }) +} + +// HitGroupChestGT applies the GT predicate on the "hit_group_chest" field. +func HitGroupChestGT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldHitGroupChest), v)) + }) +} + +// HitGroupChestGTE applies the GTE predicate on the "hit_group_chest" field. +func HitGroupChestGTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldHitGroupChest), v)) + }) +} + +// HitGroupChestLT applies the LT predicate on the "hit_group_chest" field. +func HitGroupChestLT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldHitGroupChest), v)) + }) +} + +// HitGroupChestLTE applies the LTE predicate on the "hit_group_chest" field. +func HitGroupChestLTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldHitGroupChest), v)) + }) +} + +// HitGroupChestIsNil applies the IsNil predicate on the "hit_group_chest" field. +func HitGroupChestIsNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldHitGroupChest))) + }) +} + +// HitGroupChestNotNil applies the NotNil predicate on the "hit_group_chest" field. +func HitGroupChestNotNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldHitGroupChest))) + }) +} + +// HitGroupStomachEQ applies the EQ predicate on the "hit_group_stomach" field. +func HitGroupStomachEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldHitGroupStomach), v)) + }) +} + +// HitGroupStomachNEQ applies the NEQ predicate on the "hit_group_stomach" field. +func HitGroupStomachNEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldHitGroupStomach), v)) + }) +} + +// HitGroupStomachIn applies the In predicate on the "hit_group_stomach" field. +func HitGroupStomachIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldHitGroupStomach), v...)) + }) +} + +// HitGroupStomachNotIn applies the NotIn predicate on the "hit_group_stomach" field. +func HitGroupStomachNotIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldHitGroupStomach), v...)) + }) +} + +// HitGroupStomachGT applies the GT predicate on the "hit_group_stomach" field. +func HitGroupStomachGT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldHitGroupStomach), v)) + }) +} + +// HitGroupStomachGTE applies the GTE predicate on the "hit_group_stomach" field. +func HitGroupStomachGTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldHitGroupStomach), v)) + }) +} + +// HitGroupStomachLT applies the LT predicate on the "hit_group_stomach" field. +func HitGroupStomachLT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldHitGroupStomach), v)) + }) +} + +// HitGroupStomachLTE applies the LTE predicate on the "hit_group_stomach" field. +func HitGroupStomachLTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldHitGroupStomach), v)) + }) +} + +// HitGroupStomachIsNil applies the IsNil predicate on the "hit_group_stomach" field. +func HitGroupStomachIsNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldHitGroupStomach))) + }) +} + +// HitGroupStomachNotNil applies the NotNil predicate on the "hit_group_stomach" field. +func HitGroupStomachNotNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldHitGroupStomach))) + }) +} + +// HitGroupLeftArmEQ applies the EQ predicate on the "hit_group_left_arm" field. +func HitGroupLeftArmEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldHitGroupLeftArm), v)) + }) +} + +// HitGroupLeftArmNEQ applies the NEQ predicate on the "hit_group_left_arm" field. +func HitGroupLeftArmNEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldHitGroupLeftArm), v)) + }) +} + +// HitGroupLeftArmIn applies the In predicate on the "hit_group_left_arm" field. +func HitGroupLeftArmIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldHitGroupLeftArm), v...)) + }) +} + +// HitGroupLeftArmNotIn applies the NotIn predicate on the "hit_group_left_arm" field. +func HitGroupLeftArmNotIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldHitGroupLeftArm), v...)) + }) +} + +// HitGroupLeftArmGT applies the GT predicate on the "hit_group_left_arm" field. +func HitGroupLeftArmGT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldHitGroupLeftArm), v)) + }) +} + +// HitGroupLeftArmGTE applies the GTE predicate on the "hit_group_left_arm" field. +func HitGroupLeftArmGTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldHitGroupLeftArm), v)) + }) +} + +// HitGroupLeftArmLT applies the LT predicate on the "hit_group_left_arm" field. +func HitGroupLeftArmLT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldHitGroupLeftArm), v)) + }) +} + +// HitGroupLeftArmLTE applies the LTE predicate on the "hit_group_left_arm" field. +func HitGroupLeftArmLTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldHitGroupLeftArm), v)) + }) +} + +// HitGroupLeftArmIsNil applies the IsNil predicate on the "hit_group_left_arm" field. +func HitGroupLeftArmIsNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldHitGroupLeftArm))) + }) +} + +// HitGroupLeftArmNotNil applies the NotNil predicate on the "hit_group_left_arm" field. +func HitGroupLeftArmNotNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldHitGroupLeftArm))) + }) +} + +// HitGroupRightArmEQ applies the EQ predicate on the "hit_group_right_arm" field. +func HitGroupRightArmEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldHitGroupRightArm), v)) + }) +} + +// HitGroupRightArmNEQ applies the NEQ predicate on the "hit_group_right_arm" field. +func HitGroupRightArmNEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldHitGroupRightArm), v)) + }) +} + +// HitGroupRightArmIn applies the In predicate on the "hit_group_right_arm" field. +func HitGroupRightArmIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldHitGroupRightArm), v...)) + }) +} + +// HitGroupRightArmNotIn applies the NotIn predicate on the "hit_group_right_arm" field. +func HitGroupRightArmNotIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldHitGroupRightArm), v...)) + }) +} + +// HitGroupRightArmGT applies the GT predicate on the "hit_group_right_arm" field. +func HitGroupRightArmGT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldHitGroupRightArm), v)) + }) +} + +// HitGroupRightArmGTE applies the GTE predicate on the "hit_group_right_arm" field. +func HitGroupRightArmGTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldHitGroupRightArm), v)) + }) +} + +// HitGroupRightArmLT applies the LT predicate on the "hit_group_right_arm" field. +func HitGroupRightArmLT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldHitGroupRightArm), v)) + }) +} + +// HitGroupRightArmLTE applies the LTE predicate on the "hit_group_right_arm" field. +func HitGroupRightArmLTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldHitGroupRightArm), v)) + }) +} + +// HitGroupRightArmIsNil applies the IsNil predicate on the "hit_group_right_arm" field. +func HitGroupRightArmIsNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldHitGroupRightArm))) + }) +} + +// HitGroupRightArmNotNil applies the NotNil predicate on the "hit_group_right_arm" field. +func HitGroupRightArmNotNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldHitGroupRightArm))) + }) +} + +// HitGroupLeftLegEQ applies the EQ predicate on the "hit_group_left_leg" field. +func HitGroupLeftLegEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldHitGroupLeftLeg), v)) + }) +} + +// HitGroupLeftLegNEQ applies the NEQ predicate on the "hit_group_left_leg" field. +func HitGroupLeftLegNEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldHitGroupLeftLeg), v)) + }) +} + +// HitGroupLeftLegIn applies the In predicate on the "hit_group_left_leg" field. +func HitGroupLeftLegIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldHitGroupLeftLeg), v...)) + }) +} + +// HitGroupLeftLegNotIn applies the NotIn predicate on the "hit_group_left_leg" field. +func HitGroupLeftLegNotIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldHitGroupLeftLeg), v...)) + }) +} + +// HitGroupLeftLegGT applies the GT predicate on the "hit_group_left_leg" field. +func HitGroupLeftLegGT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldHitGroupLeftLeg), v)) + }) +} + +// HitGroupLeftLegGTE applies the GTE predicate on the "hit_group_left_leg" field. +func HitGroupLeftLegGTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldHitGroupLeftLeg), v)) + }) +} + +// HitGroupLeftLegLT applies the LT predicate on the "hit_group_left_leg" field. +func HitGroupLeftLegLT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldHitGroupLeftLeg), v)) + }) +} + +// HitGroupLeftLegLTE applies the LTE predicate on the "hit_group_left_leg" field. +func HitGroupLeftLegLTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldHitGroupLeftLeg), v)) + }) +} + +// HitGroupLeftLegIsNil applies the IsNil predicate on the "hit_group_left_leg" field. +func HitGroupLeftLegIsNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldHitGroupLeftLeg))) + }) +} + +// HitGroupLeftLegNotNil applies the NotNil predicate on the "hit_group_left_leg" field. +func HitGroupLeftLegNotNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldHitGroupLeftLeg))) + }) +} + +// HitGroupRightLegEQ applies the EQ predicate on the "hit_group_right_leg" field. +func HitGroupRightLegEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldHitGroupRightLeg), v)) + }) +} + +// HitGroupRightLegNEQ applies the NEQ predicate on the "hit_group_right_leg" field. +func HitGroupRightLegNEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldHitGroupRightLeg), v)) + }) +} + +// HitGroupRightLegIn applies the In predicate on the "hit_group_right_leg" field. +func HitGroupRightLegIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldHitGroupRightLeg), v...)) + }) +} + +// HitGroupRightLegNotIn applies the NotIn predicate on the "hit_group_right_leg" field. +func HitGroupRightLegNotIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldHitGroupRightLeg), v...)) + }) +} + +// HitGroupRightLegGT applies the GT predicate on the "hit_group_right_leg" field. +func HitGroupRightLegGT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldHitGroupRightLeg), v)) + }) +} + +// HitGroupRightLegGTE applies the GTE predicate on the "hit_group_right_leg" field. +func HitGroupRightLegGTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldHitGroupRightLeg), v)) + }) +} + +// HitGroupRightLegLT applies the LT predicate on the "hit_group_right_leg" field. +func HitGroupRightLegLT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldHitGroupRightLeg), v)) + }) +} + +// HitGroupRightLegLTE applies the LTE predicate on the "hit_group_right_leg" field. +func HitGroupRightLegLTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldHitGroupRightLeg), v)) + }) +} + +// HitGroupRightLegIsNil applies the IsNil predicate on the "hit_group_right_leg" field. +func HitGroupRightLegIsNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldHitGroupRightLeg))) + }) +} + +// HitGroupRightLegNotNil applies the NotNil predicate on the "hit_group_right_leg" field. +func HitGroupRightLegNotNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldHitGroupRightLeg))) + }) +} + +// HitGroupGearEQ applies the EQ predicate on the "hit_group_gear" field. +func HitGroupGearEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldHitGroupGear), v)) + }) +} + +// HitGroupGearNEQ applies the NEQ predicate on the "hit_group_gear" field. +func HitGroupGearNEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldHitGroupGear), v)) + }) +} + +// HitGroupGearIn applies the In predicate on the "hit_group_gear" field. +func HitGroupGearIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldHitGroupGear), v...)) + }) +} + +// HitGroupGearNotIn applies the NotIn predicate on the "hit_group_gear" field. +func HitGroupGearNotIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldHitGroupGear), v...)) + }) +} + +// HitGroupGearGT applies the GT predicate on the "hit_group_gear" field. +func HitGroupGearGT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldHitGroupGear), v)) + }) +} + +// HitGroupGearGTE applies the GTE predicate on the "hit_group_gear" field. +func HitGroupGearGTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldHitGroupGear), v)) + }) +} + +// HitGroupGearLT applies the LT predicate on the "hit_group_gear" field. +func HitGroupGearLT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldHitGroupGear), v)) + }) +} + +// HitGroupGearLTE applies the LTE predicate on the "hit_group_gear" field. +func HitGroupGearLTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldHitGroupGear), v)) + }) +} + +// HitGroupGearIsNil applies the IsNil predicate on the "hit_group_gear" field. +func HitGroupGearIsNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldHitGroupGear))) + }) +} + +// HitGroupGearNotNil applies the NotNil predicate on the "hit_group_gear" field. +func HitGroupGearNotNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldHitGroupGear))) + }) +} + +// CrosshairEQ applies the EQ predicate on the "crosshair" field. +func CrosshairEQ(v string) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldCrosshair), v)) + }) +} + +// CrosshairNEQ applies the NEQ predicate on the "crosshair" field. +func CrosshairNEQ(v string) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldCrosshair), v)) + }) +} + +// CrosshairIn applies the In predicate on the "crosshair" field. +func CrosshairIn(vs ...string) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldCrosshair), v...)) + }) +} + +// CrosshairNotIn applies the NotIn predicate on the "crosshair" field. +func CrosshairNotIn(vs ...string) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldCrosshair), v...)) + }) +} + +// CrosshairGT applies the GT predicate on the "crosshair" field. +func CrosshairGT(v string) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldCrosshair), v)) + }) +} + +// CrosshairGTE applies the GTE predicate on the "crosshair" field. +func CrosshairGTE(v string) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldCrosshair), v)) + }) +} + +// CrosshairLT applies the LT predicate on the "crosshair" field. +func CrosshairLT(v string) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldCrosshair), v)) + }) +} + +// CrosshairLTE applies the LTE predicate on the "crosshair" field. +func CrosshairLTE(v string) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldCrosshair), v)) + }) +} + +// CrosshairContains applies the Contains predicate on the "crosshair" field. +func CrosshairContains(v string) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.Contains(s.C(FieldCrosshair), v)) + }) +} + +// CrosshairHasPrefix applies the HasPrefix predicate on the "crosshair" field. +func CrosshairHasPrefix(v string) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.HasPrefix(s.C(FieldCrosshair), v)) + }) +} + +// CrosshairHasSuffix applies the HasSuffix predicate on the "crosshair" field. +func CrosshairHasSuffix(v string) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.HasSuffix(s.C(FieldCrosshair), v)) + }) +} + +// CrosshairIsNil applies the IsNil predicate on the "crosshair" field. +func CrosshairIsNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldCrosshair))) + }) +} + +// CrosshairNotNil applies the NotNil predicate on the "crosshair" field. +func CrosshairNotNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldCrosshair))) + }) +} + +// CrosshairEqualFold applies the EqualFold predicate on the "crosshair" field. +func CrosshairEqualFold(v string) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EqualFold(s.C(FieldCrosshair), v)) + }) +} + +// CrosshairContainsFold applies the ContainsFold predicate on the "crosshair" field. +func CrosshairContainsFold(v string) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.ContainsFold(s.C(FieldCrosshair), v)) + }) +} + +// ColorEQ applies the EQ predicate on the "color" field. +func ColorEQ(v Color) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldColor), v)) + }) +} + +// ColorNEQ applies the NEQ predicate on the "color" field. +func ColorNEQ(v Color) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldColor), v)) + }) +} + +// ColorIn applies the In predicate on the "color" field. +func ColorIn(vs ...Color) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldColor), v...)) + }) +} + +// ColorNotIn applies the NotIn predicate on the "color" field. +func ColorNotIn(vs ...Color) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldColor), v...)) + }) +} + +// ColorIsNil applies the IsNil predicate on the "color" field. +func ColorIsNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldColor))) + }) +} + +// ColorNotNil applies the NotNil predicate on the "color" field. +func ColorNotNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldColor))) + }) +} + +// KastEQ applies the EQ predicate on the "kast" field. +func KastEQ(v int) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldKast), v)) + }) +} + +// KastNEQ applies the NEQ predicate on the "kast" field. +func KastNEQ(v int) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldKast), v)) + }) +} + +// KastIn applies the In predicate on the "kast" field. +func KastIn(vs ...int) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldKast), v...)) + }) +} + +// KastNotIn applies the NotIn predicate on the "kast" field. +func KastNotIn(vs ...int) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldKast), v...)) + }) +} + +// KastGT applies the GT predicate on the "kast" field. +func KastGT(v int) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldKast), v)) + }) +} + +// KastGTE applies the GTE predicate on the "kast" field. +func KastGTE(v int) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldKast), v)) + }) +} + +// KastLT applies the LT predicate on the "kast" field. +func KastLT(v int) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldKast), v)) + }) +} + +// KastLTE applies the LTE predicate on the "kast" field. +func KastLTE(v int) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldKast), v)) + }) +} + +// KastIsNil applies the IsNil predicate on the "kast" field. +func KastIsNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldKast))) + }) +} + +// KastNotNil applies the NotNil predicate on the "kast" field. +func KastNotNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldKast))) + }) +} + +// FlashDurationSelfEQ applies the EQ predicate on the "flash_duration_self" field. +func FlashDurationSelfEQ(v float32) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldFlashDurationSelf), v)) + }) +} + +// FlashDurationSelfNEQ applies the NEQ predicate on the "flash_duration_self" field. +func FlashDurationSelfNEQ(v float32) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldFlashDurationSelf), v)) + }) +} + +// FlashDurationSelfIn applies the In predicate on the "flash_duration_self" field. +func FlashDurationSelfIn(vs ...float32) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldFlashDurationSelf), v...)) + }) +} + +// FlashDurationSelfNotIn applies the NotIn predicate on the "flash_duration_self" field. +func FlashDurationSelfNotIn(vs ...float32) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldFlashDurationSelf), v...)) + }) +} + +// FlashDurationSelfGT applies the GT predicate on the "flash_duration_self" field. +func FlashDurationSelfGT(v float32) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldFlashDurationSelf), v)) + }) +} + +// FlashDurationSelfGTE applies the GTE predicate on the "flash_duration_self" field. +func FlashDurationSelfGTE(v float32) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldFlashDurationSelf), v)) + }) +} + +// FlashDurationSelfLT applies the LT predicate on the "flash_duration_self" field. +func FlashDurationSelfLT(v float32) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldFlashDurationSelf), v)) + }) +} + +// FlashDurationSelfLTE applies the LTE predicate on the "flash_duration_self" field. +func FlashDurationSelfLTE(v float32) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldFlashDurationSelf), v)) + }) +} + +// FlashDurationSelfIsNil applies the IsNil predicate on the "flash_duration_self" field. +func FlashDurationSelfIsNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldFlashDurationSelf))) + }) +} + +// FlashDurationSelfNotNil applies the NotNil predicate on the "flash_duration_self" field. +func FlashDurationSelfNotNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldFlashDurationSelf))) + }) +} + +// FlashDurationTeamEQ applies the EQ predicate on the "flash_duration_team" field. +func FlashDurationTeamEQ(v float32) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldFlashDurationTeam), v)) + }) +} + +// FlashDurationTeamNEQ applies the NEQ predicate on the "flash_duration_team" field. +func FlashDurationTeamNEQ(v float32) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldFlashDurationTeam), v)) + }) +} + +// FlashDurationTeamIn applies the In predicate on the "flash_duration_team" field. +func FlashDurationTeamIn(vs ...float32) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldFlashDurationTeam), v...)) + }) +} + +// FlashDurationTeamNotIn applies the NotIn predicate on the "flash_duration_team" field. +func FlashDurationTeamNotIn(vs ...float32) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldFlashDurationTeam), v...)) + }) +} + +// FlashDurationTeamGT applies the GT predicate on the "flash_duration_team" field. +func FlashDurationTeamGT(v float32) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldFlashDurationTeam), v)) + }) +} + +// FlashDurationTeamGTE applies the GTE predicate on the "flash_duration_team" field. +func FlashDurationTeamGTE(v float32) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldFlashDurationTeam), v)) + }) +} + +// FlashDurationTeamLT applies the LT predicate on the "flash_duration_team" field. +func FlashDurationTeamLT(v float32) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldFlashDurationTeam), v)) + }) +} + +// FlashDurationTeamLTE applies the LTE predicate on the "flash_duration_team" field. +func FlashDurationTeamLTE(v float32) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldFlashDurationTeam), v)) + }) +} + +// FlashDurationTeamIsNil applies the IsNil predicate on the "flash_duration_team" field. +func FlashDurationTeamIsNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldFlashDurationTeam))) + }) +} + +// FlashDurationTeamNotNil applies the NotNil predicate on the "flash_duration_team" field. +func FlashDurationTeamNotNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldFlashDurationTeam))) + }) +} + +// FlashDurationEnemyEQ applies the EQ predicate on the "flash_duration_enemy" field. +func FlashDurationEnemyEQ(v float32) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldFlashDurationEnemy), v)) + }) +} + +// FlashDurationEnemyNEQ applies the NEQ predicate on the "flash_duration_enemy" field. +func FlashDurationEnemyNEQ(v float32) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldFlashDurationEnemy), v)) + }) +} + +// FlashDurationEnemyIn applies the In predicate on the "flash_duration_enemy" field. +func FlashDurationEnemyIn(vs ...float32) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldFlashDurationEnemy), v...)) + }) +} + +// FlashDurationEnemyNotIn applies the NotIn predicate on the "flash_duration_enemy" field. +func FlashDurationEnemyNotIn(vs ...float32) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldFlashDurationEnemy), v...)) + }) +} + +// FlashDurationEnemyGT applies the GT predicate on the "flash_duration_enemy" field. +func FlashDurationEnemyGT(v float32) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldFlashDurationEnemy), v)) + }) +} + +// FlashDurationEnemyGTE applies the GTE predicate on the "flash_duration_enemy" field. +func FlashDurationEnemyGTE(v float32) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldFlashDurationEnemy), v)) + }) +} + +// FlashDurationEnemyLT applies the LT predicate on the "flash_duration_enemy" field. +func FlashDurationEnemyLT(v float32) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldFlashDurationEnemy), v)) + }) +} + +// FlashDurationEnemyLTE applies the LTE predicate on the "flash_duration_enemy" field. +func FlashDurationEnemyLTE(v float32) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldFlashDurationEnemy), v)) + }) +} + +// FlashDurationEnemyIsNil applies the IsNil predicate on the "flash_duration_enemy" field. +func FlashDurationEnemyIsNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldFlashDurationEnemy))) + }) +} + +// FlashDurationEnemyNotNil applies the NotNil predicate on the "flash_duration_enemy" field. +func FlashDurationEnemyNotNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldFlashDurationEnemy))) + }) +} + +// FlashTotalSelfEQ applies the EQ predicate on the "flash_total_self" field. +func FlashTotalSelfEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldFlashTotalSelf), v)) + }) +} + +// FlashTotalSelfNEQ applies the NEQ predicate on the "flash_total_self" field. +func FlashTotalSelfNEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldFlashTotalSelf), v)) + }) +} + +// FlashTotalSelfIn applies the In predicate on the "flash_total_self" field. +func FlashTotalSelfIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldFlashTotalSelf), v...)) + }) +} + +// FlashTotalSelfNotIn applies the NotIn predicate on the "flash_total_self" field. +func FlashTotalSelfNotIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldFlashTotalSelf), v...)) + }) +} + +// FlashTotalSelfGT applies the GT predicate on the "flash_total_self" field. +func FlashTotalSelfGT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldFlashTotalSelf), v)) + }) +} + +// FlashTotalSelfGTE applies the GTE predicate on the "flash_total_self" field. +func FlashTotalSelfGTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldFlashTotalSelf), v)) + }) +} + +// FlashTotalSelfLT applies the LT predicate on the "flash_total_self" field. +func FlashTotalSelfLT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldFlashTotalSelf), v)) + }) +} + +// FlashTotalSelfLTE applies the LTE predicate on the "flash_total_self" field. +func FlashTotalSelfLTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldFlashTotalSelf), v)) + }) +} + +// FlashTotalSelfIsNil applies the IsNil predicate on the "flash_total_self" field. +func FlashTotalSelfIsNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldFlashTotalSelf))) + }) +} + +// FlashTotalSelfNotNil applies the NotNil predicate on the "flash_total_self" field. +func FlashTotalSelfNotNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldFlashTotalSelf))) + }) +} + +// FlashTotalTeamEQ applies the EQ predicate on the "flash_total_team" field. +func FlashTotalTeamEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldFlashTotalTeam), v)) + }) +} + +// FlashTotalTeamNEQ applies the NEQ predicate on the "flash_total_team" field. +func FlashTotalTeamNEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldFlashTotalTeam), v)) + }) +} + +// FlashTotalTeamIn applies the In predicate on the "flash_total_team" field. +func FlashTotalTeamIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldFlashTotalTeam), v...)) + }) +} + +// FlashTotalTeamNotIn applies the NotIn predicate on the "flash_total_team" field. +func FlashTotalTeamNotIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldFlashTotalTeam), v...)) + }) +} + +// FlashTotalTeamGT applies the GT predicate on the "flash_total_team" field. +func FlashTotalTeamGT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldFlashTotalTeam), v)) + }) +} + +// FlashTotalTeamGTE applies the GTE predicate on the "flash_total_team" field. +func FlashTotalTeamGTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldFlashTotalTeam), v)) + }) +} + +// FlashTotalTeamLT applies the LT predicate on the "flash_total_team" field. +func FlashTotalTeamLT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldFlashTotalTeam), v)) + }) +} + +// FlashTotalTeamLTE applies the LTE predicate on the "flash_total_team" field. +func FlashTotalTeamLTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldFlashTotalTeam), v)) + }) +} + +// FlashTotalTeamIsNil applies the IsNil predicate on the "flash_total_team" field. +func FlashTotalTeamIsNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldFlashTotalTeam))) + }) +} + +// FlashTotalTeamNotNil applies the NotNil predicate on the "flash_total_team" field. +func FlashTotalTeamNotNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldFlashTotalTeam))) + }) +} + +// FlashTotalEnemyEQ applies the EQ predicate on the "flash_total_enemy" field. +func FlashTotalEnemyEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldFlashTotalEnemy), v)) + }) +} + +// FlashTotalEnemyNEQ applies the NEQ predicate on the "flash_total_enemy" field. +func FlashTotalEnemyNEQ(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldFlashTotalEnemy), v)) + }) +} + +// FlashTotalEnemyIn applies the In predicate on the "flash_total_enemy" field. +func FlashTotalEnemyIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldFlashTotalEnemy), v...)) + }) +} + +// FlashTotalEnemyNotIn applies the NotIn predicate on the "flash_total_enemy" field. +func FlashTotalEnemyNotIn(vs ...uint) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldFlashTotalEnemy), v...)) + }) +} + +// FlashTotalEnemyGT applies the GT predicate on the "flash_total_enemy" field. +func FlashTotalEnemyGT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldFlashTotalEnemy), v)) + }) +} + +// FlashTotalEnemyGTE applies the GTE predicate on the "flash_total_enemy" field. +func FlashTotalEnemyGTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldFlashTotalEnemy), v)) + }) +} + +// FlashTotalEnemyLT applies the LT predicate on the "flash_total_enemy" field. +func FlashTotalEnemyLT(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldFlashTotalEnemy), v)) + }) +} + +// FlashTotalEnemyLTE applies the LTE predicate on the "flash_total_enemy" field. +func FlashTotalEnemyLTE(v uint) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldFlashTotalEnemy), v)) + }) +} + +// FlashTotalEnemyIsNil applies the IsNil predicate on the "flash_total_enemy" field. +func FlashTotalEnemyIsNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldFlashTotalEnemy))) + }) +} + +// FlashTotalEnemyNotNil applies the NotNil predicate on the "flash_total_enemy" field. +func FlashTotalEnemyNotNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldFlashTotalEnemy))) + }) +} + +// MatchStatsEQ applies the EQ predicate on the "match_stats" field. +func MatchStatsEQ(v uint64) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldMatchStats), v)) + }) +} + +// MatchStatsNEQ applies the NEQ predicate on the "match_stats" field. +func MatchStatsNEQ(v uint64) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldMatchStats), v)) + }) +} + +// MatchStatsIn applies the In predicate on the "match_stats" field. +func MatchStatsIn(vs ...uint64) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldMatchStats), v...)) + }) +} + +// MatchStatsNotIn applies the NotIn predicate on the "match_stats" field. +func MatchStatsNotIn(vs ...uint64) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldMatchStats), v...)) + }) +} + +// MatchStatsIsNil applies the IsNil predicate on the "match_stats" field. +func MatchStatsIsNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldMatchStats))) + }) +} + +// MatchStatsNotNil applies the NotNil predicate on the "match_stats" field. +func MatchStatsNotNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldMatchStats))) + }) +} + +// PlayerStatsEQ applies the EQ predicate on the "player_stats" field. +func PlayerStatsEQ(v uint64) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldPlayerStats), v)) + }) +} + +// PlayerStatsNEQ applies the NEQ predicate on the "player_stats" field. +func PlayerStatsNEQ(v uint64) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldPlayerStats), v)) + }) +} + +// PlayerStatsIn applies the In predicate on the "player_stats" field. +func PlayerStatsIn(vs ...uint64) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldPlayerStats), v...)) + }) +} + +// PlayerStatsNotIn applies the NotIn predicate on the "player_stats" field. +func PlayerStatsNotIn(vs ...uint64) predicate.Stats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Stats(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(FieldPlayerStats), v...)) + }) +} + +// PlayerStatsIsNil applies the IsNil predicate on the "player_stats" field. +func PlayerStatsIsNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldPlayerStats))) + }) +} + +// PlayerStatsNotNil applies the NotNil predicate on the "player_stats" field. +func PlayerStatsNotNil() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldPlayerStats))) }) } @@ -743,6 +3777,34 @@ func HasPlayersWith(preds ...predicate.Player) predicate.Stats { }) } +// HasWeaponStats applies the HasEdge predicate on the "weapon_stats" edge. +func HasWeaponStats() predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(WeaponStatsTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, WeaponStatsTable, WeaponStatsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasWeaponStatsWith applies the HasEdge predicate on the "weapon_stats" edge with a given conditions (other predicates). +func HasWeaponStatsWith(preds ...predicate.WeaponStats) predicate.Stats { + return predicate.Stats(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(WeaponStatsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, WeaponStatsTable, WeaponStatsColumn), + ) + 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.Stats) predicate.Stats { return predicate.Stats(func(s *sql.Selector) { diff --git a/ent/stats_create.go b/ent/stats_create.go index 5955f04..a71104b 100644 --- a/ent/stats_create.go +++ b/ent/stats_create.go @@ -7,6 +7,7 @@ import ( "csgowtfd/ent/match" "csgowtfd/ent/player" "csgowtfd/ent/stats" + "csgowtfd/ent/weaponstats" "errors" "fmt" @@ -52,8 +53,8 @@ func (sc *StatsCreate) SetHeadshot(i int) *StatsCreate { } // SetMvp sets the "mvp" field. -func (sc *StatsCreate) SetMvp(i int) *StatsCreate { - sc.mutation.SetMvp(i) +func (sc *StatsCreate) SetMvp(u uint) *StatsCreate { + sc.mutation.SetMvp(u) return sc } @@ -63,110 +64,450 @@ func (sc *StatsCreate) SetScore(i int) *StatsCreate { return sc } -// SetExtended sets the "extended" field. -func (sc *StatsCreate) SetExtended(skkgaaaallllg struct { - MultiKills struct { - Duo int "json:\"duo,omitempty\"" - Triple int "json:\"triple,omitempty\"" - Quad int "json:\"quad,omitempty\"" - Pent int "json:\"pent,omitempty\"" - } "json:\"multi_kills,omitempty\"" - Dmg struct { - Enemy int "json:\"enemy,omitempty\"" - Team int "json:\"team,omitempty\"" - UD struct { - HE int "json:\"he,omitempty\"" - Flames int "json:\"flames,omitempty\"" - Flash int "json:\"flash,omitempty\"" - Decoy int "json:\"decoy,omitempty\"" - Smoke int "json:\"smoke,omitempty\"" - } "json:\"ud,omitempty\"" - HitGroup struct { - Head int "json:\"head,omitempty\"" - Chest int "json:\"chest,omitempty\"" - Stomach int "json:\"stomach,omitempty\"" - LeftArm int "json:\"left_arm,omitempty\"" - RightArm int "json:\"right_arm,omitempty\"" - LeftLeg int "json:\"left_leg,omitempty\"" - RightLeg int "json:\"right_leg,omitempty\"" - Gear int "json:\"gear,omitempty\"" - } "json:\"hit_group,omitempty\"" - } "json:\"dmg,omitempty\"" - Crosshair string "json:\"crosshair,omitempty\"" - Color string "json:\"color,omitempty\"" - KAST int "json:\"kast,omitempty\"" - Rank struct { - Old int "json:\"old,omitempty\"" - New int "json:\"new,omitempty\"" - } "json:\"rank,omitempty\"" - Flash struct { - Duration struct { - Self float32 "json:\"self,omitempty\"" - Team float32 "json:\"team,omitempty\"" - Enemy float32 "json:\"enemy,omitempty\"" - } "json:\"duration,omitempty\"" - Total struct { - Team int "json:\"team,omitempty\"" - Enemy int "json:\"enemy,omitempty\"" - Self int "json:\"self,omitempty\"" - } "json:\"total,omitempty\"" - } "json:\"flash,omitempty\"" -}) *StatsCreate { - sc.mutation.SetExtended(skkgaaaallllg) +// SetRankNew sets the "rank_new" field. +func (sc *StatsCreate) SetRankNew(i int) *StatsCreate { + sc.mutation.SetRankNew(i) return sc } -// SetNillableExtended sets the "extended" field if the given value is not nil. -func (sc *StatsCreate) SetNillableExtended(skkgaaaallllg *struct { - MultiKills struct { - Duo int "json:\"duo,omitempty\"" - Triple int "json:\"triple,omitempty\"" - Quad int "json:\"quad,omitempty\"" - Pent int "json:\"pent,omitempty\"" - } "json:\"multi_kills,omitempty\"" - Dmg struct { - Enemy int "json:\"enemy,omitempty\"" - Team int "json:\"team,omitempty\"" - UD struct { - HE int "json:\"he,omitempty\"" - Flames int "json:\"flames,omitempty\"" - Flash int "json:\"flash,omitempty\"" - Decoy int "json:\"decoy,omitempty\"" - Smoke int "json:\"smoke,omitempty\"" - } "json:\"ud,omitempty\"" - HitGroup struct { - Head int "json:\"head,omitempty\"" - Chest int "json:\"chest,omitempty\"" - Stomach int "json:\"stomach,omitempty\"" - LeftArm int "json:\"left_arm,omitempty\"" - RightArm int "json:\"right_arm,omitempty\"" - LeftLeg int "json:\"left_leg,omitempty\"" - RightLeg int "json:\"right_leg,omitempty\"" - Gear int "json:\"gear,omitempty\"" - } "json:\"hit_group,omitempty\"" - } "json:\"dmg,omitempty\"" - Crosshair string "json:\"crosshair,omitempty\"" - Color string "json:\"color,omitempty\"" - KAST int "json:\"kast,omitempty\"" - Rank struct { - Old int "json:\"old,omitempty\"" - New int "json:\"new,omitempty\"" - } "json:\"rank,omitempty\"" - Flash struct { - Duration struct { - Self float32 "json:\"self,omitempty\"" - Team float32 "json:\"team,omitempty\"" - Enemy float32 "json:\"enemy,omitempty\"" - } "json:\"duration,omitempty\"" - Total struct { - Team int "json:\"team,omitempty\"" - Enemy int "json:\"enemy,omitempty\"" - Self int "json:\"self,omitempty\"" - } "json:\"total,omitempty\"" - } "json:\"flash,omitempty\"" -}) *StatsCreate { - if skkgaaaallllg != nil { - sc.SetExtended(*skkgaaaallllg) +// SetNillableRankNew sets the "rank_new" field if the given value is not nil. +func (sc *StatsCreate) SetNillableRankNew(i *int) *StatsCreate { + if i != nil { + sc.SetRankNew(*i) + } + return sc +} + +// SetRankOld sets the "rank_old" field. +func (sc *StatsCreate) SetRankOld(i int) *StatsCreate { + sc.mutation.SetRankOld(i) + return sc +} + +// SetNillableRankOld sets the "rank_old" field if the given value is not nil. +func (sc *StatsCreate) SetNillableRankOld(i *int) *StatsCreate { + if i != nil { + sc.SetRankOld(*i) + } + return sc +} + +// SetMk2 sets the "mk_2" field. +func (sc *StatsCreate) SetMk2(u uint) *StatsCreate { + sc.mutation.SetMk2(u) + return sc +} + +// SetNillableMk2 sets the "mk_2" field if the given value is not nil. +func (sc *StatsCreate) SetNillableMk2(u *uint) *StatsCreate { + if u != nil { + sc.SetMk2(*u) + } + return sc +} + +// SetMk3 sets the "mk_3" field. +func (sc *StatsCreate) SetMk3(u uint) *StatsCreate { + sc.mutation.SetMk3(u) + return sc +} + +// SetNillableMk3 sets the "mk_3" field if the given value is not nil. +func (sc *StatsCreate) SetNillableMk3(u *uint) *StatsCreate { + if u != nil { + sc.SetMk3(*u) + } + return sc +} + +// SetMk4 sets the "mk_4" field. +func (sc *StatsCreate) SetMk4(u uint) *StatsCreate { + sc.mutation.SetMk4(u) + return sc +} + +// SetNillableMk4 sets the "mk_4" field if the given value is not nil. +func (sc *StatsCreate) SetNillableMk4(u *uint) *StatsCreate { + if u != nil { + sc.SetMk4(*u) + } + return sc +} + +// SetMk5 sets the "mk_5" field. +func (sc *StatsCreate) SetMk5(u uint) *StatsCreate { + sc.mutation.SetMk5(u) + return sc +} + +// SetNillableMk5 sets the "mk_5" field if the given value is not nil. +func (sc *StatsCreate) SetNillableMk5(u *uint) *StatsCreate { + if u != nil { + sc.SetMk5(*u) + } + return sc +} + +// SetDmgEnemy sets the "dmg_enemy" field. +func (sc *StatsCreate) SetDmgEnemy(u uint) *StatsCreate { + sc.mutation.SetDmgEnemy(u) + return sc +} + +// SetNillableDmgEnemy sets the "dmg_enemy" field if the given value is not nil. +func (sc *StatsCreate) SetNillableDmgEnemy(u *uint) *StatsCreate { + if u != nil { + sc.SetDmgEnemy(*u) + } + return sc +} + +// SetDmgTeam sets the "dmg_team" field. +func (sc *StatsCreate) SetDmgTeam(u uint) *StatsCreate { + sc.mutation.SetDmgTeam(u) + return sc +} + +// SetNillableDmgTeam sets the "dmg_team" field if the given value is not nil. +func (sc *StatsCreate) SetNillableDmgTeam(u *uint) *StatsCreate { + if u != nil { + sc.SetDmgTeam(*u) + } + return sc +} + +// SetUdHe sets the "ud_he" field. +func (sc *StatsCreate) SetUdHe(u uint) *StatsCreate { + sc.mutation.SetUdHe(u) + return sc +} + +// SetNillableUdHe sets the "ud_he" field if the given value is not nil. +func (sc *StatsCreate) SetNillableUdHe(u *uint) *StatsCreate { + if u != nil { + sc.SetUdHe(*u) + } + return sc +} + +// SetUdFlames sets the "ud_flames" field. +func (sc *StatsCreate) SetUdFlames(u uint) *StatsCreate { + sc.mutation.SetUdFlames(u) + return sc +} + +// SetNillableUdFlames sets the "ud_flames" field if the given value is not nil. +func (sc *StatsCreate) SetNillableUdFlames(u *uint) *StatsCreate { + if u != nil { + sc.SetUdFlames(*u) + } + return sc +} + +// SetUdFlash sets the "ud_flash" field. +func (sc *StatsCreate) SetUdFlash(u uint) *StatsCreate { + sc.mutation.SetUdFlash(u) + return sc +} + +// SetNillableUdFlash sets the "ud_flash" field if the given value is not nil. +func (sc *StatsCreate) SetNillableUdFlash(u *uint) *StatsCreate { + if u != nil { + sc.SetUdFlash(*u) + } + return sc +} + +// SetUdDecoy sets the "ud_decoy" field. +func (sc *StatsCreate) SetUdDecoy(u uint) *StatsCreate { + sc.mutation.SetUdDecoy(u) + return sc +} + +// SetNillableUdDecoy sets the "ud_decoy" field if the given value is not nil. +func (sc *StatsCreate) SetNillableUdDecoy(u *uint) *StatsCreate { + if u != nil { + sc.SetUdDecoy(*u) + } + return sc +} + +// SetUdSmoke sets the "ud_smoke" field. +func (sc *StatsCreate) SetUdSmoke(u uint) *StatsCreate { + sc.mutation.SetUdSmoke(u) + return sc +} + +// SetNillableUdSmoke sets the "ud_smoke" field if the given value is not nil. +func (sc *StatsCreate) SetNillableUdSmoke(u *uint) *StatsCreate { + if u != nil { + sc.SetUdSmoke(*u) + } + return sc +} + +// SetHitGroupHead sets the "hit_group_head" field. +func (sc *StatsCreate) SetHitGroupHead(u uint) *StatsCreate { + sc.mutation.SetHitGroupHead(u) + return sc +} + +// SetNillableHitGroupHead sets the "hit_group_head" field if the given value is not nil. +func (sc *StatsCreate) SetNillableHitGroupHead(u *uint) *StatsCreate { + if u != nil { + sc.SetHitGroupHead(*u) + } + return sc +} + +// SetHitGroupChest sets the "hit_group_chest" field. +func (sc *StatsCreate) SetHitGroupChest(u uint) *StatsCreate { + sc.mutation.SetHitGroupChest(u) + return sc +} + +// SetNillableHitGroupChest sets the "hit_group_chest" field if the given value is not nil. +func (sc *StatsCreate) SetNillableHitGroupChest(u *uint) *StatsCreate { + if u != nil { + sc.SetHitGroupChest(*u) + } + return sc +} + +// SetHitGroupStomach sets the "hit_group_stomach" field. +func (sc *StatsCreate) SetHitGroupStomach(u uint) *StatsCreate { + sc.mutation.SetHitGroupStomach(u) + return sc +} + +// SetNillableHitGroupStomach sets the "hit_group_stomach" field if the given value is not nil. +func (sc *StatsCreate) SetNillableHitGroupStomach(u *uint) *StatsCreate { + if u != nil { + sc.SetHitGroupStomach(*u) + } + return sc +} + +// SetHitGroupLeftArm sets the "hit_group_left_arm" field. +func (sc *StatsCreate) SetHitGroupLeftArm(u uint) *StatsCreate { + sc.mutation.SetHitGroupLeftArm(u) + return sc +} + +// SetNillableHitGroupLeftArm sets the "hit_group_left_arm" field if the given value is not nil. +func (sc *StatsCreate) SetNillableHitGroupLeftArm(u *uint) *StatsCreate { + if u != nil { + sc.SetHitGroupLeftArm(*u) + } + return sc +} + +// SetHitGroupRightArm sets the "hit_group_right_arm" field. +func (sc *StatsCreate) SetHitGroupRightArm(u uint) *StatsCreate { + sc.mutation.SetHitGroupRightArm(u) + return sc +} + +// SetNillableHitGroupRightArm sets the "hit_group_right_arm" field if the given value is not nil. +func (sc *StatsCreate) SetNillableHitGroupRightArm(u *uint) *StatsCreate { + if u != nil { + sc.SetHitGroupRightArm(*u) + } + return sc +} + +// SetHitGroupLeftLeg sets the "hit_group_left_leg" field. +func (sc *StatsCreate) SetHitGroupLeftLeg(u uint) *StatsCreate { + sc.mutation.SetHitGroupLeftLeg(u) + return sc +} + +// SetNillableHitGroupLeftLeg sets the "hit_group_left_leg" field if the given value is not nil. +func (sc *StatsCreate) SetNillableHitGroupLeftLeg(u *uint) *StatsCreate { + if u != nil { + sc.SetHitGroupLeftLeg(*u) + } + return sc +} + +// SetHitGroupRightLeg sets the "hit_group_right_leg" field. +func (sc *StatsCreate) SetHitGroupRightLeg(u uint) *StatsCreate { + sc.mutation.SetHitGroupRightLeg(u) + return sc +} + +// SetNillableHitGroupRightLeg sets the "hit_group_right_leg" field if the given value is not nil. +func (sc *StatsCreate) SetNillableHitGroupRightLeg(u *uint) *StatsCreate { + if u != nil { + sc.SetHitGroupRightLeg(*u) + } + return sc +} + +// SetHitGroupGear sets the "hit_group_gear" field. +func (sc *StatsCreate) SetHitGroupGear(u uint) *StatsCreate { + sc.mutation.SetHitGroupGear(u) + return sc +} + +// SetNillableHitGroupGear sets the "hit_group_gear" field if the given value is not nil. +func (sc *StatsCreate) SetNillableHitGroupGear(u *uint) *StatsCreate { + if u != nil { + sc.SetHitGroupGear(*u) + } + return sc +} + +// SetCrosshair sets the "crosshair" field. +func (sc *StatsCreate) SetCrosshair(s string) *StatsCreate { + sc.mutation.SetCrosshair(s) + return sc +} + +// SetNillableCrosshair sets the "crosshair" field if the given value is not nil. +func (sc *StatsCreate) SetNillableCrosshair(s *string) *StatsCreate { + if s != nil { + sc.SetCrosshair(*s) + } + return sc +} + +// SetColor sets the "color" field. +func (sc *StatsCreate) SetColor(s stats.Color) *StatsCreate { + sc.mutation.SetColor(s) + return sc +} + +// SetNillableColor sets the "color" field if the given value is not nil. +func (sc *StatsCreate) SetNillableColor(s *stats.Color) *StatsCreate { + if s != nil { + sc.SetColor(*s) + } + return sc +} + +// SetKast sets the "kast" field. +func (sc *StatsCreate) SetKast(i int) *StatsCreate { + sc.mutation.SetKast(i) + return sc +} + +// SetNillableKast sets the "kast" field if the given value is not nil. +func (sc *StatsCreate) SetNillableKast(i *int) *StatsCreate { + if i != nil { + sc.SetKast(*i) + } + return sc +} + +// SetFlashDurationSelf sets the "flash_duration_self" field. +func (sc *StatsCreate) SetFlashDurationSelf(f float32) *StatsCreate { + sc.mutation.SetFlashDurationSelf(f) + return sc +} + +// SetNillableFlashDurationSelf sets the "flash_duration_self" field if the given value is not nil. +func (sc *StatsCreate) SetNillableFlashDurationSelf(f *float32) *StatsCreate { + if f != nil { + sc.SetFlashDurationSelf(*f) + } + return sc +} + +// SetFlashDurationTeam sets the "flash_duration_team" field. +func (sc *StatsCreate) SetFlashDurationTeam(f float32) *StatsCreate { + sc.mutation.SetFlashDurationTeam(f) + return sc +} + +// SetNillableFlashDurationTeam sets the "flash_duration_team" field if the given value is not nil. +func (sc *StatsCreate) SetNillableFlashDurationTeam(f *float32) *StatsCreate { + if f != nil { + sc.SetFlashDurationTeam(*f) + } + return sc +} + +// SetFlashDurationEnemy sets the "flash_duration_enemy" field. +func (sc *StatsCreate) SetFlashDurationEnemy(f float32) *StatsCreate { + sc.mutation.SetFlashDurationEnemy(f) + return sc +} + +// SetNillableFlashDurationEnemy sets the "flash_duration_enemy" field if the given value is not nil. +func (sc *StatsCreate) SetNillableFlashDurationEnemy(f *float32) *StatsCreate { + if f != nil { + sc.SetFlashDurationEnemy(*f) + } + return sc +} + +// SetFlashTotalSelf sets the "flash_total_self" field. +func (sc *StatsCreate) SetFlashTotalSelf(u uint) *StatsCreate { + sc.mutation.SetFlashTotalSelf(u) + return sc +} + +// SetNillableFlashTotalSelf sets the "flash_total_self" field if the given value is not nil. +func (sc *StatsCreate) SetNillableFlashTotalSelf(u *uint) *StatsCreate { + if u != nil { + sc.SetFlashTotalSelf(*u) + } + return sc +} + +// SetFlashTotalTeam sets the "flash_total_team" field. +func (sc *StatsCreate) SetFlashTotalTeam(u uint) *StatsCreate { + sc.mutation.SetFlashTotalTeam(u) + return sc +} + +// SetNillableFlashTotalTeam sets the "flash_total_team" field if the given value is not nil. +func (sc *StatsCreate) SetNillableFlashTotalTeam(u *uint) *StatsCreate { + if u != nil { + sc.SetFlashTotalTeam(*u) + } + return sc +} + +// SetFlashTotalEnemy sets the "flash_total_enemy" field. +func (sc *StatsCreate) SetFlashTotalEnemy(u uint) *StatsCreate { + sc.mutation.SetFlashTotalEnemy(u) + return sc +} + +// SetNillableFlashTotalEnemy sets the "flash_total_enemy" field if the given value is not nil. +func (sc *StatsCreate) SetNillableFlashTotalEnemy(u *uint) *StatsCreate { + if u != nil { + sc.SetFlashTotalEnemy(*u) + } + return sc +} + +// SetMatchStats sets the "match_stats" field. +func (sc *StatsCreate) SetMatchStats(u uint64) *StatsCreate { + sc.mutation.SetMatchStats(u) + return sc +} + +// SetNillableMatchStats sets the "match_stats" field if the given value is not nil. +func (sc *StatsCreate) SetNillableMatchStats(u *uint64) *StatsCreate { + if u != nil { + sc.SetMatchStats(*u) + } + return sc +} + +// SetPlayerStats sets the "player_stats" field. +func (sc *StatsCreate) SetPlayerStats(u uint64) *StatsCreate { + sc.mutation.SetPlayerStats(u) + return sc +} + +// SetNillablePlayerStats sets the "player_stats" field if the given value is not nil. +func (sc *StatsCreate) SetNillablePlayerStats(u *uint64) *StatsCreate { + if u != nil { + sc.SetPlayerStats(*u) } return sc } @@ -209,6 +550,21 @@ func (sc *StatsCreate) SetPlayers(p *Player) *StatsCreate { return sc.SetPlayersID(p.ID) } +// AddWeaponStatIDs adds the "weapon_stats" edge to the WeaponStats entity by IDs. +func (sc *StatsCreate) AddWeaponStatIDs(ids ...int) *StatsCreate { + sc.mutation.AddWeaponStatIDs(ids...) + return sc +} + +// AddWeaponStats adds the "weapon_stats" edges to the WeaponStats entity. +func (sc *StatsCreate) AddWeaponStats(w ...*WeaponStats) *StatsCreate { + ids := make([]int, len(w)) + for i := range w { + ids[i] = w[i].ID + } + return sc.AddWeaponStatIDs(ids...) +} + // Mutation returns the StatsMutation object of the builder. func (sc *StatsCreate) Mutation() *StatsMutation { return sc.mutation @@ -300,6 +656,11 @@ func (sc *StatsCreate) check() error { if _, ok := sc.mutation.Score(); !ok { return &ValidationError{Name: "score", err: errors.New(`ent: missing required field "score"`)} } + if v, ok := sc.mutation.Color(); ok { + if err := stats.ColorValidator(v); err != nil { + return &ValidationError{Name: "color", err: fmt.Errorf(`ent: validator failed for field "color": %w`, err)} + } + } return nil } @@ -369,7 +730,7 @@ func (sc *StatsCreate) createSpec() (*Stats, *sqlgraph.CreateSpec) { } if value, ok := sc.mutation.Mvp(); ok { _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeInt, + Type: field.TypeUint, Value: value, Column: stats.FieldMvp, }) @@ -383,13 +744,245 @@ func (sc *StatsCreate) createSpec() (*Stats, *sqlgraph.CreateSpec) { }) _node.Score = value } - if value, ok := sc.mutation.Extended(); ok { + if value, ok := sc.mutation.RankNew(); ok { _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeJSON, + Type: field.TypeInt, Value: value, - Column: stats.FieldExtended, + Column: stats.FieldRankNew, }) - _node.Extended = value + _node.RankNew = value + } + if value, ok := sc.mutation.RankOld(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: stats.FieldRankOld, + }) + _node.RankOld = value + } + if value, ok := sc.mutation.Mk2(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldMk2, + }) + _node.Mk2 = value + } + if value, ok := sc.mutation.Mk3(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldMk3, + }) + _node.Mk3 = value + } + if value, ok := sc.mutation.Mk4(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldMk4, + }) + _node.Mk4 = value + } + if value, ok := sc.mutation.Mk5(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldMk5, + }) + _node.Mk5 = value + } + if value, ok := sc.mutation.DmgEnemy(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldDmgEnemy, + }) + _node.DmgEnemy = value + } + if value, ok := sc.mutation.DmgTeam(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldDmgTeam, + }) + _node.DmgTeam = value + } + if value, ok := sc.mutation.UdHe(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldUdHe, + }) + _node.UdHe = value + } + if value, ok := sc.mutation.UdFlames(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldUdFlames, + }) + _node.UdFlames = value + } + if value, ok := sc.mutation.UdFlash(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldUdFlash, + }) + _node.UdFlash = value + } + if value, ok := sc.mutation.UdDecoy(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldUdDecoy, + }) + _node.UdDecoy = value + } + if value, ok := sc.mutation.UdSmoke(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldUdSmoke, + }) + _node.UdSmoke = value + } + if value, ok := sc.mutation.HitGroupHead(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupHead, + }) + _node.HitGroupHead = value + } + if value, ok := sc.mutation.HitGroupChest(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupChest, + }) + _node.HitGroupChest = value + } + if value, ok := sc.mutation.HitGroupStomach(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupStomach, + }) + _node.HitGroupStomach = value + } + if value, ok := sc.mutation.HitGroupLeftArm(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupLeftArm, + }) + _node.HitGroupLeftArm = value + } + if value, ok := sc.mutation.HitGroupRightArm(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupRightArm, + }) + _node.HitGroupRightArm = value + } + if value, ok := sc.mutation.HitGroupLeftLeg(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupLeftLeg, + }) + _node.HitGroupLeftLeg = value + } + if value, ok := sc.mutation.HitGroupRightLeg(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupRightLeg, + }) + _node.HitGroupRightLeg = value + } + if value, ok := sc.mutation.HitGroupGear(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupGear, + }) + _node.HitGroupGear = value + } + if value, ok := sc.mutation.Crosshair(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: stats.FieldCrosshair, + }) + _node.Crosshair = value + } + if value, ok := sc.mutation.Color(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeEnum, + Value: value, + Column: stats.FieldColor, + }) + _node.Color = value + } + if value, ok := sc.mutation.Kast(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: stats.FieldKast, + }) + _node.Kast = value + } + if value, ok := sc.mutation.FlashDurationSelf(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Value: value, + Column: stats.FieldFlashDurationSelf, + }) + _node.FlashDurationSelf = value + } + if value, ok := sc.mutation.FlashDurationTeam(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Value: value, + Column: stats.FieldFlashDurationTeam, + }) + _node.FlashDurationTeam = value + } + if value, ok := sc.mutation.FlashDurationEnemy(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Value: value, + Column: stats.FieldFlashDurationEnemy, + }) + _node.FlashDurationEnemy = value + } + if value, ok := sc.mutation.FlashTotalSelf(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldFlashTotalSelf, + }) + _node.FlashTotalSelf = value + } + if value, ok := sc.mutation.FlashTotalTeam(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldFlashTotalTeam, + }) + _node.FlashTotalTeam = value + } + if value, ok := sc.mutation.FlashTotalEnemy(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldFlashTotalEnemy, + }) + _node.FlashTotalEnemy = value } if nodes := sc.mutation.MatchesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ @@ -408,7 +1001,7 @@ func (sc *StatsCreate) createSpec() (*Stats, *sqlgraph.CreateSpec) { for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } - _node.match_stats = &nodes[0] + _node.MatchStats = nodes[0] _spec.Edges = append(_spec.Edges, edge) } if nodes := sc.mutation.PlayersIDs(); len(nodes) > 0 { @@ -428,7 +1021,26 @@ func (sc *StatsCreate) createSpec() (*Stats, *sqlgraph.CreateSpec) { for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } - _node.player_stats = &nodes[0] + _node.PlayerStats = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := sc.mutation.WeaponStatsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: stats.WeaponStatsTable, + Columns: []string{stats.WeaponStatsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: weaponstats.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } _spec.Edges = append(_spec.Edges, edge) } return _node, _spec diff --git a/ent/stats_query.go b/ent/stats_query.go index bb3ca64..181cd2d 100644 --- a/ent/stats_query.go +++ b/ent/stats_query.go @@ -8,6 +8,8 @@ import ( "csgowtfd/ent/player" "csgowtfd/ent/predicate" "csgowtfd/ent/stats" + "csgowtfd/ent/weaponstats" + "database/sql/driver" "errors" "fmt" "math" @@ -27,10 +29,10 @@ type StatsQuery struct { fields []string predicates []predicate.Stats // eager-loading edges. - withMatches *MatchQuery - withPlayers *PlayerQuery - withFKs bool - modifiers []func(s *sql.Selector) + withMatches *MatchQuery + withPlayers *PlayerQuery + withWeaponStats *WeaponStatsQuery + modifiers []func(s *sql.Selector) // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) @@ -111,6 +113,28 @@ func (sq *StatsQuery) QueryPlayers() *PlayerQuery { return query } +// QueryWeaponStats chains the current query on the "weapon_stats" edge. +func (sq *StatsQuery) QueryWeaponStats() *WeaponStatsQuery { + query := &WeaponStatsQuery{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(weaponstats.Table, weaponstats.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, stats.WeaponStatsTable, stats.WeaponStatsColumn), + ) + fromU = sqlgraph.SetNeighbors(sq.driver.Dialect(), step) + return fromU, nil + } + return query +} + // First returns the first Stats entity from the query. // Returns a *NotFoundError when no Stats was found. func (sq *StatsQuery) First(ctx context.Context) (*Stats, error) { @@ -287,13 +311,14 @@ func (sq *StatsQuery) Clone() *StatsQuery { return nil } return &StatsQuery{ - config: sq.config, - limit: sq.limit, - offset: sq.offset, - order: append([]OrderFunc{}, sq.order...), - predicates: append([]predicate.Stats{}, sq.predicates...), - withMatches: sq.withMatches.Clone(), - withPlayers: sq.withPlayers.Clone(), + config: sq.config, + limit: sq.limit, + offset: sq.offset, + order: append([]OrderFunc{}, sq.order...), + predicates: append([]predicate.Stats{}, sq.predicates...), + withMatches: sq.withMatches.Clone(), + withPlayers: sq.withPlayers.Clone(), + withWeaponStats: sq.withWeaponStats.Clone(), // clone intermediate query. sql: sq.sql.Clone(), path: sq.path, @@ -322,6 +347,17 @@ func (sq *StatsQuery) WithPlayers(opts ...func(*PlayerQuery)) *StatsQuery { return sq } +// WithWeaponStats tells the query-builder to eager-load the nodes that are connected to +// the "weapon_stats" edge. The optional arguments are used to configure the query builder of the edge. +func (sq *StatsQuery) WithWeaponStats(opts ...func(*WeaponStatsQuery)) *StatsQuery { + query := &WeaponStatsQuery{config: sq.config} + for _, opt := range opts { + opt(query) + } + sq.withWeaponStats = query + return sq +} + // 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. // @@ -386,19 +422,13 @@ func (sq *StatsQuery) prepareQuery(ctx context.Context) error { func (sq *StatsQuery) sqlAll(ctx context.Context) ([]*Stats, error) { var ( nodes = []*Stats{} - withFKs = sq.withFKs _spec = sq.querySpec() - loadedTypes = [2]bool{ + loadedTypes = [3]bool{ sq.withMatches != nil, sq.withPlayers != nil, + sq.withWeaponStats != nil, } ) - if sq.withMatches != nil || sq.withPlayers != nil { - withFKs = true - } - if withFKs { - _spec.Node.Columns = append(_spec.Node.Columns, stats.ForeignKeys...) - } _spec.ScanValues = func(columns []string) ([]interface{}, error) { node := &Stats{config: sq.config} nodes = append(nodes, node) @@ -426,10 +456,7 @@ func (sq *StatsQuery) sqlAll(ctx context.Context) ([]*Stats, error) { ids := make([]uint64, 0, len(nodes)) nodeids := make(map[uint64][]*Stats) for i := range nodes { - if nodes[i].match_stats == nil { - continue - } - fk := *nodes[i].match_stats + fk := nodes[i].MatchStats if _, ok := nodeids[fk]; !ok { ids = append(ids, fk) } @@ -455,10 +482,7 @@ func (sq *StatsQuery) sqlAll(ctx context.Context) ([]*Stats, error) { ids := make([]uint64, 0, len(nodes)) nodeids := make(map[uint64][]*Stats) for i := range nodes { - if nodes[i].player_stats == nil { - continue - } - fk := *nodes[i].player_stats + fk := nodes[i].PlayerStats if _, ok := nodeids[fk]; !ok { ids = append(ids, fk) } @@ -480,6 +504,35 @@ func (sq *StatsQuery) sqlAll(ctx context.Context) ([]*Stats, error) { } } + if query := sq.withWeaponStats; 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.WeaponStats = []*WeaponStats{} + } + query.withFKs = true + query.Where(predicate.WeaponStats(func(s *sql.Selector) { + s.Where(sql.InValues(stats.WeaponStatsColumn, fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return nil, err + } + for _, n := range neighbors { + fk := n.stats_weapon_stats + if fk == nil { + return nil, fmt.Errorf(`foreign-key "stats_weapon_stats" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return nil, fmt.Errorf(`unexpected foreign-key "stats_weapon_stats" returned %v for node %v`, *fk, n.ID) + } + node.Edges.WeaponStats = append(node.Edges.WeaponStats, n) + } + } + return nodes, nil } diff --git a/ent/stats_update.go b/ent/stats_update.go index 2ab1676..b8238f8 100644 --- a/ent/stats_update.go +++ b/ent/stats_update.go @@ -8,6 +8,7 @@ import ( "csgowtfd/ent/player" "csgowtfd/ent/predicate" "csgowtfd/ent/stats" + "csgowtfd/ent/weaponstats" "fmt" "entgo.io/ent/dialect/sql" @@ -94,15 +95,15 @@ func (su *StatsUpdate) AddHeadshot(i int) *StatsUpdate { } // SetMvp sets the "mvp" field. -func (su *StatsUpdate) SetMvp(i int) *StatsUpdate { +func (su *StatsUpdate) SetMvp(u uint) *StatsUpdate { su.mutation.ResetMvp() - su.mutation.SetMvp(i) + su.mutation.SetMvp(u) return su } -// AddMvp adds i to the "mvp" field. -func (su *StatsUpdate) AddMvp(i int) *StatsUpdate { - su.mutation.AddMvp(i) +// AddMvp adds u to the "mvp" field. +func (su *StatsUpdate) AddMvp(u uint) *StatsUpdate { + su.mutation.AddMvp(u) return su } @@ -119,117 +120,839 @@ func (su *StatsUpdate) AddScore(i int) *StatsUpdate { return su } -// SetExtended sets the "extended" field. -func (su *StatsUpdate) SetExtended(skkgaaaallllg struct { - MultiKills struct { - Duo int "json:\"duo,omitempty\"" - Triple int "json:\"triple,omitempty\"" - Quad int "json:\"quad,omitempty\"" - Pent int "json:\"pent,omitempty\"" - } "json:\"multi_kills,omitempty\"" - Dmg struct { - Enemy int "json:\"enemy,omitempty\"" - Team int "json:\"team,omitempty\"" - UD struct { - HE int "json:\"he,omitempty\"" - Flames int "json:\"flames,omitempty\"" - Flash int "json:\"flash,omitempty\"" - Decoy int "json:\"decoy,omitempty\"" - Smoke int "json:\"smoke,omitempty\"" - } "json:\"ud,omitempty\"" - HitGroup struct { - Head int "json:\"head,omitempty\"" - Chest int "json:\"chest,omitempty\"" - Stomach int "json:\"stomach,omitempty\"" - LeftArm int "json:\"left_arm,omitempty\"" - RightArm int "json:\"right_arm,omitempty\"" - LeftLeg int "json:\"left_leg,omitempty\"" - RightLeg int "json:\"right_leg,omitempty\"" - Gear int "json:\"gear,omitempty\"" - } "json:\"hit_group,omitempty\"" - } "json:\"dmg,omitempty\"" - Crosshair string "json:\"crosshair,omitempty\"" - Color string "json:\"color,omitempty\"" - KAST int "json:\"kast,omitempty\"" - Rank struct { - Old int "json:\"old,omitempty\"" - New int "json:\"new,omitempty\"" - } "json:\"rank,omitempty\"" - Flash struct { - Duration struct { - Self float32 "json:\"self,omitempty\"" - Team float32 "json:\"team,omitempty\"" - Enemy float32 "json:\"enemy,omitempty\"" - } "json:\"duration,omitempty\"" - Total struct { - Team int "json:\"team,omitempty\"" - Enemy int "json:\"enemy,omitempty\"" - Self int "json:\"self,omitempty\"" - } "json:\"total,omitempty\"" - } "json:\"flash,omitempty\"" -}) *StatsUpdate { - su.mutation.SetExtended(skkgaaaallllg) +// SetRankNew sets the "rank_new" field. +func (su *StatsUpdate) SetRankNew(i int) *StatsUpdate { + su.mutation.ResetRankNew() + su.mutation.SetRankNew(i) return su } -// SetNillableExtended sets the "extended" field if the given value is not nil. -func (su *StatsUpdate) SetNillableExtended(skkgaaaallllg *struct { - MultiKills struct { - Duo int "json:\"duo,omitempty\"" - Triple int "json:\"triple,omitempty\"" - Quad int "json:\"quad,omitempty\"" - Pent int "json:\"pent,omitempty\"" - } "json:\"multi_kills,omitempty\"" - Dmg struct { - Enemy int "json:\"enemy,omitempty\"" - Team int "json:\"team,omitempty\"" - UD struct { - HE int "json:\"he,omitempty\"" - Flames int "json:\"flames,omitempty\"" - Flash int "json:\"flash,omitempty\"" - Decoy int "json:\"decoy,omitempty\"" - Smoke int "json:\"smoke,omitempty\"" - } "json:\"ud,omitempty\"" - HitGroup struct { - Head int "json:\"head,omitempty\"" - Chest int "json:\"chest,omitempty\"" - Stomach int "json:\"stomach,omitempty\"" - LeftArm int "json:\"left_arm,omitempty\"" - RightArm int "json:\"right_arm,omitempty\"" - LeftLeg int "json:\"left_leg,omitempty\"" - RightLeg int "json:\"right_leg,omitempty\"" - Gear int "json:\"gear,omitempty\"" - } "json:\"hit_group,omitempty\"" - } "json:\"dmg,omitempty\"" - Crosshair string "json:\"crosshair,omitempty\"" - Color string "json:\"color,omitempty\"" - KAST int "json:\"kast,omitempty\"" - Rank struct { - Old int "json:\"old,omitempty\"" - New int "json:\"new,omitempty\"" - } "json:\"rank,omitempty\"" - Flash struct { - Duration struct { - Self float32 "json:\"self,omitempty\"" - Team float32 "json:\"team,omitempty\"" - Enemy float32 "json:\"enemy,omitempty\"" - } "json:\"duration,omitempty\"" - Total struct { - Team int "json:\"team,omitempty\"" - Enemy int "json:\"enemy,omitempty\"" - Self int "json:\"self,omitempty\"" - } "json:\"total,omitempty\"" - } "json:\"flash,omitempty\"" -}) *StatsUpdate { - if skkgaaaallllg != nil { - su.SetExtended(*skkgaaaallllg) +// SetNillableRankNew sets the "rank_new" field if the given value is not nil. +func (su *StatsUpdate) SetNillableRankNew(i *int) *StatsUpdate { + if i != nil { + su.SetRankNew(*i) } return su } -// ClearExtended clears the value of the "extended" field. -func (su *StatsUpdate) ClearExtended() *StatsUpdate { - su.mutation.ClearExtended() +// AddRankNew adds i to the "rank_new" field. +func (su *StatsUpdate) AddRankNew(i int) *StatsUpdate { + su.mutation.AddRankNew(i) + return su +} + +// ClearRankNew clears the value of the "rank_new" field. +func (su *StatsUpdate) ClearRankNew() *StatsUpdate { + su.mutation.ClearRankNew() + return su +} + +// SetRankOld sets the "rank_old" field. +func (su *StatsUpdate) SetRankOld(i int) *StatsUpdate { + su.mutation.ResetRankOld() + su.mutation.SetRankOld(i) + return su +} + +// SetNillableRankOld sets the "rank_old" field if the given value is not nil. +func (su *StatsUpdate) SetNillableRankOld(i *int) *StatsUpdate { + if i != nil { + su.SetRankOld(*i) + } + return su +} + +// AddRankOld adds i to the "rank_old" field. +func (su *StatsUpdate) AddRankOld(i int) *StatsUpdate { + su.mutation.AddRankOld(i) + return su +} + +// ClearRankOld clears the value of the "rank_old" field. +func (su *StatsUpdate) ClearRankOld() *StatsUpdate { + su.mutation.ClearRankOld() + return su +} + +// SetMk2 sets the "mk_2" field. +func (su *StatsUpdate) SetMk2(u uint) *StatsUpdate { + su.mutation.ResetMk2() + su.mutation.SetMk2(u) + return su +} + +// SetNillableMk2 sets the "mk_2" field if the given value is not nil. +func (su *StatsUpdate) SetNillableMk2(u *uint) *StatsUpdate { + if u != nil { + su.SetMk2(*u) + } + return su +} + +// AddMk2 adds u to the "mk_2" field. +func (su *StatsUpdate) AddMk2(u uint) *StatsUpdate { + su.mutation.AddMk2(u) + return su +} + +// ClearMk2 clears the value of the "mk_2" field. +func (su *StatsUpdate) ClearMk2() *StatsUpdate { + su.mutation.ClearMk2() + return su +} + +// SetMk3 sets the "mk_3" field. +func (su *StatsUpdate) SetMk3(u uint) *StatsUpdate { + su.mutation.ResetMk3() + su.mutation.SetMk3(u) + return su +} + +// SetNillableMk3 sets the "mk_3" field if the given value is not nil. +func (su *StatsUpdate) SetNillableMk3(u *uint) *StatsUpdate { + if u != nil { + su.SetMk3(*u) + } + return su +} + +// AddMk3 adds u to the "mk_3" field. +func (su *StatsUpdate) AddMk3(u uint) *StatsUpdate { + su.mutation.AddMk3(u) + return su +} + +// ClearMk3 clears the value of the "mk_3" field. +func (su *StatsUpdate) ClearMk3() *StatsUpdate { + su.mutation.ClearMk3() + return su +} + +// SetMk4 sets the "mk_4" field. +func (su *StatsUpdate) SetMk4(u uint) *StatsUpdate { + su.mutation.ResetMk4() + su.mutation.SetMk4(u) + return su +} + +// SetNillableMk4 sets the "mk_4" field if the given value is not nil. +func (su *StatsUpdate) SetNillableMk4(u *uint) *StatsUpdate { + if u != nil { + su.SetMk4(*u) + } + return su +} + +// AddMk4 adds u to the "mk_4" field. +func (su *StatsUpdate) AddMk4(u uint) *StatsUpdate { + su.mutation.AddMk4(u) + return su +} + +// ClearMk4 clears the value of the "mk_4" field. +func (su *StatsUpdate) ClearMk4() *StatsUpdate { + su.mutation.ClearMk4() + return su +} + +// SetMk5 sets the "mk_5" field. +func (su *StatsUpdate) SetMk5(u uint) *StatsUpdate { + su.mutation.ResetMk5() + su.mutation.SetMk5(u) + return su +} + +// SetNillableMk5 sets the "mk_5" field if the given value is not nil. +func (su *StatsUpdate) SetNillableMk5(u *uint) *StatsUpdate { + if u != nil { + su.SetMk5(*u) + } + return su +} + +// AddMk5 adds u to the "mk_5" field. +func (su *StatsUpdate) AddMk5(u uint) *StatsUpdate { + su.mutation.AddMk5(u) + return su +} + +// ClearMk5 clears the value of the "mk_5" field. +func (su *StatsUpdate) ClearMk5() *StatsUpdate { + su.mutation.ClearMk5() + return su +} + +// SetDmgEnemy sets the "dmg_enemy" field. +func (su *StatsUpdate) SetDmgEnemy(u uint) *StatsUpdate { + su.mutation.ResetDmgEnemy() + su.mutation.SetDmgEnemy(u) + return su +} + +// SetNillableDmgEnemy sets the "dmg_enemy" field if the given value is not nil. +func (su *StatsUpdate) SetNillableDmgEnemy(u *uint) *StatsUpdate { + if u != nil { + su.SetDmgEnemy(*u) + } + return su +} + +// AddDmgEnemy adds u to the "dmg_enemy" field. +func (su *StatsUpdate) AddDmgEnemy(u uint) *StatsUpdate { + su.mutation.AddDmgEnemy(u) + return su +} + +// ClearDmgEnemy clears the value of the "dmg_enemy" field. +func (su *StatsUpdate) ClearDmgEnemy() *StatsUpdate { + su.mutation.ClearDmgEnemy() + return su +} + +// SetDmgTeam sets the "dmg_team" field. +func (su *StatsUpdate) SetDmgTeam(u uint) *StatsUpdate { + su.mutation.ResetDmgTeam() + su.mutation.SetDmgTeam(u) + return su +} + +// SetNillableDmgTeam sets the "dmg_team" field if the given value is not nil. +func (su *StatsUpdate) SetNillableDmgTeam(u *uint) *StatsUpdate { + if u != nil { + su.SetDmgTeam(*u) + } + return su +} + +// AddDmgTeam adds u to the "dmg_team" field. +func (su *StatsUpdate) AddDmgTeam(u uint) *StatsUpdate { + su.mutation.AddDmgTeam(u) + return su +} + +// ClearDmgTeam clears the value of the "dmg_team" field. +func (su *StatsUpdate) ClearDmgTeam() *StatsUpdate { + su.mutation.ClearDmgTeam() + return su +} + +// SetUdHe sets the "ud_he" field. +func (su *StatsUpdate) SetUdHe(u uint) *StatsUpdate { + su.mutation.ResetUdHe() + su.mutation.SetUdHe(u) + return su +} + +// SetNillableUdHe sets the "ud_he" field if the given value is not nil. +func (su *StatsUpdate) SetNillableUdHe(u *uint) *StatsUpdate { + if u != nil { + su.SetUdHe(*u) + } + return su +} + +// AddUdHe adds u to the "ud_he" field. +func (su *StatsUpdate) AddUdHe(u uint) *StatsUpdate { + su.mutation.AddUdHe(u) + return su +} + +// ClearUdHe clears the value of the "ud_he" field. +func (su *StatsUpdate) ClearUdHe() *StatsUpdate { + su.mutation.ClearUdHe() + return su +} + +// SetUdFlames sets the "ud_flames" field. +func (su *StatsUpdate) SetUdFlames(u uint) *StatsUpdate { + su.mutation.ResetUdFlames() + su.mutation.SetUdFlames(u) + return su +} + +// SetNillableUdFlames sets the "ud_flames" field if the given value is not nil. +func (su *StatsUpdate) SetNillableUdFlames(u *uint) *StatsUpdate { + if u != nil { + su.SetUdFlames(*u) + } + return su +} + +// AddUdFlames adds u to the "ud_flames" field. +func (su *StatsUpdate) AddUdFlames(u uint) *StatsUpdate { + su.mutation.AddUdFlames(u) + return su +} + +// ClearUdFlames clears the value of the "ud_flames" field. +func (su *StatsUpdate) ClearUdFlames() *StatsUpdate { + su.mutation.ClearUdFlames() + return su +} + +// SetUdFlash sets the "ud_flash" field. +func (su *StatsUpdate) SetUdFlash(u uint) *StatsUpdate { + su.mutation.ResetUdFlash() + su.mutation.SetUdFlash(u) + return su +} + +// SetNillableUdFlash sets the "ud_flash" field if the given value is not nil. +func (su *StatsUpdate) SetNillableUdFlash(u *uint) *StatsUpdate { + if u != nil { + su.SetUdFlash(*u) + } + return su +} + +// AddUdFlash adds u to the "ud_flash" field. +func (su *StatsUpdate) AddUdFlash(u uint) *StatsUpdate { + su.mutation.AddUdFlash(u) + return su +} + +// ClearUdFlash clears the value of the "ud_flash" field. +func (su *StatsUpdate) ClearUdFlash() *StatsUpdate { + su.mutation.ClearUdFlash() + return su +} + +// SetUdDecoy sets the "ud_decoy" field. +func (su *StatsUpdate) SetUdDecoy(u uint) *StatsUpdate { + su.mutation.ResetUdDecoy() + su.mutation.SetUdDecoy(u) + return su +} + +// SetNillableUdDecoy sets the "ud_decoy" field if the given value is not nil. +func (su *StatsUpdate) SetNillableUdDecoy(u *uint) *StatsUpdate { + if u != nil { + su.SetUdDecoy(*u) + } + return su +} + +// AddUdDecoy adds u to the "ud_decoy" field. +func (su *StatsUpdate) AddUdDecoy(u uint) *StatsUpdate { + su.mutation.AddUdDecoy(u) + return su +} + +// ClearUdDecoy clears the value of the "ud_decoy" field. +func (su *StatsUpdate) ClearUdDecoy() *StatsUpdate { + su.mutation.ClearUdDecoy() + return su +} + +// SetUdSmoke sets the "ud_smoke" field. +func (su *StatsUpdate) SetUdSmoke(u uint) *StatsUpdate { + su.mutation.ResetUdSmoke() + su.mutation.SetUdSmoke(u) + return su +} + +// SetNillableUdSmoke sets the "ud_smoke" field if the given value is not nil. +func (su *StatsUpdate) SetNillableUdSmoke(u *uint) *StatsUpdate { + if u != nil { + su.SetUdSmoke(*u) + } + return su +} + +// AddUdSmoke adds u to the "ud_smoke" field. +func (su *StatsUpdate) AddUdSmoke(u uint) *StatsUpdate { + su.mutation.AddUdSmoke(u) + return su +} + +// ClearUdSmoke clears the value of the "ud_smoke" field. +func (su *StatsUpdate) ClearUdSmoke() *StatsUpdate { + su.mutation.ClearUdSmoke() + return su +} + +// SetHitGroupHead sets the "hit_group_head" field. +func (su *StatsUpdate) SetHitGroupHead(u uint) *StatsUpdate { + su.mutation.ResetHitGroupHead() + su.mutation.SetHitGroupHead(u) + return su +} + +// SetNillableHitGroupHead sets the "hit_group_head" field if the given value is not nil. +func (su *StatsUpdate) SetNillableHitGroupHead(u *uint) *StatsUpdate { + if u != nil { + su.SetHitGroupHead(*u) + } + return su +} + +// AddHitGroupHead adds u to the "hit_group_head" field. +func (su *StatsUpdate) AddHitGroupHead(u uint) *StatsUpdate { + su.mutation.AddHitGroupHead(u) + return su +} + +// ClearHitGroupHead clears the value of the "hit_group_head" field. +func (su *StatsUpdate) ClearHitGroupHead() *StatsUpdate { + su.mutation.ClearHitGroupHead() + return su +} + +// SetHitGroupChest sets the "hit_group_chest" field. +func (su *StatsUpdate) SetHitGroupChest(u uint) *StatsUpdate { + su.mutation.ResetHitGroupChest() + su.mutation.SetHitGroupChest(u) + return su +} + +// SetNillableHitGroupChest sets the "hit_group_chest" field if the given value is not nil. +func (su *StatsUpdate) SetNillableHitGroupChest(u *uint) *StatsUpdate { + if u != nil { + su.SetHitGroupChest(*u) + } + return su +} + +// AddHitGroupChest adds u to the "hit_group_chest" field. +func (su *StatsUpdate) AddHitGroupChest(u uint) *StatsUpdate { + su.mutation.AddHitGroupChest(u) + return su +} + +// ClearHitGroupChest clears the value of the "hit_group_chest" field. +func (su *StatsUpdate) ClearHitGroupChest() *StatsUpdate { + su.mutation.ClearHitGroupChest() + return su +} + +// SetHitGroupStomach sets the "hit_group_stomach" field. +func (su *StatsUpdate) SetHitGroupStomach(u uint) *StatsUpdate { + su.mutation.ResetHitGroupStomach() + su.mutation.SetHitGroupStomach(u) + return su +} + +// SetNillableHitGroupStomach sets the "hit_group_stomach" field if the given value is not nil. +func (su *StatsUpdate) SetNillableHitGroupStomach(u *uint) *StatsUpdate { + if u != nil { + su.SetHitGroupStomach(*u) + } + return su +} + +// AddHitGroupStomach adds u to the "hit_group_stomach" field. +func (su *StatsUpdate) AddHitGroupStomach(u uint) *StatsUpdate { + su.mutation.AddHitGroupStomach(u) + return su +} + +// ClearHitGroupStomach clears the value of the "hit_group_stomach" field. +func (su *StatsUpdate) ClearHitGroupStomach() *StatsUpdate { + su.mutation.ClearHitGroupStomach() + return su +} + +// SetHitGroupLeftArm sets the "hit_group_left_arm" field. +func (su *StatsUpdate) SetHitGroupLeftArm(u uint) *StatsUpdate { + su.mutation.ResetHitGroupLeftArm() + su.mutation.SetHitGroupLeftArm(u) + return su +} + +// SetNillableHitGroupLeftArm sets the "hit_group_left_arm" field if the given value is not nil. +func (su *StatsUpdate) SetNillableHitGroupLeftArm(u *uint) *StatsUpdate { + if u != nil { + su.SetHitGroupLeftArm(*u) + } + return su +} + +// AddHitGroupLeftArm adds u to the "hit_group_left_arm" field. +func (su *StatsUpdate) AddHitGroupLeftArm(u uint) *StatsUpdate { + su.mutation.AddHitGroupLeftArm(u) + return su +} + +// ClearHitGroupLeftArm clears the value of the "hit_group_left_arm" field. +func (su *StatsUpdate) ClearHitGroupLeftArm() *StatsUpdate { + su.mutation.ClearHitGroupLeftArm() + return su +} + +// SetHitGroupRightArm sets the "hit_group_right_arm" field. +func (su *StatsUpdate) SetHitGroupRightArm(u uint) *StatsUpdate { + su.mutation.ResetHitGroupRightArm() + su.mutation.SetHitGroupRightArm(u) + return su +} + +// SetNillableHitGroupRightArm sets the "hit_group_right_arm" field if the given value is not nil. +func (su *StatsUpdate) SetNillableHitGroupRightArm(u *uint) *StatsUpdate { + if u != nil { + su.SetHitGroupRightArm(*u) + } + return su +} + +// AddHitGroupRightArm adds u to the "hit_group_right_arm" field. +func (su *StatsUpdate) AddHitGroupRightArm(u uint) *StatsUpdate { + su.mutation.AddHitGroupRightArm(u) + return su +} + +// ClearHitGroupRightArm clears the value of the "hit_group_right_arm" field. +func (su *StatsUpdate) ClearHitGroupRightArm() *StatsUpdate { + su.mutation.ClearHitGroupRightArm() + return su +} + +// SetHitGroupLeftLeg sets the "hit_group_left_leg" field. +func (su *StatsUpdate) SetHitGroupLeftLeg(u uint) *StatsUpdate { + su.mutation.ResetHitGroupLeftLeg() + su.mutation.SetHitGroupLeftLeg(u) + return su +} + +// SetNillableHitGroupLeftLeg sets the "hit_group_left_leg" field if the given value is not nil. +func (su *StatsUpdate) SetNillableHitGroupLeftLeg(u *uint) *StatsUpdate { + if u != nil { + su.SetHitGroupLeftLeg(*u) + } + return su +} + +// AddHitGroupLeftLeg adds u to the "hit_group_left_leg" field. +func (su *StatsUpdate) AddHitGroupLeftLeg(u uint) *StatsUpdate { + su.mutation.AddHitGroupLeftLeg(u) + return su +} + +// ClearHitGroupLeftLeg clears the value of the "hit_group_left_leg" field. +func (su *StatsUpdate) ClearHitGroupLeftLeg() *StatsUpdate { + su.mutation.ClearHitGroupLeftLeg() + return su +} + +// SetHitGroupRightLeg sets the "hit_group_right_leg" field. +func (su *StatsUpdate) SetHitGroupRightLeg(u uint) *StatsUpdate { + su.mutation.ResetHitGroupRightLeg() + su.mutation.SetHitGroupRightLeg(u) + return su +} + +// SetNillableHitGroupRightLeg sets the "hit_group_right_leg" field if the given value is not nil. +func (su *StatsUpdate) SetNillableHitGroupRightLeg(u *uint) *StatsUpdate { + if u != nil { + su.SetHitGroupRightLeg(*u) + } + return su +} + +// AddHitGroupRightLeg adds u to the "hit_group_right_leg" field. +func (su *StatsUpdate) AddHitGroupRightLeg(u uint) *StatsUpdate { + su.mutation.AddHitGroupRightLeg(u) + return su +} + +// ClearHitGroupRightLeg clears the value of the "hit_group_right_leg" field. +func (su *StatsUpdate) ClearHitGroupRightLeg() *StatsUpdate { + su.mutation.ClearHitGroupRightLeg() + return su +} + +// SetHitGroupGear sets the "hit_group_gear" field. +func (su *StatsUpdate) SetHitGroupGear(u uint) *StatsUpdate { + su.mutation.ResetHitGroupGear() + su.mutation.SetHitGroupGear(u) + return su +} + +// SetNillableHitGroupGear sets the "hit_group_gear" field if the given value is not nil. +func (su *StatsUpdate) SetNillableHitGroupGear(u *uint) *StatsUpdate { + if u != nil { + su.SetHitGroupGear(*u) + } + return su +} + +// AddHitGroupGear adds u to the "hit_group_gear" field. +func (su *StatsUpdate) AddHitGroupGear(u uint) *StatsUpdate { + su.mutation.AddHitGroupGear(u) + return su +} + +// ClearHitGroupGear clears the value of the "hit_group_gear" field. +func (su *StatsUpdate) ClearHitGroupGear() *StatsUpdate { + su.mutation.ClearHitGroupGear() + return su +} + +// SetCrosshair sets the "crosshair" field. +func (su *StatsUpdate) SetCrosshair(s string) *StatsUpdate { + su.mutation.SetCrosshair(s) + return su +} + +// SetNillableCrosshair sets the "crosshair" field if the given value is not nil. +func (su *StatsUpdate) SetNillableCrosshair(s *string) *StatsUpdate { + if s != nil { + su.SetCrosshair(*s) + } + return su +} + +// ClearCrosshair clears the value of the "crosshair" field. +func (su *StatsUpdate) ClearCrosshair() *StatsUpdate { + su.mutation.ClearCrosshair() + return su +} + +// SetColor sets the "color" field. +func (su *StatsUpdate) SetColor(s stats.Color) *StatsUpdate { + su.mutation.SetColor(s) + return su +} + +// SetNillableColor sets the "color" field if the given value is not nil. +func (su *StatsUpdate) SetNillableColor(s *stats.Color) *StatsUpdate { + if s != nil { + su.SetColor(*s) + } + return su +} + +// ClearColor clears the value of the "color" field. +func (su *StatsUpdate) ClearColor() *StatsUpdate { + su.mutation.ClearColor() + return su +} + +// SetKast sets the "kast" field. +func (su *StatsUpdate) SetKast(i int) *StatsUpdate { + su.mutation.ResetKast() + su.mutation.SetKast(i) + return su +} + +// SetNillableKast sets the "kast" field if the given value is not nil. +func (su *StatsUpdate) SetNillableKast(i *int) *StatsUpdate { + if i != nil { + su.SetKast(*i) + } + return su +} + +// AddKast adds i to the "kast" field. +func (su *StatsUpdate) AddKast(i int) *StatsUpdate { + su.mutation.AddKast(i) + return su +} + +// ClearKast clears the value of the "kast" field. +func (su *StatsUpdate) ClearKast() *StatsUpdate { + su.mutation.ClearKast() + return su +} + +// SetFlashDurationSelf sets the "flash_duration_self" field. +func (su *StatsUpdate) SetFlashDurationSelf(f float32) *StatsUpdate { + su.mutation.ResetFlashDurationSelf() + su.mutation.SetFlashDurationSelf(f) + return su +} + +// SetNillableFlashDurationSelf sets the "flash_duration_self" field if the given value is not nil. +func (su *StatsUpdate) SetNillableFlashDurationSelf(f *float32) *StatsUpdate { + if f != nil { + su.SetFlashDurationSelf(*f) + } + return su +} + +// AddFlashDurationSelf adds f to the "flash_duration_self" field. +func (su *StatsUpdate) AddFlashDurationSelf(f float32) *StatsUpdate { + su.mutation.AddFlashDurationSelf(f) + return su +} + +// ClearFlashDurationSelf clears the value of the "flash_duration_self" field. +func (su *StatsUpdate) ClearFlashDurationSelf() *StatsUpdate { + su.mutation.ClearFlashDurationSelf() + return su +} + +// SetFlashDurationTeam sets the "flash_duration_team" field. +func (su *StatsUpdate) SetFlashDurationTeam(f float32) *StatsUpdate { + su.mutation.ResetFlashDurationTeam() + su.mutation.SetFlashDurationTeam(f) + return su +} + +// SetNillableFlashDurationTeam sets the "flash_duration_team" field if the given value is not nil. +func (su *StatsUpdate) SetNillableFlashDurationTeam(f *float32) *StatsUpdate { + if f != nil { + su.SetFlashDurationTeam(*f) + } + return su +} + +// AddFlashDurationTeam adds f to the "flash_duration_team" field. +func (su *StatsUpdate) AddFlashDurationTeam(f float32) *StatsUpdate { + su.mutation.AddFlashDurationTeam(f) + return su +} + +// ClearFlashDurationTeam clears the value of the "flash_duration_team" field. +func (su *StatsUpdate) ClearFlashDurationTeam() *StatsUpdate { + su.mutation.ClearFlashDurationTeam() + return su +} + +// SetFlashDurationEnemy sets the "flash_duration_enemy" field. +func (su *StatsUpdate) SetFlashDurationEnemy(f float32) *StatsUpdate { + su.mutation.ResetFlashDurationEnemy() + su.mutation.SetFlashDurationEnemy(f) + return su +} + +// SetNillableFlashDurationEnemy sets the "flash_duration_enemy" field if the given value is not nil. +func (su *StatsUpdate) SetNillableFlashDurationEnemy(f *float32) *StatsUpdate { + if f != nil { + su.SetFlashDurationEnemy(*f) + } + return su +} + +// AddFlashDurationEnemy adds f to the "flash_duration_enemy" field. +func (su *StatsUpdate) AddFlashDurationEnemy(f float32) *StatsUpdate { + su.mutation.AddFlashDurationEnemy(f) + return su +} + +// ClearFlashDurationEnemy clears the value of the "flash_duration_enemy" field. +func (su *StatsUpdate) ClearFlashDurationEnemy() *StatsUpdate { + su.mutation.ClearFlashDurationEnemy() + return su +} + +// SetFlashTotalSelf sets the "flash_total_self" field. +func (su *StatsUpdate) SetFlashTotalSelf(u uint) *StatsUpdate { + su.mutation.ResetFlashTotalSelf() + su.mutation.SetFlashTotalSelf(u) + return su +} + +// SetNillableFlashTotalSelf sets the "flash_total_self" field if the given value is not nil. +func (su *StatsUpdate) SetNillableFlashTotalSelf(u *uint) *StatsUpdate { + if u != nil { + su.SetFlashTotalSelf(*u) + } + return su +} + +// AddFlashTotalSelf adds u to the "flash_total_self" field. +func (su *StatsUpdate) AddFlashTotalSelf(u uint) *StatsUpdate { + su.mutation.AddFlashTotalSelf(u) + return su +} + +// ClearFlashTotalSelf clears the value of the "flash_total_self" field. +func (su *StatsUpdate) ClearFlashTotalSelf() *StatsUpdate { + su.mutation.ClearFlashTotalSelf() + return su +} + +// SetFlashTotalTeam sets the "flash_total_team" field. +func (su *StatsUpdate) SetFlashTotalTeam(u uint) *StatsUpdate { + su.mutation.ResetFlashTotalTeam() + su.mutation.SetFlashTotalTeam(u) + return su +} + +// SetNillableFlashTotalTeam sets the "flash_total_team" field if the given value is not nil. +func (su *StatsUpdate) SetNillableFlashTotalTeam(u *uint) *StatsUpdate { + if u != nil { + su.SetFlashTotalTeam(*u) + } + return su +} + +// AddFlashTotalTeam adds u to the "flash_total_team" field. +func (su *StatsUpdate) AddFlashTotalTeam(u uint) *StatsUpdate { + su.mutation.AddFlashTotalTeam(u) + return su +} + +// ClearFlashTotalTeam clears the value of the "flash_total_team" field. +func (su *StatsUpdate) ClearFlashTotalTeam() *StatsUpdate { + su.mutation.ClearFlashTotalTeam() + return su +} + +// SetFlashTotalEnemy sets the "flash_total_enemy" field. +func (su *StatsUpdate) SetFlashTotalEnemy(u uint) *StatsUpdate { + su.mutation.ResetFlashTotalEnemy() + su.mutation.SetFlashTotalEnemy(u) + return su +} + +// SetNillableFlashTotalEnemy sets the "flash_total_enemy" field if the given value is not nil. +func (su *StatsUpdate) SetNillableFlashTotalEnemy(u *uint) *StatsUpdate { + if u != nil { + su.SetFlashTotalEnemy(*u) + } + return su +} + +// AddFlashTotalEnemy adds u to the "flash_total_enemy" field. +func (su *StatsUpdate) AddFlashTotalEnemy(u uint) *StatsUpdate { + su.mutation.AddFlashTotalEnemy(u) + return su +} + +// ClearFlashTotalEnemy clears the value of the "flash_total_enemy" field. +func (su *StatsUpdate) ClearFlashTotalEnemy() *StatsUpdate { + su.mutation.ClearFlashTotalEnemy() + return su +} + +// SetMatchStats sets the "match_stats" field. +func (su *StatsUpdate) SetMatchStats(u uint64) *StatsUpdate { + su.mutation.SetMatchStats(u) + return su +} + +// SetNillableMatchStats sets the "match_stats" field if the given value is not nil. +func (su *StatsUpdate) SetNillableMatchStats(u *uint64) *StatsUpdate { + if u != nil { + su.SetMatchStats(*u) + } + return su +} + +// ClearMatchStats clears the value of the "match_stats" field. +func (su *StatsUpdate) ClearMatchStats() *StatsUpdate { + su.mutation.ClearMatchStats() + return su +} + +// SetPlayerStats sets the "player_stats" field. +func (su *StatsUpdate) SetPlayerStats(u uint64) *StatsUpdate { + su.mutation.SetPlayerStats(u) + return su +} + +// SetNillablePlayerStats sets the "player_stats" field if the given value is not nil. +func (su *StatsUpdate) SetNillablePlayerStats(u *uint64) *StatsUpdate { + if u != nil { + su.SetPlayerStats(*u) + } + return su +} + +// ClearPlayerStats clears the value of the "player_stats" field. +func (su *StatsUpdate) ClearPlayerStats() *StatsUpdate { + su.mutation.ClearPlayerStats() return su } @@ -271,6 +994,21 @@ func (su *StatsUpdate) SetPlayers(p *Player) *StatsUpdate { return su.SetPlayersID(p.ID) } +// AddWeaponStatIDs adds the "weapon_stats" edge to the WeaponStats entity by IDs. +func (su *StatsUpdate) AddWeaponStatIDs(ids ...int) *StatsUpdate { + su.mutation.AddWeaponStatIDs(ids...) + return su +} + +// AddWeaponStats adds the "weapon_stats" edges to the WeaponStats entity. +func (su *StatsUpdate) AddWeaponStats(w ...*WeaponStats) *StatsUpdate { + ids := make([]int, len(w)) + for i := range w { + ids[i] = w[i].ID + } + return su.AddWeaponStatIDs(ids...) +} + // Mutation returns the StatsMutation object of the builder. func (su *StatsUpdate) Mutation() *StatsMutation { return su.mutation @@ -288,6 +1026,27 @@ func (su *StatsUpdate) ClearPlayers() *StatsUpdate { return su } +// ClearWeaponStats clears all "weapon_stats" edges to the WeaponStats entity. +func (su *StatsUpdate) ClearWeaponStats() *StatsUpdate { + su.mutation.ClearWeaponStats() + return su +} + +// RemoveWeaponStatIDs removes the "weapon_stats" edge to WeaponStats entities by IDs. +func (su *StatsUpdate) RemoveWeaponStatIDs(ids ...int) *StatsUpdate { + su.mutation.RemoveWeaponStatIDs(ids...) + return su +} + +// RemoveWeaponStats removes "weapon_stats" edges to WeaponStats entities. +func (su *StatsUpdate) RemoveWeaponStats(w ...*WeaponStats) *StatsUpdate { + ids := make([]int, len(w)) + for i := range w { + ids[i] = w[i].ID + } + return su.RemoveWeaponStatIDs(ids...) +} + // Save executes the query and returns the number of nodes affected by the update operation. func (su *StatsUpdate) Save(ctx context.Context) (int, error) { var ( @@ -295,6 +1054,9 @@ func (su *StatsUpdate) Save(ctx context.Context) (int, error) { affected int ) if len(su.hooks) == 0 { + if err = su.check(); err != nil { + return 0, err + } affected, err = su.sqlSave(ctx) } else { var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { @@ -302,6 +1064,9 @@ func (su *StatsUpdate) Save(ctx context.Context) (int, error) { if !ok { return nil, fmt.Errorf("unexpected mutation type %T", m) } + if err = su.check(); err != nil { + return 0, err + } su.mutation = mutation affected, err = su.sqlSave(ctx) mutation.done = true @@ -342,6 +1107,16 @@ func (su *StatsUpdate) ExecX(ctx context.Context) { } } +// check runs all checks and user-defined validators on the builder. +func (su *StatsUpdate) check() error { + if v, ok := su.mutation.Color(); ok { + if err := stats.ColorValidator(v); err != nil { + return &ValidationError{Name: "color", err: fmt.Errorf("ent: validator failed for field \"color\": %w", err)} + } + } + return nil +} + func (su *StatsUpdate) sqlSave(ctx context.Context) (n int, err error) { _spec := &sqlgraph.UpdateSpec{ Node: &sqlgraph.NodeSpec{ @@ -432,14 +1207,14 @@ func (su *StatsUpdate) sqlSave(ctx context.Context) (n int, err error) { } if value, ok := su.mutation.Mvp(); ok { _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeInt, + Type: field.TypeUint, Value: value, Column: stats.FieldMvp, }) } if value, ok := su.mutation.AddedMvp(); ok { _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeInt, + Type: field.TypeUint, Value: value, Column: stats.FieldMvp, }) @@ -458,17 +1233,590 @@ func (su *StatsUpdate) sqlSave(ctx context.Context) (n int, err error) { Column: stats.FieldScore, }) } - if value, ok := su.mutation.Extended(); ok { + if value, ok := su.mutation.RankNew(); ok { _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeJSON, + Type: field.TypeInt, Value: value, - Column: stats.FieldExtended, + Column: stats.FieldRankNew, }) } - if su.mutation.ExtendedCleared() { + if value, ok := su.mutation.AddedRankNew(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: stats.FieldRankNew, + }) + } + if su.mutation.RankNewCleared() { _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeJSON, - Column: stats.FieldExtended, + Type: field.TypeInt, + Column: stats.FieldRankNew, + }) + } + if value, ok := su.mutation.RankOld(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: stats.FieldRankOld, + }) + } + if value, ok := su.mutation.AddedRankOld(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: stats.FieldRankOld, + }) + } + if su.mutation.RankOldCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: stats.FieldRankOld, + }) + } + if value, ok := su.mutation.Mk2(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldMk2, + }) + } + if value, ok := su.mutation.AddedMk2(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldMk2, + }) + } + if su.mutation.Mk2Cleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldMk2, + }) + } + if value, ok := su.mutation.Mk3(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldMk3, + }) + } + if value, ok := su.mutation.AddedMk3(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldMk3, + }) + } + if su.mutation.Mk3Cleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldMk3, + }) + } + if value, ok := su.mutation.Mk4(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldMk4, + }) + } + if value, ok := su.mutation.AddedMk4(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldMk4, + }) + } + if su.mutation.Mk4Cleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldMk4, + }) + } + if value, ok := su.mutation.Mk5(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldMk5, + }) + } + if value, ok := su.mutation.AddedMk5(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldMk5, + }) + } + if su.mutation.Mk5Cleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldMk5, + }) + } + if value, ok := su.mutation.DmgEnemy(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldDmgEnemy, + }) + } + if value, ok := su.mutation.AddedDmgEnemy(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldDmgEnemy, + }) + } + if su.mutation.DmgEnemyCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldDmgEnemy, + }) + } + if value, ok := su.mutation.DmgTeam(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldDmgTeam, + }) + } + if value, ok := su.mutation.AddedDmgTeam(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldDmgTeam, + }) + } + if su.mutation.DmgTeamCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldDmgTeam, + }) + } + if value, ok := su.mutation.UdHe(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldUdHe, + }) + } + if value, ok := su.mutation.AddedUdHe(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldUdHe, + }) + } + if su.mutation.UdHeCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldUdHe, + }) + } + if value, ok := su.mutation.UdFlames(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldUdFlames, + }) + } + if value, ok := su.mutation.AddedUdFlames(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldUdFlames, + }) + } + if su.mutation.UdFlamesCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldUdFlames, + }) + } + if value, ok := su.mutation.UdFlash(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldUdFlash, + }) + } + if value, ok := su.mutation.AddedUdFlash(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldUdFlash, + }) + } + if su.mutation.UdFlashCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldUdFlash, + }) + } + if value, ok := su.mutation.UdDecoy(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldUdDecoy, + }) + } + if value, ok := su.mutation.AddedUdDecoy(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldUdDecoy, + }) + } + if su.mutation.UdDecoyCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldUdDecoy, + }) + } + if value, ok := su.mutation.UdSmoke(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldUdSmoke, + }) + } + if value, ok := su.mutation.AddedUdSmoke(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldUdSmoke, + }) + } + if su.mutation.UdSmokeCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldUdSmoke, + }) + } + if value, ok := su.mutation.HitGroupHead(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupHead, + }) + } + if value, ok := su.mutation.AddedHitGroupHead(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupHead, + }) + } + if su.mutation.HitGroupHeadCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldHitGroupHead, + }) + } + if value, ok := su.mutation.HitGroupChest(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupChest, + }) + } + if value, ok := su.mutation.AddedHitGroupChest(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupChest, + }) + } + if su.mutation.HitGroupChestCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldHitGroupChest, + }) + } + if value, ok := su.mutation.HitGroupStomach(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupStomach, + }) + } + if value, ok := su.mutation.AddedHitGroupStomach(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupStomach, + }) + } + if su.mutation.HitGroupStomachCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldHitGroupStomach, + }) + } + if value, ok := su.mutation.HitGroupLeftArm(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupLeftArm, + }) + } + if value, ok := su.mutation.AddedHitGroupLeftArm(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupLeftArm, + }) + } + if su.mutation.HitGroupLeftArmCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldHitGroupLeftArm, + }) + } + if value, ok := su.mutation.HitGroupRightArm(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupRightArm, + }) + } + if value, ok := su.mutation.AddedHitGroupRightArm(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupRightArm, + }) + } + if su.mutation.HitGroupRightArmCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldHitGroupRightArm, + }) + } + if value, ok := su.mutation.HitGroupLeftLeg(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupLeftLeg, + }) + } + if value, ok := su.mutation.AddedHitGroupLeftLeg(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupLeftLeg, + }) + } + if su.mutation.HitGroupLeftLegCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldHitGroupLeftLeg, + }) + } + if value, ok := su.mutation.HitGroupRightLeg(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupRightLeg, + }) + } + if value, ok := su.mutation.AddedHitGroupRightLeg(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupRightLeg, + }) + } + if su.mutation.HitGroupRightLegCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldHitGroupRightLeg, + }) + } + if value, ok := su.mutation.HitGroupGear(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupGear, + }) + } + if value, ok := su.mutation.AddedHitGroupGear(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupGear, + }) + } + if su.mutation.HitGroupGearCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldHitGroupGear, + }) + } + if value, ok := su.mutation.Crosshair(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: stats.FieldCrosshair, + }) + } + if su.mutation.CrosshairCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Column: stats.FieldCrosshair, + }) + } + if value, ok := su.mutation.Color(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeEnum, + Value: value, + Column: stats.FieldColor, + }) + } + if su.mutation.ColorCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeEnum, + Column: stats.FieldColor, + }) + } + if value, ok := su.mutation.Kast(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: stats.FieldKast, + }) + } + if value, ok := su.mutation.AddedKast(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: stats.FieldKast, + }) + } + if su.mutation.KastCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: stats.FieldKast, + }) + } + if value, ok := su.mutation.FlashDurationSelf(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Value: value, + Column: stats.FieldFlashDurationSelf, + }) + } + if value, ok := su.mutation.AddedFlashDurationSelf(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Value: value, + Column: stats.FieldFlashDurationSelf, + }) + } + if su.mutation.FlashDurationSelfCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Column: stats.FieldFlashDurationSelf, + }) + } + if value, ok := su.mutation.FlashDurationTeam(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Value: value, + Column: stats.FieldFlashDurationTeam, + }) + } + if value, ok := su.mutation.AddedFlashDurationTeam(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Value: value, + Column: stats.FieldFlashDurationTeam, + }) + } + if su.mutation.FlashDurationTeamCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Column: stats.FieldFlashDurationTeam, + }) + } + if value, ok := su.mutation.FlashDurationEnemy(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Value: value, + Column: stats.FieldFlashDurationEnemy, + }) + } + if value, ok := su.mutation.AddedFlashDurationEnemy(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Value: value, + Column: stats.FieldFlashDurationEnemy, + }) + } + if su.mutation.FlashDurationEnemyCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Column: stats.FieldFlashDurationEnemy, + }) + } + if value, ok := su.mutation.FlashTotalSelf(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldFlashTotalSelf, + }) + } + if value, ok := su.mutation.AddedFlashTotalSelf(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldFlashTotalSelf, + }) + } + if su.mutation.FlashTotalSelfCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldFlashTotalSelf, + }) + } + if value, ok := su.mutation.FlashTotalTeam(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldFlashTotalTeam, + }) + } + if value, ok := su.mutation.AddedFlashTotalTeam(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldFlashTotalTeam, + }) + } + if su.mutation.FlashTotalTeamCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldFlashTotalTeam, + }) + } + if value, ok := su.mutation.FlashTotalEnemy(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldFlashTotalEnemy, + }) + } + if value, ok := su.mutation.AddedFlashTotalEnemy(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldFlashTotalEnemy, + }) + } + if su.mutation.FlashTotalEnemyCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldFlashTotalEnemy, }) } if su.mutation.MatchesCleared() { @@ -541,6 +1889,60 @@ func (su *StatsUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if su.mutation.WeaponStatsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: stats.WeaponStatsTable, + Columns: []string{stats.WeaponStatsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: weaponstats.FieldID, + }, + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := su.mutation.RemovedWeaponStatsIDs(); len(nodes) > 0 && !su.mutation.WeaponStatsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: stats.WeaponStatsTable, + Columns: []string{stats.WeaponStatsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: weaponstats.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.WeaponStatsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: stats.WeaponStatsTable, + Columns: []string{stats.WeaponStatsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: weaponstats.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 _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{stats.Label} @@ -626,15 +2028,15 @@ func (suo *StatsUpdateOne) AddHeadshot(i int) *StatsUpdateOne { } // SetMvp sets the "mvp" field. -func (suo *StatsUpdateOne) SetMvp(i int) *StatsUpdateOne { +func (suo *StatsUpdateOne) SetMvp(u uint) *StatsUpdateOne { suo.mutation.ResetMvp() - suo.mutation.SetMvp(i) + suo.mutation.SetMvp(u) return suo } -// AddMvp adds i to the "mvp" field. -func (suo *StatsUpdateOne) AddMvp(i int) *StatsUpdateOne { - suo.mutation.AddMvp(i) +// AddMvp adds u to the "mvp" field. +func (suo *StatsUpdateOne) AddMvp(u uint) *StatsUpdateOne { + suo.mutation.AddMvp(u) return suo } @@ -651,117 +2053,839 @@ func (suo *StatsUpdateOne) AddScore(i int) *StatsUpdateOne { return suo } -// SetExtended sets the "extended" field. -func (suo *StatsUpdateOne) SetExtended(skkgaaaallllg struct { - MultiKills struct { - Duo int "json:\"duo,omitempty\"" - Triple int "json:\"triple,omitempty\"" - Quad int "json:\"quad,omitempty\"" - Pent int "json:\"pent,omitempty\"" - } "json:\"multi_kills,omitempty\"" - Dmg struct { - Enemy int "json:\"enemy,omitempty\"" - Team int "json:\"team,omitempty\"" - UD struct { - HE int "json:\"he,omitempty\"" - Flames int "json:\"flames,omitempty\"" - Flash int "json:\"flash,omitempty\"" - Decoy int "json:\"decoy,omitempty\"" - Smoke int "json:\"smoke,omitempty\"" - } "json:\"ud,omitempty\"" - HitGroup struct { - Head int "json:\"head,omitempty\"" - Chest int "json:\"chest,omitempty\"" - Stomach int "json:\"stomach,omitempty\"" - LeftArm int "json:\"left_arm,omitempty\"" - RightArm int "json:\"right_arm,omitempty\"" - LeftLeg int "json:\"left_leg,omitempty\"" - RightLeg int "json:\"right_leg,omitempty\"" - Gear int "json:\"gear,omitempty\"" - } "json:\"hit_group,omitempty\"" - } "json:\"dmg,omitempty\"" - Crosshair string "json:\"crosshair,omitempty\"" - Color string "json:\"color,omitempty\"" - KAST int "json:\"kast,omitempty\"" - Rank struct { - Old int "json:\"old,omitempty\"" - New int "json:\"new,omitempty\"" - } "json:\"rank,omitempty\"" - Flash struct { - Duration struct { - Self float32 "json:\"self,omitempty\"" - Team float32 "json:\"team,omitempty\"" - Enemy float32 "json:\"enemy,omitempty\"" - } "json:\"duration,omitempty\"" - Total struct { - Team int "json:\"team,omitempty\"" - Enemy int "json:\"enemy,omitempty\"" - Self int "json:\"self,omitempty\"" - } "json:\"total,omitempty\"" - } "json:\"flash,omitempty\"" -}) *StatsUpdateOne { - suo.mutation.SetExtended(skkgaaaallllg) +// SetRankNew sets the "rank_new" field. +func (suo *StatsUpdateOne) SetRankNew(i int) *StatsUpdateOne { + suo.mutation.ResetRankNew() + suo.mutation.SetRankNew(i) return suo } -// SetNillableExtended sets the "extended" field if the given value is not nil. -func (suo *StatsUpdateOne) SetNillableExtended(skkgaaaallllg *struct { - MultiKills struct { - Duo int "json:\"duo,omitempty\"" - Triple int "json:\"triple,omitempty\"" - Quad int "json:\"quad,omitempty\"" - Pent int "json:\"pent,omitempty\"" - } "json:\"multi_kills,omitempty\"" - Dmg struct { - Enemy int "json:\"enemy,omitempty\"" - Team int "json:\"team,omitempty\"" - UD struct { - HE int "json:\"he,omitempty\"" - Flames int "json:\"flames,omitempty\"" - Flash int "json:\"flash,omitempty\"" - Decoy int "json:\"decoy,omitempty\"" - Smoke int "json:\"smoke,omitempty\"" - } "json:\"ud,omitempty\"" - HitGroup struct { - Head int "json:\"head,omitempty\"" - Chest int "json:\"chest,omitempty\"" - Stomach int "json:\"stomach,omitempty\"" - LeftArm int "json:\"left_arm,omitempty\"" - RightArm int "json:\"right_arm,omitempty\"" - LeftLeg int "json:\"left_leg,omitempty\"" - RightLeg int "json:\"right_leg,omitempty\"" - Gear int "json:\"gear,omitempty\"" - } "json:\"hit_group,omitempty\"" - } "json:\"dmg,omitempty\"" - Crosshair string "json:\"crosshair,omitempty\"" - Color string "json:\"color,omitempty\"" - KAST int "json:\"kast,omitempty\"" - Rank struct { - Old int "json:\"old,omitempty\"" - New int "json:\"new,omitempty\"" - } "json:\"rank,omitempty\"" - Flash struct { - Duration struct { - Self float32 "json:\"self,omitempty\"" - Team float32 "json:\"team,omitempty\"" - Enemy float32 "json:\"enemy,omitempty\"" - } "json:\"duration,omitempty\"" - Total struct { - Team int "json:\"team,omitempty\"" - Enemy int "json:\"enemy,omitempty\"" - Self int "json:\"self,omitempty\"" - } "json:\"total,omitempty\"" - } "json:\"flash,omitempty\"" -}) *StatsUpdateOne { - if skkgaaaallllg != nil { - suo.SetExtended(*skkgaaaallllg) +// SetNillableRankNew sets the "rank_new" field if the given value is not nil. +func (suo *StatsUpdateOne) SetNillableRankNew(i *int) *StatsUpdateOne { + if i != nil { + suo.SetRankNew(*i) } return suo } -// ClearExtended clears the value of the "extended" field. -func (suo *StatsUpdateOne) ClearExtended() *StatsUpdateOne { - suo.mutation.ClearExtended() +// AddRankNew adds i to the "rank_new" field. +func (suo *StatsUpdateOne) AddRankNew(i int) *StatsUpdateOne { + suo.mutation.AddRankNew(i) + return suo +} + +// ClearRankNew clears the value of the "rank_new" field. +func (suo *StatsUpdateOne) ClearRankNew() *StatsUpdateOne { + suo.mutation.ClearRankNew() + return suo +} + +// SetRankOld sets the "rank_old" field. +func (suo *StatsUpdateOne) SetRankOld(i int) *StatsUpdateOne { + suo.mutation.ResetRankOld() + suo.mutation.SetRankOld(i) + return suo +} + +// SetNillableRankOld sets the "rank_old" field if the given value is not nil. +func (suo *StatsUpdateOne) SetNillableRankOld(i *int) *StatsUpdateOne { + if i != nil { + suo.SetRankOld(*i) + } + return suo +} + +// AddRankOld adds i to the "rank_old" field. +func (suo *StatsUpdateOne) AddRankOld(i int) *StatsUpdateOne { + suo.mutation.AddRankOld(i) + return suo +} + +// ClearRankOld clears the value of the "rank_old" field. +func (suo *StatsUpdateOne) ClearRankOld() *StatsUpdateOne { + suo.mutation.ClearRankOld() + return suo +} + +// SetMk2 sets the "mk_2" field. +func (suo *StatsUpdateOne) SetMk2(u uint) *StatsUpdateOne { + suo.mutation.ResetMk2() + suo.mutation.SetMk2(u) + return suo +} + +// SetNillableMk2 sets the "mk_2" field if the given value is not nil. +func (suo *StatsUpdateOne) SetNillableMk2(u *uint) *StatsUpdateOne { + if u != nil { + suo.SetMk2(*u) + } + return suo +} + +// AddMk2 adds u to the "mk_2" field. +func (suo *StatsUpdateOne) AddMk2(u uint) *StatsUpdateOne { + suo.mutation.AddMk2(u) + return suo +} + +// ClearMk2 clears the value of the "mk_2" field. +func (suo *StatsUpdateOne) ClearMk2() *StatsUpdateOne { + suo.mutation.ClearMk2() + return suo +} + +// SetMk3 sets the "mk_3" field. +func (suo *StatsUpdateOne) SetMk3(u uint) *StatsUpdateOne { + suo.mutation.ResetMk3() + suo.mutation.SetMk3(u) + return suo +} + +// SetNillableMk3 sets the "mk_3" field if the given value is not nil. +func (suo *StatsUpdateOne) SetNillableMk3(u *uint) *StatsUpdateOne { + if u != nil { + suo.SetMk3(*u) + } + return suo +} + +// AddMk3 adds u to the "mk_3" field. +func (suo *StatsUpdateOne) AddMk3(u uint) *StatsUpdateOne { + suo.mutation.AddMk3(u) + return suo +} + +// ClearMk3 clears the value of the "mk_3" field. +func (suo *StatsUpdateOne) ClearMk3() *StatsUpdateOne { + suo.mutation.ClearMk3() + return suo +} + +// SetMk4 sets the "mk_4" field. +func (suo *StatsUpdateOne) SetMk4(u uint) *StatsUpdateOne { + suo.mutation.ResetMk4() + suo.mutation.SetMk4(u) + return suo +} + +// SetNillableMk4 sets the "mk_4" field if the given value is not nil. +func (suo *StatsUpdateOne) SetNillableMk4(u *uint) *StatsUpdateOne { + if u != nil { + suo.SetMk4(*u) + } + return suo +} + +// AddMk4 adds u to the "mk_4" field. +func (suo *StatsUpdateOne) AddMk4(u uint) *StatsUpdateOne { + suo.mutation.AddMk4(u) + return suo +} + +// ClearMk4 clears the value of the "mk_4" field. +func (suo *StatsUpdateOne) ClearMk4() *StatsUpdateOne { + suo.mutation.ClearMk4() + return suo +} + +// SetMk5 sets the "mk_5" field. +func (suo *StatsUpdateOne) SetMk5(u uint) *StatsUpdateOne { + suo.mutation.ResetMk5() + suo.mutation.SetMk5(u) + return suo +} + +// SetNillableMk5 sets the "mk_5" field if the given value is not nil. +func (suo *StatsUpdateOne) SetNillableMk5(u *uint) *StatsUpdateOne { + if u != nil { + suo.SetMk5(*u) + } + return suo +} + +// AddMk5 adds u to the "mk_5" field. +func (suo *StatsUpdateOne) AddMk5(u uint) *StatsUpdateOne { + suo.mutation.AddMk5(u) + return suo +} + +// ClearMk5 clears the value of the "mk_5" field. +func (suo *StatsUpdateOne) ClearMk5() *StatsUpdateOne { + suo.mutation.ClearMk5() + return suo +} + +// SetDmgEnemy sets the "dmg_enemy" field. +func (suo *StatsUpdateOne) SetDmgEnemy(u uint) *StatsUpdateOne { + suo.mutation.ResetDmgEnemy() + suo.mutation.SetDmgEnemy(u) + return suo +} + +// SetNillableDmgEnemy sets the "dmg_enemy" field if the given value is not nil. +func (suo *StatsUpdateOne) SetNillableDmgEnemy(u *uint) *StatsUpdateOne { + if u != nil { + suo.SetDmgEnemy(*u) + } + return suo +} + +// AddDmgEnemy adds u to the "dmg_enemy" field. +func (suo *StatsUpdateOne) AddDmgEnemy(u uint) *StatsUpdateOne { + suo.mutation.AddDmgEnemy(u) + return suo +} + +// ClearDmgEnemy clears the value of the "dmg_enemy" field. +func (suo *StatsUpdateOne) ClearDmgEnemy() *StatsUpdateOne { + suo.mutation.ClearDmgEnemy() + return suo +} + +// SetDmgTeam sets the "dmg_team" field. +func (suo *StatsUpdateOne) SetDmgTeam(u uint) *StatsUpdateOne { + suo.mutation.ResetDmgTeam() + suo.mutation.SetDmgTeam(u) + return suo +} + +// SetNillableDmgTeam sets the "dmg_team" field if the given value is not nil. +func (suo *StatsUpdateOne) SetNillableDmgTeam(u *uint) *StatsUpdateOne { + if u != nil { + suo.SetDmgTeam(*u) + } + return suo +} + +// AddDmgTeam adds u to the "dmg_team" field. +func (suo *StatsUpdateOne) AddDmgTeam(u uint) *StatsUpdateOne { + suo.mutation.AddDmgTeam(u) + return suo +} + +// ClearDmgTeam clears the value of the "dmg_team" field. +func (suo *StatsUpdateOne) ClearDmgTeam() *StatsUpdateOne { + suo.mutation.ClearDmgTeam() + return suo +} + +// SetUdHe sets the "ud_he" field. +func (suo *StatsUpdateOne) SetUdHe(u uint) *StatsUpdateOne { + suo.mutation.ResetUdHe() + suo.mutation.SetUdHe(u) + return suo +} + +// SetNillableUdHe sets the "ud_he" field if the given value is not nil. +func (suo *StatsUpdateOne) SetNillableUdHe(u *uint) *StatsUpdateOne { + if u != nil { + suo.SetUdHe(*u) + } + return suo +} + +// AddUdHe adds u to the "ud_he" field. +func (suo *StatsUpdateOne) AddUdHe(u uint) *StatsUpdateOne { + suo.mutation.AddUdHe(u) + return suo +} + +// ClearUdHe clears the value of the "ud_he" field. +func (suo *StatsUpdateOne) ClearUdHe() *StatsUpdateOne { + suo.mutation.ClearUdHe() + return suo +} + +// SetUdFlames sets the "ud_flames" field. +func (suo *StatsUpdateOne) SetUdFlames(u uint) *StatsUpdateOne { + suo.mutation.ResetUdFlames() + suo.mutation.SetUdFlames(u) + return suo +} + +// SetNillableUdFlames sets the "ud_flames" field if the given value is not nil. +func (suo *StatsUpdateOne) SetNillableUdFlames(u *uint) *StatsUpdateOne { + if u != nil { + suo.SetUdFlames(*u) + } + return suo +} + +// AddUdFlames adds u to the "ud_flames" field. +func (suo *StatsUpdateOne) AddUdFlames(u uint) *StatsUpdateOne { + suo.mutation.AddUdFlames(u) + return suo +} + +// ClearUdFlames clears the value of the "ud_flames" field. +func (suo *StatsUpdateOne) ClearUdFlames() *StatsUpdateOne { + suo.mutation.ClearUdFlames() + return suo +} + +// SetUdFlash sets the "ud_flash" field. +func (suo *StatsUpdateOne) SetUdFlash(u uint) *StatsUpdateOne { + suo.mutation.ResetUdFlash() + suo.mutation.SetUdFlash(u) + return suo +} + +// SetNillableUdFlash sets the "ud_flash" field if the given value is not nil. +func (suo *StatsUpdateOne) SetNillableUdFlash(u *uint) *StatsUpdateOne { + if u != nil { + suo.SetUdFlash(*u) + } + return suo +} + +// AddUdFlash adds u to the "ud_flash" field. +func (suo *StatsUpdateOne) AddUdFlash(u uint) *StatsUpdateOne { + suo.mutation.AddUdFlash(u) + return suo +} + +// ClearUdFlash clears the value of the "ud_flash" field. +func (suo *StatsUpdateOne) ClearUdFlash() *StatsUpdateOne { + suo.mutation.ClearUdFlash() + return suo +} + +// SetUdDecoy sets the "ud_decoy" field. +func (suo *StatsUpdateOne) SetUdDecoy(u uint) *StatsUpdateOne { + suo.mutation.ResetUdDecoy() + suo.mutation.SetUdDecoy(u) + return suo +} + +// SetNillableUdDecoy sets the "ud_decoy" field if the given value is not nil. +func (suo *StatsUpdateOne) SetNillableUdDecoy(u *uint) *StatsUpdateOne { + if u != nil { + suo.SetUdDecoy(*u) + } + return suo +} + +// AddUdDecoy adds u to the "ud_decoy" field. +func (suo *StatsUpdateOne) AddUdDecoy(u uint) *StatsUpdateOne { + suo.mutation.AddUdDecoy(u) + return suo +} + +// ClearUdDecoy clears the value of the "ud_decoy" field. +func (suo *StatsUpdateOne) ClearUdDecoy() *StatsUpdateOne { + suo.mutation.ClearUdDecoy() + return suo +} + +// SetUdSmoke sets the "ud_smoke" field. +func (suo *StatsUpdateOne) SetUdSmoke(u uint) *StatsUpdateOne { + suo.mutation.ResetUdSmoke() + suo.mutation.SetUdSmoke(u) + return suo +} + +// SetNillableUdSmoke sets the "ud_smoke" field if the given value is not nil. +func (suo *StatsUpdateOne) SetNillableUdSmoke(u *uint) *StatsUpdateOne { + if u != nil { + suo.SetUdSmoke(*u) + } + return suo +} + +// AddUdSmoke adds u to the "ud_smoke" field. +func (suo *StatsUpdateOne) AddUdSmoke(u uint) *StatsUpdateOne { + suo.mutation.AddUdSmoke(u) + return suo +} + +// ClearUdSmoke clears the value of the "ud_smoke" field. +func (suo *StatsUpdateOne) ClearUdSmoke() *StatsUpdateOne { + suo.mutation.ClearUdSmoke() + return suo +} + +// SetHitGroupHead sets the "hit_group_head" field. +func (suo *StatsUpdateOne) SetHitGroupHead(u uint) *StatsUpdateOne { + suo.mutation.ResetHitGroupHead() + suo.mutation.SetHitGroupHead(u) + return suo +} + +// SetNillableHitGroupHead sets the "hit_group_head" field if the given value is not nil. +func (suo *StatsUpdateOne) SetNillableHitGroupHead(u *uint) *StatsUpdateOne { + if u != nil { + suo.SetHitGroupHead(*u) + } + return suo +} + +// AddHitGroupHead adds u to the "hit_group_head" field. +func (suo *StatsUpdateOne) AddHitGroupHead(u uint) *StatsUpdateOne { + suo.mutation.AddHitGroupHead(u) + return suo +} + +// ClearHitGroupHead clears the value of the "hit_group_head" field. +func (suo *StatsUpdateOne) ClearHitGroupHead() *StatsUpdateOne { + suo.mutation.ClearHitGroupHead() + return suo +} + +// SetHitGroupChest sets the "hit_group_chest" field. +func (suo *StatsUpdateOne) SetHitGroupChest(u uint) *StatsUpdateOne { + suo.mutation.ResetHitGroupChest() + suo.mutation.SetHitGroupChest(u) + return suo +} + +// SetNillableHitGroupChest sets the "hit_group_chest" field if the given value is not nil. +func (suo *StatsUpdateOne) SetNillableHitGroupChest(u *uint) *StatsUpdateOne { + if u != nil { + suo.SetHitGroupChest(*u) + } + return suo +} + +// AddHitGroupChest adds u to the "hit_group_chest" field. +func (suo *StatsUpdateOne) AddHitGroupChest(u uint) *StatsUpdateOne { + suo.mutation.AddHitGroupChest(u) + return suo +} + +// ClearHitGroupChest clears the value of the "hit_group_chest" field. +func (suo *StatsUpdateOne) ClearHitGroupChest() *StatsUpdateOne { + suo.mutation.ClearHitGroupChest() + return suo +} + +// SetHitGroupStomach sets the "hit_group_stomach" field. +func (suo *StatsUpdateOne) SetHitGroupStomach(u uint) *StatsUpdateOne { + suo.mutation.ResetHitGroupStomach() + suo.mutation.SetHitGroupStomach(u) + return suo +} + +// SetNillableHitGroupStomach sets the "hit_group_stomach" field if the given value is not nil. +func (suo *StatsUpdateOne) SetNillableHitGroupStomach(u *uint) *StatsUpdateOne { + if u != nil { + suo.SetHitGroupStomach(*u) + } + return suo +} + +// AddHitGroupStomach adds u to the "hit_group_stomach" field. +func (suo *StatsUpdateOne) AddHitGroupStomach(u uint) *StatsUpdateOne { + suo.mutation.AddHitGroupStomach(u) + return suo +} + +// ClearHitGroupStomach clears the value of the "hit_group_stomach" field. +func (suo *StatsUpdateOne) ClearHitGroupStomach() *StatsUpdateOne { + suo.mutation.ClearHitGroupStomach() + return suo +} + +// SetHitGroupLeftArm sets the "hit_group_left_arm" field. +func (suo *StatsUpdateOne) SetHitGroupLeftArm(u uint) *StatsUpdateOne { + suo.mutation.ResetHitGroupLeftArm() + suo.mutation.SetHitGroupLeftArm(u) + return suo +} + +// SetNillableHitGroupLeftArm sets the "hit_group_left_arm" field if the given value is not nil. +func (suo *StatsUpdateOne) SetNillableHitGroupLeftArm(u *uint) *StatsUpdateOne { + if u != nil { + suo.SetHitGroupLeftArm(*u) + } + return suo +} + +// AddHitGroupLeftArm adds u to the "hit_group_left_arm" field. +func (suo *StatsUpdateOne) AddHitGroupLeftArm(u uint) *StatsUpdateOne { + suo.mutation.AddHitGroupLeftArm(u) + return suo +} + +// ClearHitGroupLeftArm clears the value of the "hit_group_left_arm" field. +func (suo *StatsUpdateOne) ClearHitGroupLeftArm() *StatsUpdateOne { + suo.mutation.ClearHitGroupLeftArm() + return suo +} + +// SetHitGroupRightArm sets the "hit_group_right_arm" field. +func (suo *StatsUpdateOne) SetHitGroupRightArm(u uint) *StatsUpdateOne { + suo.mutation.ResetHitGroupRightArm() + suo.mutation.SetHitGroupRightArm(u) + return suo +} + +// SetNillableHitGroupRightArm sets the "hit_group_right_arm" field if the given value is not nil. +func (suo *StatsUpdateOne) SetNillableHitGroupRightArm(u *uint) *StatsUpdateOne { + if u != nil { + suo.SetHitGroupRightArm(*u) + } + return suo +} + +// AddHitGroupRightArm adds u to the "hit_group_right_arm" field. +func (suo *StatsUpdateOne) AddHitGroupRightArm(u uint) *StatsUpdateOne { + suo.mutation.AddHitGroupRightArm(u) + return suo +} + +// ClearHitGroupRightArm clears the value of the "hit_group_right_arm" field. +func (suo *StatsUpdateOne) ClearHitGroupRightArm() *StatsUpdateOne { + suo.mutation.ClearHitGroupRightArm() + return suo +} + +// SetHitGroupLeftLeg sets the "hit_group_left_leg" field. +func (suo *StatsUpdateOne) SetHitGroupLeftLeg(u uint) *StatsUpdateOne { + suo.mutation.ResetHitGroupLeftLeg() + suo.mutation.SetHitGroupLeftLeg(u) + return suo +} + +// SetNillableHitGroupLeftLeg sets the "hit_group_left_leg" field if the given value is not nil. +func (suo *StatsUpdateOne) SetNillableHitGroupLeftLeg(u *uint) *StatsUpdateOne { + if u != nil { + suo.SetHitGroupLeftLeg(*u) + } + return suo +} + +// AddHitGroupLeftLeg adds u to the "hit_group_left_leg" field. +func (suo *StatsUpdateOne) AddHitGroupLeftLeg(u uint) *StatsUpdateOne { + suo.mutation.AddHitGroupLeftLeg(u) + return suo +} + +// ClearHitGroupLeftLeg clears the value of the "hit_group_left_leg" field. +func (suo *StatsUpdateOne) ClearHitGroupLeftLeg() *StatsUpdateOne { + suo.mutation.ClearHitGroupLeftLeg() + return suo +} + +// SetHitGroupRightLeg sets the "hit_group_right_leg" field. +func (suo *StatsUpdateOne) SetHitGroupRightLeg(u uint) *StatsUpdateOne { + suo.mutation.ResetHitGroupRightLeg() + suo.mutation.SetHitGroupRightLeg(u) + return suo +} + +// SetNillableHitGroupRightLeg sets the "hit_group_right_leg" field if the given value is not nil. +func (suo *StatsUpdateOne) SetNillableHitGroupRightLeg(u *uint) *StatsUpdateOne { + if u != nil { + suo.SetHitGroupRightLeg(*u) + } + return suo +} + +// AddHitGroupRightLeg adds u to the "hit_group_right_leg" field. +func (suo *StatsUpdateOne) AddHitGroupRightLeg(u uint) *StatsUpdateOne { + suo.mutation.AddHitGroupRightLeg(u) + return suo +} + +// ClearHitGroupRightLeg clears the value of the "hit_group_right_leg" field. +func (suo *StatsUpdateOne) ClearHitGroupRightLeg() *StatsUpdateOne { + suo.mutation.ClearHitGroupRightLeg() + return suo +} + +// SetHitGroupGear sets the "hit_group_gear" field. +func (suo *StatsUpdateOne) SetHitGroupGear(u uint) *StatsUpdateOne { + suo.mutation.ResetHitGroupGear() + suo.mutation.SetHitGroupGear(u) + return suo +} + +// SetNillableHitGroupGear sets the "hit_group_gear" field if the given value is not nil. +func (suo *StatsUpdateOne) SetNillableHitGroupGear(u *uint) *StatsUpdateOne { + if u != nil { + suo.SetHitGroupGear(*u) + } + return suo +} + +// AddHitGroupGear adds u to the "hit_group_gear" field. +func (suo *StatsUpdateOne) AddHitGroupGear(u uint) *StatsUpdateOne { + suo.mutation.AddHitGroupGear(u) + return suo +} + +// ClearHitGroupGear clears the value of the "hit_group_gear" field. +func (suo *StatsUpdateOne) ClearHitGroupGear() *StatsUpdateOne { + suo.mutation.ClearHitGroupGear() + return suo +} + +// SetCrosshair sets the "crosshair" field. +func (suo *StatsUpdateOne) SetCrosshair(s string) *StatsUpdateOne { + suo.mutation.SetCrosshair(s) + return suo +} + +// SetNillableCrosshair sets the "crosshair" field if the given value is not nil. +func (suo *StatsUpdateOne) SetNillableCrosshair(s *string) *StatsUpdateOne { + if s != nil { + suo.SetCrosshair(*s) + } + return suo +} + +// ClearCrosshair clears the value of the "crosshair" field. +func (suo *StatsUpdateOne) ClearCrosshair() *StatsUpdateOne { + suo.mutation.ClearCrosshair() + return suo +} + +// SetColor sets the "color" field. +func (suo *StatsUpdateOne) SetColor(s stats.Color) *StatsUpdateOne { + suo.mutation.SetColor(s) + return suo +} + +// SetNillableColor sets the "color" field if the given value is not nil. +func (suo *StatsUpdateOne) SetNillableColor(s *stats.Color) *StatsUpdateOne { + if s != nil { + suo.SetColor(*s) + } + return suo +} + +// ClearColor clears the value of the "color" field. +func (suo *StatsUpdateOne) ClearColor() *StatsUpdateOne { + suo.mutation.ClearColor() + return suo +} + +// SetKast sets the "kast" field. +func (suo *StatsUpdateOne) SetKast(i int) *StatsUpdateOne { + suo.mutation.ResetKast() + suo.mutation.SetKast(i) + return suo +} + +// SetNillableKast sets the "kast" field if the given value is not nil. +func (suo *StatsUpdateOne) SetNillableKast(i *int) *StatsUpdateOne { + if i != nil { + suo.SetKast(*i) + } + return suo +} + +// AddKast adds i to the "kast" field. +func (suo *StatsUpdateOne) AddKast(i int) *StatsUpdateOne { + suo.mutation.AddKast(i) + return suo +} + +// ClearKast clears the value of the "kast" field. +func (suo *StatsUpdateOne) ClearKast() *StatsUpdateOne { + suo.mutation.ClearKast() + return suo +} + +// SetFlashDurationSelf sets the "flash_duration_self" field. +func (suo *StatsUpdateOne) SetFlashDurationSelf(f float32) *StatsUpdateOne { + suo.mutation.ResetFlashDurationSelf() + suo.mutation.SetFlashDurationSelf(f) + return suo +} + +// SetNillableFlashDurationSelf sets the "flash_duration_self" field if the given value is not nil. +func (suo *StatsUpdateOne) SetNillableFlashDurationSelf(f *float32) *StatsUpdateOne { + if f != nil { + suo.SetFlashDurationSelf(*f) + } + return suo +} + +// AddFlashDurationSelf adds f to the "flash_duration_self" field. +func (suo *StatsUpdateOne) AddFlashDurationSelf(f float32) *StatsUpdateOne { + suo.mutation.AddFlashDurationSelf(f) + return suo +} + +// ClearFlashDurationSelf clears the value of the "flash_duration_self" field. +func (suo *StatsUpdateOne) ClearFlashDurationSelf() *StatsUpdateOne { + suo.mutation.ClearFlashDurationSelf() + return suo +} + +// SetFlashDurationTeam sets the "flash_duration_team" field. +func (suo *StatsUpdateOne) SetFlashDurationTeam(f float32) *StatsUpdateOne { + suo.mutation.ResetFlashDurationTeam() + suo.mutation.SetFlashDurationTeam(f) + return suo +} + +// SetNillableFlashDurationTeam sets the "flash_duration_team" field if the given value is not nil. +func (suo *StatsUpdateOne) SetNillableFlashDurationTeam(f *float32) *StatsUpdateOne { + if f != nil { + suo.SetFlashDurationTeam(*f) + } + return suo +} + +// AddFlashDurationTeam adds f to the "flash_duration_team" field. +func (suo *StatsUpdateOne) AddFlashDurationTeam(f float32) *StatsUpdateOne { + suo.mutation.AddFlashDurationTeam(f) + return suo +} + +// ClearFlashDurationTeam clears the value of the "flash_duration_team" field. +func (suo *StatsUpdateOne) ClearFlashDurationTeam() *StatsUpdateOne { + suo.mutation.ClearFlashDurationTeam() + return suo +} + +// SetFlashDurationEnemy sets the "flash_duration_enemy" field. +func (suo *StatsUpdateOne) SetFlashDurationEnemy(f float32) *StatsUpdateOne { + suo.mutation.ResetFlashDurationEnemy() + suo.mutation.SetFlashDurationEnemy(f) + return suo +} + +// SetNillableFlashDurationEnemy sets the "flash_duration_enemy" field if the given value is not nil. +func (suo *StatsUpdateOne) SetNillableFlashDurationEnemy(f *float32) *StatsUpdateOne { + if f != nil { + suo.SetFlashDurationEnemy(*f) + } + return suo +} + +// AddFlashDurationEnemy adds f to the "flash_duration_enemy" field. +func (suo *StatsUpdateOne) AddFlashDurationEnemy(f float32) *StatsUpdateOne { + suo.mutation.AddFlashDurationEnemy(f) + return suo +} + +// ClearFlashDurationEnemy clears the value of the "flash_duration_enemy" field. +func (suo *StatsUpdateOne) ClearFlashDurationEnemy() *StatsUpdateOne { + suo.mutation.ClearFlashDurationEnemy() + return suo +} + +// SetFlashTotalSelf sets the "flash_total_self" field. +func (suo *StatsUpdateOne) SetFlashTotalSelf(u uint) *StatsUpdateOne { + suo.mutation.ResetFlashTotalSelf() + suo.mutation.SetFlashTotalSelf(u) + return suo +} + +// SetNillableFlashTotalSelf sets the "flash_total_self" field if the given value is not nil. +func (suo *StatsUpdateOne) SetNillableFlashTotalSelf(u *uint) *StatsUpdateOne { + if u != nil { + suo.SetFlashTotalSelf(*u) + } + return suo +} + +// AddFlashTotalSelf adds u to the "flash_total_self" field. +func (suo *StatsUpdateOne) AddFlashTotalSelf(u uint) *StatsUpdateOne { + suo.mutation.AddFlashTotalSelf(u) + return suo +} + +// ClearFlashTotalSelf clears the value of the "flash_total_self" field. +func (suo *StatsUpdateOne) ClearFlashTotalSelf() *StatsUpdateOne { + suo.mutation.ClearFlashTotalSelf() + return suo +} + +// SetFlashTotalTeam sets the "flash_total_team" field. +func (suo *StatsUpdateOne) SetFlashTotalTeam(u uint) *StatsUpdateOne { + suo.mutation.ResetFlashTotalTeam() + suo.mutation.SetFlashTotalTeam(u) + return suo +} + +// SetNillableFlashTotalTeam sets the "flash_total_team" field if the given value is not nil. +func (suo *StatsUpdateOne) SetNillableFlashTotalTeam(u *uint) *StatsUpdateOne { + if u != nil { + suo.SetFlashTotalTeam(*u) + } + return suo +} + +// AddFlashTotalTeam adds u to the "flash_total_team" field. +func (suo *StatsUpdateOne) AddFlashTotalTeam(u uint) *StatsUpdateOne { + suo.mutation.AddFlashTotalTeam(u) + return suo +} + +// ClearFlashTotalTeam clears the value of the "flash_total_team" field. +func (suo *StatsUpdateOne) ClearFlashTotalTeam() *StatsUpdateOne { + suo.mutation.ClearFlashTotalTeam() + return suo +} + +// SetFlashTotalEnemy sets the "flash_total_enemy" field. +func (suo *StatsUpdateOne) SetFlashTotalEnemy(u uint) *StatsUpdateOne { + suo.mutation.ResetFlashTotalEnemy() + suo.mutation.SetFlashTotalEnemy(u) + return suo +} + +// SetNillableFlashTotalEnemy sets the "flash_total_enemy" field if the given value is not nil. +func (suo *StatsUpdateOne) SetNillableFlashTotalEnemy(u *uint) *StatsUpdateOne { + if u != nil { + suo.SetFlashTotalEnemy(*u) + } + return suo +} + +// AddFlashTotalEnemy adds u to the "flash_total_enemy" field. +func (suo *StatsUpdateOne) AddFlashTotalEnemy(u uint) *StatsUpdateOne { + suo.mutation.AddFlashTotalEnemy(u) + return suo +} + +// ClearFlashTotalEnemy clears the value of the "flash_total_enemy" field. +func (suo *StatsUpdateOne) ClearFlashTotalEnemy() *StatsUpdateOne { + suo.mutation.ClearFlashTotalEnemy() + return suo +} + +// SetMatchStats sets the "match_stats" field. +func (suo *StatsUpdateOne) SetMatchStats(u uint64) *StatsUpdateOne { + suo.mutation.SetMatchStats(u) + return suo +} + +// SetNillableMatchStats sets the "match_stats" field if the given value is not nil. +func (suo *StatsUpdateOne) SetNillableMatchStats(u *uint64) *StatsUpdateOne { + if u != nil { + suo.SetMatchStats(*u) + } + return suo +} + +// ClearMatchStats clears the value of the "match_stats" field. +func (suo *StatsUpdateOne) ClearMatchStats() *StatsUpdateOne { + suo.mutation.ClearMatchStats() + return suo +} + +// SetPlayerStats sets the "player_stats" field. +func (suo *StatsUpdateOne) SetPlayerStats(u uint64) *StatsUpdateOne { + suo.mutation.SetPlayerStats(u) + return suo +} + +// SetNillablePlayerStats sets the "player_stats" field if the given value is not nil. +func (suo *StatsUpdateOne) SetNillablePlayerStats(u *uint64) *StatsUpdateOne { + if u != nil { + suo.SetPlayerStats(*u) + } + return suo +} + +// ClearPlayerStats clears the value of the "player_stats" field. +func (suo *StatsUpdateOne) ClearPlayerStats() *StatsUpdateOne { + suo.mutation.ClearPlayerStats() return suo } @@ -803,6 +2927,21 @@ func (suo *StatsUpdateOne) SetPlayers(p *Player) *StatsUpdateOne { return suo.SetPlayersID(p.ID) } +// AddWeaponStatIDs adds the "weapon_stats" edge to the WeaponStats entity by IDs. +func (suo *StatsUpdateOne) AddWeaponStatIDs(ids ...int) *StatsUpdateOne { + suo.mutation.AddWeaponStatIDs(ids...) + return suo +} + +// AddWeaponStats adds the "weapon_stats" edges to the WeaponStats entity. +func (suo *StatsUpdateOne) AddWeaponStats(w ...*WeaponStats) *StatsUpdateOne { + ids := make([]int, len(w)) + for i := range w { + ids[i] = w[i].ID + } + return suo.AddWeaponStatIDs(ids...) +} + // Mutation returns the StatsMutation object of the builder. func (suo *StatsUpdateOne) Mutation() *StatsMutation { return suo.mutation @@ -820,6 +2959,27 @@ func (suo *StatsUpdateOne) ClearPlayers() *StatsUpdateOne { return suo } +// ClearWeaponStats clears all "weapon_stats" edges to the WeaponStats entity. +func (suo *StatsUpdateOne) ClearWeaponStats() *StatsUpdateOne { + suo.mutation.ClearWeaponStats() + return suo +} + +// RemoveWeaponStatIDs removes the "weapon_stats" edge to WeaponStats entities by IDs. +func (suo *StatsUpdateOne) RemoveWeaponStatIDs(ids ...int) *StatsUpdateOne { + suo.mutation.RemoveWeaponStatIDs(ids...) + return suo +} + +// RemoveWeaponStats removes "weapon_stats" edges to WeaponStats entities. +func (suo *StatsUpdateOne) RemoveWeaponStats(w ...*WeaponStats) *StatsUpdateOne { + ids := make([]int, len(w)) + for i := range w { + ids[i] = w[i].ID + } + return suo.RemoveWeaponStatIDs(ids...) +} + // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. func (suo *StatsUpdateOne) Select(field string, fields ...string) *StatsUpdateOne { @@ -834,6 +2994,9 @@ func (suo *StatsUpdateOne) Save(ctx context.Context) (*Stats, error) { node *Stats ) if len(suo.hooks) == 0 { + if err = suo.check(); err != nil { + return nil, err + } node, err = suo.sqlSave(ctx) } else { var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { @@ -841,6 +3004,9 @@ func (suo *StatsUpdateOne) Save(ctx context.Context) (*Stats, error) { if !ok { return nil, fmt.Errorf("unexpected mutation type %T", m) } + if err = suo.check(); err != nil { + return nil, err + } suo.mutation = mutation node, err = suo.sqlSave(ctx) mutation.done = true @@ -881,6 +3047,16 @@ func (suo *StatsUpdateOne) ExecX(ctx context.Context) { } } +// check runs all checks and user-defined validators on the builder. +func (suo *StatsUpdateOne) check() error { + if v, ok := suo.mutation.Color(); ok { + if err := stats.ColorValidator(v); err != nil { + return &ValidationError{Name: "color", err: fmt.Errorf("ent: validator failed for field \"color\": %w", err)} + } + } + return nil +} + func (suo *StatsUpdateOne) sqlSave(ctx context.Context) (_node *Stats, err error) { _spec := &sqlgraph.UpdateSpec{ Node: &sqlgraph.NodeSpec{ @@ -988,14 +3164,14 @@ func (suo *StatsUpdateOne) sqlSave(ctx context.Context) (_node *Stats, err error } if value, ok := suo.mutation.Mvp(); ok { _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeInt, + Type: field.TypeUint, Value: value, Column: stats.FieldMvp, }) } if value, ok := suo.mutation.AddedMvp(); ok { _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ - Type: field.TypeInt, + Type: field.TypeUint, Value: value, Column: stats.FieldMvp, }) @@ -1014,17 +3190,590 @@ func (suo *StatsUpdateOne) sqlSave(ctx context.Context) (_node *Stats, err error Column: stats.FieldScore, }) } - if value, ok := suo.mutation.Extended(); ok { + if value, ok := suo.mutation.RankNew(); ok { _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeJSON, + Type: field.TypeInt, Value: value, - Column: stats.FieldExtended, + Column: stats.FieldRankNew, }) } - if suo.mutation.ExtendedCleared() { + if value, ok := suo.mutation.AddedRankNew(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: stats.FieldRankNew, + }) + } + if suo.mutation.RankNewCleared() { _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeJSON, - Column: stats.FieldExtended, + Type: field.TypeInt, + Column: stats.FieldRankNew, + }) + } + if value, ok := suo.mutation.RankOld(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: stats.FieldRankOld, + }) + } + if value, ok := suo.mutation.AddedRankOld(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: stats.FieldRankOld, + }) + } + if suo.mutation.RankOldCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: stats.FieldRankOld, + }) + } + if value, ok := suo.mutation.Mk2(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldMk2, + }) + } + if value, ok := suo.mutation.AddedMk2(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldMk2, + }) + } + if suo.mutation.Mk2Cleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldMk2, + }) + } + if value, ok := suo.mutation.Mk3(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldMk3, + }) + } + if value, ok := suo.mutation.AddedMk3(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldMk3, + }) + } + if suo.mutation.Mk3Cleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldMk3, + }) + } + if value, ok := suo.mutation.Mk4(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldMk4, + }) + } + if value, ok := suo.mutation.AddedMk4(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldMk4, + }) + } + if suo.mutation.Mk4Cleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldMk4, + }) + } + if value, ok := suo.mutation.Mk5(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldMk5, + }) + } + if value, ok := suo.mutation.AddedMk5(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldMk5, + }) + } + if suo.mutation.Mk5Cleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldMk5, + }) + } + if value, ok := suo.mutation.DmgEnemy(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldDmgEnemy, + }) + } + if value, ok := suo.mutation.AddedDmgEnemy(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldDmgEnemy, + }) + } + if suo.mutation.DmgEnemyCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldDmgEnemy, + }) + } + if value, ok := suo.mutation.DmgTeam(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldDmgTeam, + }) + } + if value, ok := suo.mutation.AddedDmgTeam(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldDmgTeam, + }) + } + if suo.mutation.DmgTeamCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldDmgTeam, + }) + } + if value, ok := suo.mutation.UdHe(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldUdHe, + }) + } + if value, ok := suo.mutation.AddedUdHe(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldUdHe, + }) + } + if suo.mutation.UdHeCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldUdHe, + }) + } + if value, ok := suo.mutation.UdFlames(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldUdFlames, + }) + } + if value, ok := suo.mutation.AddedUdFlames(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldUdFlames, + }) + } + if suo.mutation.UdFlamesCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldUdFlames, + }) + } + if value, ok := suo.mutation.UdFlash(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldUdFlash, + }) + } + if value, ok := suo.mutation.AddedUdFlash(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldUdFlash, + }) + } + if suo.mutation.UdFlashCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldUdFlash, + }) + } + if value, ok := suo.mutation.UdDecoy(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldUdDecoy, + }) + } + if value, ok := suo.mutation.AddedUdDecoy(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldUdDecoy, + }) + } + if suo.mutation.UdDecoyCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldUdDecoy, + }) + } + if value, ok := suo.mutation.UdSmoke(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldUdSmoke, + }) + } + if value, ok := suo.mutation.AddedUdSmoke(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldUdSmoke, + }) + } + if suo.mutation.UdSmokeCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldUdSmoke, + }) + } + if value, ok := suo.mutation.HitGroupHead(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupHead, + }) + } + if value, ok := suo.mutation.AddedHitGroupHead(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupHead, + }) + } + if suo.mutation.HitGroupHeadCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldHitGroupHead, + }) + } + if value, ok := suo.mutation.HitGroupChest(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupChest, + }) + } + if value, ok := suo.mutation.AddedHitGroupChest(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupChest, + }) + } + if suo.mutation.HitGroupChestCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldHitGroupChest, + }) + } + if value, ok := suo.mutation.HitGroupStomach(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupStomach, + }) + } + if value, ok := suo.mutation.AddedHitGroupStomach(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupStomach, + }) + } + if suo.mutation.HitGroupStomachCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldHitGroupStomach, + }) + } + if value, ok := suo.mutation.HitGroupLeftArm(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupLeftArm, + }) + } + if value, ok := suo.mutation.AddedHitGroupLeftArm(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupLeftArm, + }) + } + if suo.mutation.HitGroupLeftArmCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldHitGroupLeftArm, + }) + } + if value, ok := suo.mutation.HitGroupRightArm(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupRightArm, + }) + } + if value, ok := suo.mutation.AddedHitGroupRightArm(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupRightArm, + }) + } + if suo.mutation.HitGroupRightArmCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldHitGroupRightArm, + }) + } + if value, ok := suo.mutation.HitGroupLeftLeg(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupLeftLeg, + }) + } + if value, ok := suo.mutation.AddedHitGroupLeftLeg(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupLeftLeg, + }) + } + if suo.mutation.HitGroupLeftLegCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldHitGroupLeftLeg, + }) + } + if value, ok := suo.mutation.HitGroupRightLeg(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupRightLeg, + }) + } + if value, ok := suo.mutation.AddedHitGroupRightLeg(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupRightLeg, + }) + } + if suo.mutation.HitGroupRightLegCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldHitGroupRightLeg, + }) + } + if value, ok := suo.mutation.HitGroupGear(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupGear, + }) + } + if value, ok := suo.mutation.AddedHitGroupGear(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldHitGroupGear, + }) + } + if suo.mutation.HitGroupGearCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldHitGroupGear, + }) + } + if value, ok := suo.mutation.Crosshair(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: stats.FieldCrosshair, + }) + } + if suo.mutation.CrosshairCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Column: stats.FieldCrosshair, + }) + } + if value, ok := suo.mutation.Color(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeEnum, + Value: value, + Column: stats.FieldColor, + }) + } + if suo.mutation.ColorCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeEnum, + Column: stats.FieldColor, + }) + } + if value, ok := suo.mutation.Kast(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: stats.FieldKast, + }) + } + if value, ok := suo.mutation.AddedKast(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: stats.FieldKast, + }) + } + if suo.mutation.KastCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: stats.FieldKast, + }) + } + if value, ok := suo.mutation.FlashDurationSelf(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Value: value, + Column: stats.FieldFlashDurationSelf, + }) + } + if value, ok := suo.mutation.AddedFlashDurationSelf(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Value: value, + Column: stats.FieldFlashDurationSelf, + }) + } + if suo.mutation.FlashDurationSelfCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Column: stats.FieldFlashDurationSelf, + }) + } + if value, ok := suo.mutation.FlashDurationTeam(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Value: value, + Column: stats.FieldFlashDurationTeam, + }) + } + if value, ok := suo.mutation.AddedFlashDurationTeam(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Value: value, + Column: stats.FieldFlashDurationTeam, + }) + } + if suo.mutation.FlashDurationTeamCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Column: stats.FieldFlashDurationTeam, + }) + } + if value, ok := suo.mutation.FlashDurationEnemy(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Value: value, + Column: stats.FieldFlashDurationEnemy, + }) + } + if value, ok := suo.mutation.AddedFlashDurationEnemy(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Value: value, + Column: stats.FieldFlashDurationEnemy, + }) + } + if suo.mutation.FlashDurationEnemyCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeFloat32, + Column: stats.FieldFlashDurationEnemy, + }) + } + if value, ok := suo.mutation.FlashTotalSelf(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldFlashTotalSelf, + }) + } + if value, ok := suo.mutation.AddedFlashTotalSelf(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldFlashTotalSelf, + }) + } + if suo.mutation.FlashTotalSelfCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldFlashTotalSelf, + }) + } + if value, ok := suo.mutation.FlashTotalTeam(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldFlashTotalTeam, + }) + } + if value, ok := suo.mutation.AddedFlashTotalTeam(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldFlashTotalTeam, + }) + } + if suo.mutation.FlashTotalTeamCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldFlashTotalTeam, + }) + } + if value, ok := suo.mutation.FlashTotalEnemy(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldFlashTotalEnemy, + }) + } + if value, ok := suo.mutation.AddedFlashTotalEnemy(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: stats.FieldFlashTotalEnemy, + }) + } + if suo.mutation.FlashTotalEnemyCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: stats.FieldFlashTotalEnemy, }) } if suo.mutation.MatchesCleared() { @@ -1097,6 +3846,60 @@ func (suo *StatsUpdateOne) sqlSave(ctx context.Context) (_node *Stats, err error } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if suo.mutation.WeaponStatsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: stats.WeaponStatsTable, + Columns: []string{stats.WeaponStatsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: weaponstats.FieldID, + }, + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := suo.mutation.RemovedWeaponStatsIDs(); len(nodes) > 0 && !suo.mutation.WeaponStatsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: stats.WeaponStatsTable, + Columns: []string{stats.WeaponStatsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: weaponstats.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.WeaponStatsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: stats.WeaponStatsTable, + Columns: []string{stats.WeaponStatsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: weaponstats.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} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues diff --git a/ent/tx.go b/ent/tx.go index 3db76c8..08ed15f 100644 --- a/ent/tx.go +++ b/ent/tx.go @@ -18,6 +18,8 @@ type Tx struct { Player *PlayerClient // Stats is the client for interacting with the Stats builders. Stats *StatsClient + // WeaponStats is the client for interacting with the WeaponStats builders. + WeaponStats *WeaponStatsClient // lazily loaded. client *Client @@ -156,6 +158,7 @@ func (tx *Tx) init() { tx.Match = NewMatchClient(tx.config) tx.Player = NewPlayerClient(tx.config) tx.Stats = NewStatsClient(tx.config) + tx.WeaponStats = NewWeaponStatsClient(tx.config) } // txDriver wraps the given dialect.Tx with a nop dialect.Driver implementation. diff --git a/ent/weaponstats.go b/ent/weaponstats.go new file mode 100644 index 0000000..fd8808d --- /dev/null +++ b/ent/weaponstats.go @@ -0,0 +1,169 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "csgowtfd/ent/stats" + "csgowtfd/ent/weaponstats" + "fmt" + "strings" + + "entgo.io/ent/dialect/sql" +) + +// WeaponStats is the model entity for the WeaponStats schema. +type WeaponStats struct { + config `json:"-"` + // ID of the ent. + ID int `json:"id,omitempty"` + // Victim holds the value of the "victim" field. + Victim uint64 `json:"victim,omitempty"` + // Dmg holds the value of the "dmg" field. + Dmg uint `json:"dmg,omitempty"` + // EqType holds the value of the "eq_type" field. + EqType int `json:"eq_type,omitempty"` + // HitGroup holds the value of the "hit_group" field. + HitGroup int `json:"hit_group,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the WeaponStatsQuery when eager-loading is set. + Edges WeaponStatsEdges `json:"edges"` + stats_weapon_stats *int +} + +// WeaponStatsEdges holds the relations/edges for other nodes in the graph. +type WeaponStatsEdges 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 WeaponStatsEdges) 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 (*WeaponStats) scanValues(columns []string) ([]interface{}, error) { + values := make([]interface{}, len(columns)) + for i := range columns { + switch columns[i] { + case weaponstats.FieldID, weaponstats.FieldVictim, weaponstats.FieldDmg, weaponstats.FieldEqType, weaponstats.FieldHitGroup: + values[i] = new(sql.NullInt64) + case weaponstats.ForeignKeys[0]: // stats_weapon_stats + values[i] = new(sql.NullInt64) + default: + return nil, fmt.Errorf("unexpected column %q for type WeaponStats", columns[i]) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the WeaponStats fields. +func (ws *WeaponStats) 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 weaponstats.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + ws.ID = int(value.Int64) + case weaponstats.FieldVictim: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field victim", values[i]) + } else if value.Valid { + ws.Victim = uint64(value.Int64) + } + case weaponstats.FieldDmg: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field dmg", values[i]) + } else if value.Valid { + ws.Dmg = uint(value.Int64) + } + case weaponstats.FieldEqType: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field eq_type", values[i]) + } else if value.Valid { + ws.EqType = int(value.Int64) + } + case weaponstats.FieldHitGroup: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field hit_group", values[i]) + } else if value.Valid { + ws.HitGroup = int(value.Int64) + } + case weaponstats.ForeignKeys[0]: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for edge-field stats_weapon_stats", value) + } else if value.Valid { + ws.stats_weapon_stats = new(int) + *ws.stats_weapon_stats = int(value.Int64) + } + } + } + return nil +} + +// QueryStat queries the "stat" edge of the WeaponStats entity. +func (ws *WeaponStats) QueryStat() *StatsQuery { + return (&WeaponStatsClient{config: ws.config}).QueryStat(ws) +} + +// Update returns a builder for updating this WeaponStats. +// Note that you need to call WeaponStats.Unwrap() before calling this method if this WeaponStats +// was returned from a transaction, and the transaction was committed or rolled back. +func (ws *WeaponStats) Update() *WeaponStatsUpdateOne { + return (&WeaponStatsClient{config: ws.config}).UpdateOne(ws) +} + +// Unwrap unwraps the WeaponStats 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 (ws *WeaponStats) Unwrap() *WeaponStats { + tx, ok := ws.config.driver.(*txDriver) + if !ok { + panic("ent: WeaponStats is not a transactional entity") + } + ws.config.driver = tx.drv + return ws +} + +// String implements the fmt.Stringer. +func (ws *WeaponStats) String() string { + var builder strings.Builder + builder.WriteString("WeaponStats(") + builder.WriteString(fmt.Sprintf("id=%v", ws.ID)) + builder.WriteString(", victim=") + builder.WriteString(fmt.Sprintf("%v", ws.Victim)) + builder.WriteString(", dmg=") + builder.WriteString(fmt.Sprintf("%v", ws.Dmg)) + builder.WriteString(", eq_type=") + builder.WriteString(fmt.Sprintf("%v", ws.EqType)) + builder.WriteString(", hit_group=") + builder.WriteString(fmt.Sprintf("%v", ws.HitGroup)) + builder.WriteByte(')') + return builder.String() +} + +// WeaponStatsSlice is a parsable slice of WeaponStats. +type WeaponStatsSlice []*WeaponStats + +func (ws WeaponStatsSlice) config(cfg config) { + for _i := range ws { + ws[_i].config = cfg + } +} diff --git a/ent/weaponstats/weaponstats.go b/ent/weaponstats/weaponstats.go new file mode 100644 index 0000000..8d32055 --- /dev/null +++ b/ent/weaponstats/weaponstats.go @@ -0,0 +1,59 @@ +// Code generated by entc, DO NOT EDIT. + +package weaponstats + +const ( + // Label holds the string label denoting the weaponstats type in the database. + Label = "weapon_stats" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldVictim holds the string denoting the victim field in the database. + FieldVictim = "victim" + // FieldDmg holds the string denoting the dmg field in the database. + FieldDmg = "dmg" + // FieldEqType holds the string denoting the eq_type field in the database. + FieldEqType = "eq_type" + // FieldHitGroup holds the string denoting the hit_group field in the database. + FieldHitGroup = "hit_group" + // EdgeStat holds the string denoting the stat edge name in mutations. + EdgeStat = "stat" + // Table holds the table name of the weaponstats in the database. + Table = "weapon_stats" + // StatTable is the table that holds the stat relation/edge. + StatTable = "weapon_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_weapon_stats" +) + +// Columns holds all SQL columns for weaponstats fields. +var Columns = []string{ + FieldID, + FieldVictim, + FieldDmg, + FieldEqType, + FieldHitGroup, +} + +// ForeignKeys holds the SQL foreign-keys that are owned by the "weapon_stats" +// table and are not defined as standalone fields in the schema. +var ForeignKeys = []string{ + "stats_weapon_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 +} diff --git a/ent/weaponstats/where.go b/ent/weaponstats/where.go new file mode 100644 index 0000000..f5e1615 --- /dev/null +++ b/ent/weaponstats/where.go @@ -0,0 +1,485 @@ +// Code generated by entc, DO NOT EDIT. + +package weaponstats + +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.WeaponStats { + return predicate.WeaponStats(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.WeaponStats { + return predicate.WeaponStats(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.WeaponStats { + return predicate.WeaponStats(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.WeaponStats { + return predicate.WeaponStats(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.WeaponStats { + return predicate.WeaponStats(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.WeaponStats { + return predicate.WeaponStats(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.WeaponStats { + return predicate.WeaponStats(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.WeaponStats { + return predicate.WeaponStats(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.WeaponStats { + return predicate.WeaponStats(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldID), id)) + }) +} + +// Victim applies equality check predicate on the "victim" field. It's identical to VictimEQ. +func Victim(v uint64) predicate.WeaponStats { + return predicate.WeaponStats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldVictim), v)) + }) +} + +// Dmg applies equality check predicate on the "dmg" field. It's identical to DmgEQ. +func Dmg(v uint) predicate.WeaponStats { + return predicate.WeaponStats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldDmg), v)) + }) +} + +// EqType applies equality check predicate on the "eq_type" field. It's identical to EqTypeEQ. +func EqType(v int) predicate.WeaponStats { + return predicate.WeaponStats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldEqType), v)) + }) +} + +// HitGroup applies equality check predicate on the "hit_group" field. It's identical to HitGroupEQ. +func HitGroup(v int) predicate.WeaponStats { + return predicate.WeaponStats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldHitGroup), v)) + }) +} + +// VictimEQ applies the EQ predicate on the "victim" field. +func VictimEQ(v uint64) predicate.WeaponStats { + return predicate.WeaponStats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldVictim), v)) + }) +} + +// VictimNEQ applies the NEQ predicate on the "victim" field. +func VictimNEQ(v uint64) predicate.WeaponStats { + return predicate.WeaponStats(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldVictim), v)) + }) +} + +// VictimIn applies the In predicate on the "victim" field. +func VictimIn(vs ...uint64) predicate.WeaponStats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.WeaponStats(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(FieldVictim), v...)) + }) +} + +// VictimNotIn applies the NotIn predicate on the "victim" field. +func VictimNotIn(vs ...uint64) predicate.WeaponStats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.WeaponStats(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(FieldVictim), v...)) + }) +} + +// VictimGT applies the GT predicate on the "victim" field. +func VictimGT(v uint64) predicate.WeaponStats { + return predicate.WeaponStats(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldVictim), v)) + }) +} + +// VictimGTE applies the GTE predicate on the "victim" field. +func VictimGTE(v uint64) predicate.WeaponStats { + return predicate.WeaponStats(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldVictim), v)) + }) +} + +// VictimLT applies the LT predicate on the "victim" field. +func VictimLT(v uint64) predicate.WeaponStats { + return predicate.WeaponStats(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldVictim), v)) + }) +} + +// VictimLTE applies the LTE predicate on the "victim" field. +func VictimLTE(v uint64) predicate.WeaponStats { + return predicate.WeaponStats(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldVictim), v)) + }) +} + +// DmgEQ applies the EQ predicate on the "dmg" field. +func DmgEQ(v uint) predicate.WeaponStats { + return predicate.WeaponStats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldDmg), v)) + }) +} + +// DmgNEQ applies the NEQ predicate on the "dmg" field. +func DmgNEQ(v uint) predicate.WeaponStats { + return predicate.WeaponStats(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldDmg), v)) + }) +} + +// DmgIn applies the In predicate on the "dmg" field. +func DmgIn(vs ...uint) predicate.WeaponStats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.WeaponStats(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(FieldDmg), v...)) + }) +} + +// DmgNotIn applies the NotIn predicate on the "dmg" field. +func DmgNotIn(vs ...uint) predicate.WeaponStats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.WeaponStats(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(FieldDmg), v...)) + }) +} + +// DmgGT applies the GT predicate on the "dmg" field. +func DmgGT(v uint) predicate.WeaponStats { + return predicate.WeaponStats(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldDmg), v)) + }) +} + +// DmgGTE applies the GTE predicate on the "dmg" field. +func DmgGTE(v uint) predicate.WeaponStats { + return predicate.WeaponStats(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldDmg), v)) + }) +} + +// DmgLT applies the LT predicate on the "dmg" field. +func DmgLT(v uint) predicate.WeaponStats { + return predicate.WeaponStats(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldDmg), v)) + }) +} + +// DmgLTE applies the LTE predicate on the "dmg" field. +func DmgLTE(v uint) predicate.WeaponStats { + return predicate.WeaponStats(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldDmg), v)) + }) +} + +// EqTypeEQ applies the EQ predicate on the "eq_type" field. +func EqTypeEQ(v int) predicate.WeaponStats { + return predicate.WeaponStats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldEqType), v)) + }) +} + +// EqTypeNEQ applies the NEQ predicate on the "eq_type" field. +func EqTypeNEQ(v int) predicate.WeaponStats { + return predicate.WeaponStats(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldEqType), v)) + }) +} + +// EqTypeIn applies the In predicate on the "eq_type" field. +func EqTypeIn(vs ...int) predicate.WeaponStats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.WeaponStats(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(FieldEqType), v...)) + }) +} + +// EqTypeNotIn applies the NotIn predicate on the "eq_type" field. +func EqTypeNotIn(vs ...int) predicate.WeaponStats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.WeaponStats(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(FieldEqType), v...)) + }) +} + +// EqTypeGT applies the GT predicate on the "eq_type" field. +func EqTypeGT(v int) predicate.WeaponStats { + return predicate.WeaponStats(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldEqType), v)) + }) +} + +// EqTypeGTE applies the GTE predicate on the "eq_type" field. +func EqTypeGTE(v int) predicate.WeaponStats { + return predicate.WeaponStats(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldEqType), v)) + }) +} + +// EqTypeLT applies the LT predicate on the "eq_type" field. +func EqTypeLT(v int) predicate.WeaponStats { + return predicate.WeaponStats(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldEqType), v)) + }) +} + +// EqTypeLTE applies the LTE predicate on the "eq_type" field. +func EqTypeLTE(v int) predicate.WeaponStats { + return predicate.WeaponStats(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldEqType), v)) + }) +} + +// HitGroupEQ applies the EQ predicate on the "hit_group" field. +func HitGroupEQ(v int) predicate.WeaponStats { + return predicate.WeaponStats(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldHitGroup), v)) + }) +} + +// HitGroupNEQ applies the NEQ predicate on the "hit_group" field. +func HitGroupNEQ(v int) predicate.WeaponStats { + return predicate.WeaponStats(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldHitGroup), v)) + }) +} + +// HitGroupIn applies the In predicate on the "hit_group" field. +func HitGroupIn(vs ...int) predicate.WeaponStats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.WeaponStats(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(FieldHitGroup), v...)) + }) +} + +// HitGroupNotIn applies the NotIn predicate on the "hit_group" field. +func HitGroupNotIn(vs ...int) predicate.WeaponStats { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.WeaponStats(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(FieldHitGroup), v...)) + }) +} + +// HitGroupGT applies the GT predicate on the "hit_group" field. +func HitGroupGT(v int) predicate.WeaponStats { + return predicate.WeaponStats(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldHitGroup), v)) + }) +} + +// HitGroupGTE applies the GTE predicate on the "hit_group" field. +func HitGroupGTE(v int) predicate.WeaponStats { + return predicate.WeaponStats(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldHitGroup), v)) + }) +} + +// HitGroupLT applies the LT predicate on the "hit_group" field. +func HitGroupLT(v int) predicate.WeaponStats { + return predicate.WeaponStats(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldHitGroup), v)) + }) +} + +// HitGroupLTE applies the LTE predicate on the "hit_group" field. +func HitGroupLTE(v int) predicate.WeaponStats { + return predicate.WeaponStats(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldHitGroup), v)) + }) +} + +// HasStat applies the HasEdge predicate on the "stat" edge. +func HasStat() predicate.WeaponStats { + return predicate.WeaponStats(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.WeaponStats { + return predicate.WeaponStats(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.WeaponStats) predicate.WeaponStats { + return predicate.WeaponStats(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.WeaponStats) predicate.WeaponStats { + return predicate.WeaponStats(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.WeaponStats) predicate.WeaponStats { + return predicate.WeaponStats(func(s *sql.Selector) { + p(s.Not()) + }) +} diff --git a/ent/weaponstats_create.go b/ent/weaponstats_create.go new file mode 100644 index 0000000..2169b2d --- /dev/null +++ b/ent/weaponstats_create.go @@ -0,0 +1,311 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "context" + "csgowtfd/ent/stats" + "csgowtfd/ent/weaponstats" + "errors" + "fmt" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// WeaponStatsCreate is the builder for creating a WeaponStats entity. +type WeaponStatsCreate struct { + config + mutation *WeaponStatsMutation + hooks []Hook +} + +// SetVictim sets the "victim" field. +func (wsc *WeaponStatsCreate) SetVictim(u uint64) *WeaponStatsCreate { + wsc.mutation.SetVictim(u) + return wsc +} + +// SetDmg sets the "dmg" field. +func (wsc *WeaponStatsCreate) SetDmg(u uint) *WeaponStatsCreate { + wsc.mutation.SetDmg(u) + return wsc +} + +// SetEqType sets the "eq_type" field. +func (wsc *WeaponStatsCreate) SetEqType(i int) *WeaponStatsCreate { + wsc.mutation.SetEqType(i) + return wsc +} + +// SetHitGroup sets the "hit_group" field. +func (wsc *WeaponStatsCreate) SetHitGroup(i int) *WeaponStatsCreate { + wsc.mutation.SetHitGroup(i) + return wsc +} + +// SetStatID sets the "stat" edge to the Stats entity by ID. +func (wsc *WeaponStatsCreate) SetStatID(id int) *WeaponStatsCreate { + wsc.mutation.SetStatID(id) + return wsc +} + +// SetNillableStatID sets the "stat" edge to the Stats entity by ID if the given value is not nil. +func (wsc *WeaponStatsCreate) SetNillableStatID(id *int) *WeaponStatsCreate { + if id != nil { + wsc = wsc.SetStatID(*id) + } + return wsc +} + +// SetStat sets the "stat" edge to the Stats entity. +func (wsc *WeaponStatsCreate) SetStat(s *Stats) *WeaponStatsCreate { + return wsc.SetStatID(s.ID) +} + +// Mutation returns the WeaponStatsMutation object of the builder. +func (wsc *WeaponStatsCreate) Mutation() *WeaponStatsMutation { + return wsc.mutation +} + +// Save creates the WeaponStats in the database. +func (wsc *WeaponStatsCreate) Save(ctx context.Context) (*WeaponStats, error) { + var ( + err error + node *WeaponStats + ) + if len(wsc.hooks) == 0 { + if err = wsc.check(); err != nil { + return nil, err + } + node, err = wsc.sqlSave(ctx) + } else { + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*WeaponStatsMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err = wsc.check(); err != nil { + return nil, err + } + wsc.mutation = mutation + if node, err = wsc.sqlSave(ctx); err != nil { + return nil, err + } + mutation.id = &node.ID + mutation.done = true + return node, err + }) + for i := len(wsc.hooks) - 1; i >= 0; i-- { + if wsc.hooks[i] == nil { + return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") + } + mut = wsc.hooks[i](mut) + } + if _, err := mut.Mutate(ctx, wsc.mutation); err != nil { + return nil, err + } + } + return node, err +} + +// SaveX calls Save and panics if Save returns an error. +func (wsc *WeaponStatsCreate) SaveX(ctx context.Context) *WeaponStats { + v, err := wsc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (wsc *WeaponStatsCreate) Exec(ctx context.Context) error { + _, err := wsc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (wsc *WeaponStatsCreate) ExecX(ctx context.Context) { + if err := wsc.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (wsc *WeaponStatsCreate) check() error { + if _, ok := wsc.mutation.Victim(); !ok { + return &ValidationError{Name: "victim", err: errors.New(`ent: missing required field "victim"`)} + } + if _, ok := wsc.mutation.Dmg(); !ok { + return &ValidationError{Name: "dmg", err: errors.New(`ent: missing required field "dmg"`)} + } + if _, ok := wsc.mutation.EqType(); !ok { + return &ValidationError{Name: "eq_type", err: errors.New(`ent: missing required field "eq_type"`)} + } + if _, ok := wsc.mutation.HitGroup(); !ok { + return &ValidationError{Name: "hit_group", err: errors.New(`ent: missing required field "hit_group"`)} + } + return nil +} + +func (wsc *WeaponStatsCreate) sqlSave(ctx context.Context) (*WeaponStats, error) { + _node, _spec := wsc.createSpec() + if err := sqlgraph.CreateNode(ctx, wsc.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 (wsc *WeaponStatsCreate) createSpec() (*WeaponStats, *sqlgraph.CreateSpec) { + var ( + _node = &WeaponStats{config: wsc.config} + _spec = &sqlgraph.CreateSpec{ + Table: weaponstats.Table, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: weaponstats.FieldID, + }, + } + ) + if value, ok := wsc.mutation.Victim(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint64, + Value: value, + Column: weaponstats.FieldVictim, + }) + _node.Victim = value + } + if value, ok := wsc.mutation.Dmg(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: weaponstats.FieldDmg, + }) + _node.Dmg = value + } + if value, ok := wsc.mutation.EqType(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: weaponstats.FieldEqType, + }) + _node.EqType = value + } + if value, ok := wsc.mutation.HitGroup(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: weaponstats.FieldHitGroup, + }) + _node.HitGroup = value + } + if nodes := wsc.mutation.StatIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: weaponstats.StatTable, + Columns: []string{weaponstats.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_weapon_stats = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// WeaponStatsCreateBulk is the builder for creating many WeaponStats entities in bulk. +type WeaponStatsCreateBulk struct { + config + builders []*WeaponStatsCreate +} + +// Save creates the WeaponStats entities in the database. +func (wscb *WeaponStatsCreateBulk) Save(ctx context.Context) ([]*WeaponStats, error) { + specs := make([]*sqlgraph.CreateSpec, len(wscb.builders)) + nodes := make([]*WeaponStats, len(wscb.builders)) + mutators := make([]Mutator, len(wscb.builders)) + for i := range wscb.builders { + func(i int, root context.Context) { + builder := wscb.builders[i] + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*WeaponStatsMutation) + 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, wscb.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, wscb.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, wscb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (wscb *WeaponStatsCreateBulk) SaveX(ctx context.Context) []*WeaponStats { + v, err := wscb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (wscb *WeaponStatsCreateBulk) Exec(ctx context.Context) error { + _, err := wscb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (wscb *WeaponStatsCreateBulk) ExecX(ctx context.Context) { + if err := wscb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/ent/weaponstats_delete.go b/ent/weaponstats_delete.go new file mode 100644 index 0000000..3e31fbc --- /dev/null +++ b/ent/weaponstats_delete.go @@ -0,0 +1,111 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "context" + "csgowtfd/ent/predicate" + "csgowtfd/ent/weaponstats" + "fmt" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// WeaponStatsDelete is the builder for deleting a WeaponStats entity. +type WeaponStatsDelete struct { + config + hooks []Hook + mutation *WeaponStatsMutation +} + +// Where appends a list predicates to the WeaponStatsDelete builder. +func (wsd *WeaponStatsDelete) Where(ps ...predicate.WeaponStats) *WeaponStatsDelete { + wsd.mutation.Where(ps...) + return wsd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (wsd *WeaponStatsDelete) Exec(ctx context.Context) (int, error) { + var ( + err error + affected int + ) + if len(wsd.hooks) == 0 { + affected, err = wsd.sqlExec(ctx) + } else { + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*WeaponStatsMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + wsd.mutation = mutation + affected, err = wsd.sqlExec(ctx) + mutation.done = true + return affected, err + }) + for i := len(wsd.hooks) - 1; i >= 0; i-- { + if wsd.hooks[i] == nil { + return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") + } + mut = wsd.hooks[i](mut) + } + if _, err := mut.Mutate(ctx, wsd.mutation); err != nil { + return 0, err + } + } + return affected, err +} + +// ExecX is like Exec, but panics if an error occurs. +func (wsd *WeaponStatsDelete) ExecX(ctx context.Context) int { + n, err := wsd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (wsd *WeaponStatsDelete) sqlExec(ctx context.Context) (int, error) { + _spec := &sqlgraph.DeleteSpec{ + Node: &sqlgraph.NodeSpec{ + Table: weaponstats.Table, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: weaponstats.FieldID, + }, + }, + } + if ps := wsd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return sqlgraph.DeleteNodes(ctx, wsd.driver, _spec) +} + +// WeaponStatsDeleteOne is the builder for deleting a single WeaponStats entity. +type WeaponStatsDeleteOne struct { + wsd *WeaponStatsDelete +} + +// Exec executes the deletion query. +func (wsdo *WeaponStatsDeleteOne) Exec(ctx context.Context) error { + n, err := wsdo.wsd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{weaponstats.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (wsdo *WeaponStatsDeleteOne) ExecX(ctx context.Context) { + wsdo.wsd.ExecX(ctx) +} diff --git a/ent/weaponstats_query.go b/ent/weaponstats_query.go new file mode 100644 index 0000000..1951478 --- /dev/null +++ b/ent/weaponstats_query.go @@ -0,0 +1,1016 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "context" + "csgowtfd/ent/predicate" + "csgowtfd/ent/stats" + "csgowtfd/ent/weaponstats" + "errors" + "fmt" + "math" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// WeaponStatsQuery is the builder for querying WeaponStats entities. +type WeaponStatsQuery struct { + config + limit *int + offset *int + unique *bool + order []OrderFunc + fields []string + predicates []predicate.WeaponStats + // eager-loading edges. + withStat *StatsQuery + withFKs bool + modifiers []func(s *sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the WeaponStatsQuery builder. +func (wsq *WeaponStatsQuery) Where(ps ...predicate.WeaponStats) *WeaponStatsQuery { + wsq.predicates = append(wsq.predicates, ps...) + return wsq +} + +// Limit adds a limit step to the query. +func (wsq *WeaponStatsQuery) Limit(limit int) *WeaponStatsQuery { + wsq.limit = &limit + return wsq +} + +// Offset adds an offset step to the query. +func (wsq *WeaponStatsQuery) Offset(offset int) *WeaponStatsQuery { + wsq.offset = &offset + return wsq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (wsq *WeaponStatsQuery) Unique(unique bool) *WeaponStatsQuery { + wsq.unique = &unique + return wsq +} + +// Order adds an order step to the query. +func (wsq *WeaponStatsQuery) Order(o ...OrderFunc) *WeaponStatsQuery { + wsq.order = append(wsq.order, o...) + return wsq +} + +// QueryStat chains the current query on the "stat" edge. +func (wsq *WeaponStatsQuery) QueryStat() *StatsQuery { + query := &StatsQuery{config: wsq.config} + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := wsq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := wsq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(weaponstats.Table, weaponstats.FieldID, selector), + sqlgraph.To(stats.Table, stats.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, weaponstats.StatTable, weaponstats.StatColumn), + ) + fromU = sqlgraph.SetNeighbors(wsq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first WeaponStats entity from the query. +// Returns a *NotFoundError when no WeaponStats was found. +func (wsq *WeaponStatsQuery) First(ctx context.Context) (*WeaponStats, error) { + nodes, err := wsq.Limit(1).All(ctx) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{weaponstats.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (wsq *WeaponStatsQuery) FirstX(ctx context.Context) *WeaponStats { + node, err := wsq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first WeaponStats ID from the query. +// Returns a *NotFoundError when no WeaponStats ID was found. +func (wsq *WeaponStatsQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = wsq.Limit(1).IDs(ctx); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{weaponstats.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (wsq *WeaponStatsQuery) FirstIDX(ctx context.Context) int { + id, err := wsq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single WeaponStats entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when exactly one WeaponStats entity is not found. +// Returns a *NotFoundError when no WeaponStats entities are found. +func (wsq *WeaponStatsQuery) Only(ctx context.Context) (*WeaponStats, error) { + nodes, err := wsq.Limit(2).All(ctx) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{weaponstats.Label} + default: + return nil, &NotSingularError{weaponstats.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (wsq *WeaponStatsQuery) OnlyX(ctx context.Context) *WeaponStats { + node, err := wsq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only WeaponStats ID in the query. +// Returns a *NotSingularError when exactly one WeaponStats ID is not found. +// Returns a *NotFoundError when no entities are found. +func (wsq *WeaponStatsQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = wsq.Limit(2).IDs(ctx); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{weaponstats.Label} + default: + err = &NotSingularError{weaponstats.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (wsq *WeaponStatsQuery) OnlyIDX(ctx context.Context) int { + id, err := wsq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of WeaponStatsSlice. +func (wsq *WeaponStatsQuery) All(ctx context.Context) ([]*WeaponStats, error) { + if err := wsq.prepareQuery(ctx); err != nil { + return nil, err + } + return wsq.sqlAll(ctx) +} + +// AllX is like All, but panics if an error occurs. +func (wsq *WeaponStatsQuery) AllX(ctx context.Context) []*WeaponStats { + nodes, err := wsq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of WeaponStats IDs. +func (wsq *WeaponStatsQuery) IDs(ctx context.Context) ([]int, error) { + var ids []int + if err := wsq.Select(weaponstats.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (wsq *WeaponStatsQuery) IDsX(ctx context.Context) []int { + ids, err := wsq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (wsq *WeaponStatsQuery) Count(ctx context.Context) (int, error) { + if err := wsq.prepareQuery(ctx); err != nil { + return 0, err + } + return wsq.sqlCount(ctx) +} + +// CountX is like Count, but panics if an error occurs. +func (wsq *WeaponStatsQuery) CountX(ctx context.Context) int { + count, err := wsq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (wsq *WeaponStatsQuery) Exist(ctx context.Context) (bool, error) { + if err := wsq.prepareQuery(ctx); err != nil { + return false, err + } + return wsq.sqlExist(ctx) +} + +// ExistX is like Exist, but panics if an error occurs. +func (wsq *WeaponStatsQuery) ExistX(ctx context.Context) bool { + exist, err := wsq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the WeaponStatsQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (wsq *WeaponStatsQuery) Clone() *WeaponStatsQuery { + if wsq == nil { + return nil + } + return &WeaponStatsQuery{ + config: wsq.config, + limit: wsq.limit, + offset: wsq.offset, + order: append([]OrderFunc{}, wsq.order...), + predicates: append([]predicate.WeaponStats{}, wsq.predicates...), + withStat: wsq.withStat.Clone(), + // clone intermediate query. + sql: wsq.sql.Clone(), + path: wsq.path, + } +} + +// WithStat tells the query-builder to eager-load the nodes that are connected to +// the "stat" edge. The optional arguments are used to configure the query builder of the edge. +func (wsq *WeaponStatsQuery) WithStat(opts ...func(*StatsQuery)) *WeaponStatsQuery { + query := &StatsQuery{config: wsq.config} + for _, opt := range opts { + opt(query) + } + wsq.withStat = query + return wsq +} + +// 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. +// +// Example: +// +// var v []struct { +// Victim uint64 `json:"victim,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.WeaponStats.Query(). +// GroupBy(weaponstats.FieldVictim). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +// +func (wsq *WeaponStatsQuery) GroupBy(field string, fields ...string) *WeaponStatsGroupBy { + group := &WeaponStatsGroupBy{config: wsq.config} + group.fields = append([]string{field}, fields...) + group.path = func(ctx context.Context) (prev *sql.Selector, err error) { + if err := wsq.prepareQuery(ctx); err != nil { + return nil, err + } + return wsq.sqlQuery(ctx), nil + } + return group +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// Victim uint64 `json:"victim,omitempty"` +// } +// +// client.WeaponStats.Query(). +// Select(weaponstats.FieldVictim). +// Scan(ctx, &v) +// +func (wsq *WeaponStatsQuery) Select(fields ...string) *WeaponStatsSelect { + wsq.fields = append(wsq.fields, fields...) + return &WeaponStatsSelect{WeaponStatsQuery: wsq} +} + +func (wsq *WeaponStatsQuery) prepareQuery(ctx context.Context) error { + for _, f := range wsq.fields { + if !weaponstats.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if wsq.path != nil { + prev, err := wsq.path(ctx) + if err != nil { + return err + } + wsq.sql = prev + } + return nil +} + +func (wsq *WeaponStatsQuery) sqlAll(ctx context.Context) ([]*WeaponStats, error) { + var ( + nodes = []*WeaponStats{} + withFKs = wsq.withFKs + _spec = wsq.querySpec() + loadedTypes = [1]bool{ + wsq.withStat != nil, + } + ) + if wsq.withStat != nil { + withFKs = true + } + if withFKs { + _spec.Node.Columns = append(_spec.Node.Columns, weaponstats.ForeignKeys...) + } + _spec.ScanValues = func(columns []string) ([]interface{}, error) { + node := &WeaponStats{config: wsq.config} + nodes = append(nodes, node) + return node.scanValues(columns) + } + _spec.Assign = func(columns []string, values []interface{}) error { + if len(nodes) == 0 { + return fmt.Errorf("ent: Assign called without calling ScanValues") + } + node := nodes[len(nodes)-1] + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(wsq.modifiers) > 0 { + _spec.Modifiers = wsq.modifiers + } + if err := sqlgraph.QueryNodes(ctx, wsq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + + if query := wsq.withStat; query != nil { + ids := make([]int, 0, len(nodes)) + nodeids := make(map[int][]*WeaponStats) + for i := range nodes { + if nodes[i].stats_weapon_stats == nil { + continue + } + fk := *nodes[i].stats_weapon_stats + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + query.Where(stats.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return nil, err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return nil, fmt.Errorf(`unexpected foreign-key "stats_weapon_stats" returned %v`, n.ID) + } + for i := range nodes { + nodes[i].Edges.Stat = n + } + } + } + + return nodes, nil +} + +func (wsq *WeaponStatsQuery) sqlCount(ctx context.Context) (int, error) { + _spec := wsq.querySpec() + if len(wsq.modifiers) > 0 { + _spec.Modifiers = wsq.modifiers + } + return sqlgraph.CountNodes(ctx, wsq.driver, _spec) +} + +func (wsq *WeaponStatsQuery) sqlExist(ctx context.Context) (bool, error) { + n, err := wsq.sqlCount(ctx) + if err != nil { + return false, fmt.Errorf("ent: check existence: %w", err) + } + return n > 0, nil +} + +func (wsq *WeaponStatsQuery) querySpec() *sqlgraph.QuerySpec { + _spec := &sqlgraph.QuerySpec{ + Node: &sqlgraph.NodeSpec{ + Table: weaponstats.Table, + Columns: weaponstats.Columns, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: weaponstats.FieldID, + }, + }, + From: wsq.sql, + Unique: true, + } + if unique := wsq.unique; unique != nil { + _spec.Unique = *unique + } + if fields := wsq.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, weaponstats.FieldID) + for i := range fields { + if fields[i] != weaponstats.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := wsq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := wsq.limit; limit != nil { + _spec.Limit = *limit + } + if offset := wsq.offset; offset != nil { + _spec.Offset = *offset + } + if ps := wsq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (wsq *WeaponStatsQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(wsq.driver.Dialect()) + t1 := builder.Table(weaponstats.Table) + columns := wsq.fields + if len(columns) == 0 { + columns = weaponstats.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if wsq.sql != nil { + selector = wsq.sql + selector.Select(selector.Columns(columns...)...) + } + for _, m := range wsq.modifiers { + m(selector) + } + for _, p := range wsq.predicates { + p(selector) + } + for _, p := range wsq.order { + p(selector) + } + if offset := wsq.offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := wsq.limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (wsq *WeaponStatsQuery) Modify(modifiers ...func(s *sql.Selector)) *WeaponStatsSelect { + wsq.modifiers = append(wsq.modifiers, modifiers...) + return wsq.Select() +} + +// WeaponStatsGroupBy is the group-by builder for WeaponStats entities. +type WeaponStatsGroupBy struct { + config + fields []string + fns []AggregateFunc + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (wsgb *WeaponStatsGroupBy) Aggregate(fns ...AggregateFunc) *WeaponStatsGroupBy { + wsgb.fns = append(wsgb.fns, fns...) + return wsgb +} + +// Scan applies the group-by query and scans the result into the given value. +func (wsgb *WeaponStatsGroupBy) Scan(ctx context.Context, v interface{}) error { + query, err := wsgb.path(ctx) + if err != nil { + return err + } + wsgb.sql = query + return wsgb.sqlScan(ctx, v) +} + +// ScanX is like Scan, but panics if an error occurs. +func (wsgb *WeaponStatsGroupBy) ScanX(ctx context.Context, v interface{}) { + if err := wsgb.Scan(ctx, v); err != nil { + panic(err) + } +} + +// Strings returns list of strings from group-by. +// It is only allowed when executing a group-by query with one field. +func (wsgb *WeaponStatsGroupBy) Strings(ctx context.Context) ([]string, error) { + if len(wsgb.fields) > 1 { + return nil, errors.New("ent: WeaponStatsGroupBy.Strings is not achievable when grouping more than 1 field") + } + var v []string + if err := wsgb.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// StringsX is like Strings, but panics if an error occurs. +func (wsgb *WeaponStatsGroupBy) StringsX(ctx context.Context) []string { + v, err := wsgb.Strings(ctx) + if err != nil { + panic(err) + } + return v +} + +// String returns a single string from a group-by query. +// It is only allowed when executing a group-by query with one field. +func (wsgb *WeaponStatsGroupBy) String(ctx context.Context) (_ string, err error) { + var v []string + if v, err = wsgb.Strings(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{weaponstats.Label} + default: + err = fmt.Errorf("ent: WeaponStatsGroupBy.Strings returned %d results when one was expected", len(v)) + } + return +} + +// StringX is like String, but panics if an error occurs. +func (wsgb *WeaponStatsGroupBy) StringX(ctx context.Context) string { + v, err := wsgb.String(ctx) + if err != nil { + panic(err) + } + return v +} + +// Ints returns list of ints from group-by. +// It is only allowed when executing a group-by query with one field. +func (wsgb *WeaponStatsGroupBy) Ints(ctx context.Context) ([]int, error) { + if len(wsgb.fields) > 1 { + return nil, errors.New("ent: WeaponStatsGroupBy.Ints is not achievable when grouping more than 1 field") + } + var v []int + if err := wsgb.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// IntsX is like Ints, but panics if an error occurs. +func (wsgb *WeaponStatsGroupBy) IntsX(ctx context.Context) []int { + v, err := wsgb.Ints(ctx) + if err != nil { + panic(err) + } + return v +} + +// Int returns a single int from a group-by query. +// It is only allowed when executing a group-by query with one field. +func (wsgb *WeaponStatsGroupBy) Int(ctx context.Context) (_ int, err error) { + var v []int + if v, err = wsgb.Ints(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{weaponstats.Label} + default: + err = fmt.Errorf("ent: WeaponStatsGroupBy.Ints returned %d results when one was expected", len(v)) + } + return +} + +// IntX is like Int, but panics if an error occurs. +func (wsgb *WeaponStatsGroupBy) IntX(ctx context.Context) int { + v, err := wsgb.Int(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64s returns list of float64s from group-by. +// It is only allowed when executing a group-by query with one field. +func (wsgb *WeaponStatsGroupBy) Float64s(ctx context.Context) ([]float64, error) { + if len(wsgb.fields) > 1 { + return nil, errors.New("ent: WeaponStatsGroupBy.Float64s is not achievable when grouping more than 1 field") + } + var v []float64 + if err := wsgb.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// Float64sX is like Float64s, but panics if an error occurs. +func (wsgb *WeaponStatsGroupBy) Float64sX(ctx context.Context) []float64 { + v, err := wsgb.Float64s(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64 returns a single float64 from a group-by query. +// It is only allowed when executing a group-by query with one field. +func (wsgb *WeaponStatsGroupBy) Float64(ctx context.Context) (_ float64, err error) { + var v []float64 + if v, err = wsgb.Float64s(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{weaponstats.Label} + default: + err = fmt.Errorf("ent: WeaponStatsGroupBy.Float64s returned %d results when one was expected", len(v)) + } + return +} + +// Float64X is like Float64, but panics if an error occurs. +func (wsgb *WeaponStatsGroupBy) Float64X(ctx context.Context) float64 { + v, err := wsgb.Float64(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bools returns list of bools from group-by. +// It is only allowed when executing a group-by query with one field. +func (wsgb *WeaponStatsGroupBy) Bools(ctx context.Context) ([]bool, error) { + if len(wsgb.fields) > 1 { + return nil, errors.New("ent: WeaponStatsGroupBy.Bools is not achievable when grouping more than 1 field") + } + var v []bool + if err := wsgb.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// BoolsX is like Bools, but panics if an error occurs. +func (wsgb *WeaponStatsGroupBy) BoolsX(ctx context.Context) []bool { + v, err := wsgb.Bools(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bool returns a single bool from a group-by query. +// It is only allowed when executing a group-by query with one field. +func (wsgb *WeaponStatsGroupBy) Bool(ctx context.Context) (_ bool, err error) { + var v []bool + if v, err = wsgb.Bools(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{weaponstats.Label} + default: + err = fmt.Errorf("ent: WeaponStatsGroupBy.Bools returned %d results when one was expected", len(v)) + } + return +} + +// BoolX is like Bool, but panics if an error occurs. +func (wsgb *WeaponStatsGroupBy) BoolX(ctx context.Context) bool { + v, err := wsgb.Bool(ctx) + if err != nil { + panic(err) + } + return v +} + +func (wsgb *WeaponStatsGroupBy) sqlScan(ctx context.Context, v interface{}) error { + for _, f := range wsgb.fields { + if !weaponstats.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} + } + } + selector := wsgb.sqlQuery() + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := wsgb.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +func (wsgb *WeaponStatsGroupBy) sqlQuery() *sql.Selector { + selector := wsgb.sql.Select() + aggregation := make([]string, 0, len(wsgb.fns)) + for _, fn := range wsgb.fns { + aggregation = append(aggregation, fn(selector)) + } + // If no columns were selected in a custom aggregation function, the default + // selection is the fields used for "group-by", and the aggregation functions. + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(wsgb.fields)+len(wsgb.fns)) + for _, f := range wsgb.fields { + columns = append(columns, selector.C(f)) + } + for _, c := range aggregation { + columns = append(columns, c) + } + selector.Select(columns...) + } + return selector.GroupBy(selector.Columns(wsgb.fields...)...) +} + +// WeaponStatsSelect is the builder for selecting fields of WeaponStats entities. +type WeaponStatsSelect struct { + *WeaponStatsQuery + // intermediate query (i.e. traversal path). + sql *sql.Selector +} + +// Scan applies the selector query and scans the result into the given value. +func (wss *WeaponStatsSelect) Scan(ctx context.Context, v interface{}) error { + if err := wss.prepareQuery(ctx); err != nil { + return err + } + wss.sql = wss.WeaponStatsQuery.sqlQuery(ctx) + return wss.sqlScan(ctx, v) +} + +// ScanX is like Scan, but panics if an error occurs. +func (wss *WeaponStatsSelect) ScanX(ctx context.Context, v interface{}) { + if err := wss.Scan(ctx, v); err != nil { + panic(err) + } +} + +// Strings returns list of strings from a selector. It is only allowed when selecting one field. +func (wss *WeaponStatsSelect) Strings(ctx context.Context) ([]string, error) { + if len(wss.fields) > 1 { + return nil, errors.New("ent: WeaponStatsSelect.Strings is not achievable when selecting more than 1 field") + } + var v []string + if err := wss.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// StringsX is like Strings, but panics if an error occurs. +func (wss *WeaponStatsSelect) StringsX(ctx context.Context) []string { + v, err := wss.Strings(ctx) + if err != nil { + panic(err) + } + return v +} + +// String returns a single string from a selector. It is only allowed when selecting one field. +func (wss *WeaponStatsSelect) String(ctx context.Context) (_ string, err error) { + var v []string + if v, err = wss.Strings(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{weaponstats.Label} + default: + err = fmt.Errorf("ent: WeaponStatsSelect.Strings returned %d results when one was expected", len(v)) + } + return +} + +// StringX is like String, but panics if an error occurs. +func (wss *WeaponStatsSelect) StringX(ctx context.Context) string { + v, err := wss.String(ctx) + if err != nil { + panic(err) + } + return v +} + +// Ints returns list of ints from a selector. It is only allowed when selecting one field. +func (wss *WeaponStatsSelect) Ints(ctx context.Context) ([]int, error) { + if len(wss.fields) > 1 { + return nil, errors.New("ent: WeaponStatsSelect.Ints is not achievable when selecting more than 1 field") + } + var v []int + if err := wss.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// IntsX is like Ints, but panics if an error occurs. +func (wss *WeaponStatsSelect) IntsX(ctx context.Context) []int { + v, err := wss.Ints(ctx) + if err != nil { + panic(err) + } + return v +} + +// Int returns a single int from a selector. It is only allowed when selecting one field. +func (wss *WeaponStatsSelect) Int(ctx context.Context) (_ int, err error) { + var v []int + if v, err = wss.Ints(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{weaponstats.Label} + default: + err = fmt.Errorf("ent: WeaponStatsSelect.Ints returned %d results when one was expected", len(v)) + } + return +} + +// IntX is like Int, but panics if an error occurs. +func (wss *WeaponStatsSelect) IntX(ctx context.Context) int { + v, err := wss.Int(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64s returns list of float64s from a selector. It is only allowed when selecting one field. +func (wss *WeaponStatsSelect) Float64s(ctx context.Context) ([]float64, error) { + if len(wss.fields) > 1 { + return nil, errors.New("ent: WeaponStatsSelect.Float64s is not achievable when selecting more than 1 field") + } + var v []float64 + if err := wss.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// Float64sX is like Float64s, but panics if an error occurs. +func (wss *WeaponStatsSelect) Float64sX(ctx context.Context) []float64 { + v, err := wss.Float64s(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64 returns a single float64 from a selector. It is only allowed when selecting one field. +func (wss *WeaponStatsSelect) Float64(ctx context.Context) (_ float64, err error) { + var v []float64 + if v, err = wss.Float64s(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{weaponstats.Label} + default: + err = fmt.Errorf("ent: WeaponStatsSelect.Float64s returned %d results when one was expected", len(v)) + } + return +} + +// Float64X is like Float64, but panics if an error occurs. +func (wss *WeaponStatsSelect) Float64X(ctx context.Context) float64 { + v, err := wss.Float64(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bools returns list of bools from a selector. It is only allowed when selecting one field. +func (wss *WeaponStatsSelect) Bools(ctx context.Context) ([]bool, error) { + if len(wss.fields) > 1 { + return nil, errors.New("ent: WeaponStatsSelect.Bools is not achievable when selecting more than 1 field") + } + var v []bool + if err := wss.Scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// BoolsX is like Bools, but panics if an error occurs. +func (wss *WeaponStatsSelect) BoolsX(ctx context.Context) []bool { + v, err := wss.Bools(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bool returns a single bool from a selector. It is only allowed when selecting one field. +func (wss *WeaponStatsSelect) Bool(ctx context.Context) (_ bool, err error) { + var v []bool + if v, err = wss.Bools(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{weaponstats.Label} + default: + err = fmt.Errorf("ent: WeaponStatsSelect.Bools returned %d results when one was expected", len(v)) + } + return +} + +// BoolX is like Bool, but panics if an error occurs. +func (wss *WeaponStatsSelect) BoolX(ctx context.Context) bool { + v, err := wss.Bool(ctx) + if err != nil { + panic(err) + } + return v +} + +func (wss *WeaponStatsSelect) sqlScan(ctx context.Context, v interface{}) error { + rows := &sql.Rows{} + query, args := wss.sql.Query() + if err := wss.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (wss *WeaponStatsSelect) Modify(modifiers ...func(s *sql.Selector)) *WeaponStatsSelect { + wss.modifiers = append(wss.modifiers, modifiers...) + return wss +} diff --git a/ent/weaponstats_update.go b/ent/weaponstats_update.go new file mode 100644 index 0000000..c66933a --- /dev/null +++ b/ent/weaponstats_update.go @@ -0,0 +1,575 @@ +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "context" + "csgowtfd/ent/predicate" + "csgowtfd/ent/stats" + "csgowtfd/ent/weaponstats" + "fmt" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// WeaponStatsUpdate is the builder for updating WeaponStats entities. +type WeaponStatsUpdate struct { + config + hooks []Hook + mutation *WeaponStatsMutation +} + +// Where appends a list predicates to the WeaponStatsUpdate builder. +func (wsu *WeaponStatsUpdate) Where(ps ...predicate.WeaponStats) *WeaponStatsUpdate { + wsu.mutation.Where(ps...) + return wsu +} + +// SetVictim sets the "victim" field. +func (wsu *WeaponStatsUpdate) SetVictim(u uint64) *WeaponStatsUpdate { + wsu.mutation.ResetVictim() + wsu.mutation.SetVictim(u) + return wsu +} + +// AddVictim adds u to the "victim" field. +func (wsu *WeaponStatsUpdate) AddVictim(u uint64) *WeaponStatsUpdate { + wsu.mutation.AddVictim(u) + return wsu +} + +// SetDmg sets the "dmg" field. +func (wsu *WeaponStatsUpdate) SetDmg(u uint) *WeaponStatsUpdate { + wsu.mutation.ResetDmg() + wsu.mutation.SetDmg(u) + return wsu +} + +// AddDmg adds u to the "dmg" field. +func (wsu *WeaponStatsUpdate) AddDmg(u uint) *WeaponStatsUpdate { + wsu.mutation.AddDmg(u) + return wsu +} + +// SetEqType sets the "eq_type" field. +func (wsu *WeaponStatsUpdate) SetEqType(i int) *WeaponStatsUpdate { + wsu.mutation.ResetEqType() + wsu.mutation.SetEqType(i) + return wsu +} + +// AddEqType adds i to the "eq_type" field. +func (wsu *WeaponStatsUpdate) AddEqType(i int) *WeaponStatsUpdate { + wsu.mutation.AddEqType(i) + return wsu +} + +// SetHitGroup sets the "hit_group" field. +func (wsu *WeaponStatsUpdate) SetHitGroup(i int) *WeaponStatsUpdate { + wsu.mutation.ResetHitGroup() + wsu.mutation.SetHitGroup(i) + return wsu +} + +// AddHitGroup adds i to the "hit_group" field. +func (wsu *WeaponStatsUpdate) AddHitGroup(i int) *WeaponStatsUpdate { + wsu.mutation.AddHitGroup(i) + return wsu +} + +// SetStatID sets the "stat" edge to the Stats entity by ID. +func (wsu *WeaponStatsUpdate) SetStatID(id int) *WeaponStatsUpdate { + wsu.mutation.SetStatID(id) + return wsu +} + +// SetNillableStatID sets the "stat" edge to the Stats entity by ID if the given value is not nil. +func (wsu *WeaponStatsUpdate) SetNillableStatID(id *int) *WeaponStatsUpdate { + if id != nil { + wsu = wsu.SetStatID(*id) + } + return wsu +} + +// SetStat sets the "stat" edge to the Stats entity. +func (wsu *WeaponStatsUpdate) SetStat(s *Stats) *WeaponStatsUpdate { + return wsu.SetStatID(s.ID) +} + +// Mutation returns the WeaponStatsMutation object of the builder. +func (wsu *WeaponStatsUpdate) Mutation() *WeaponStatsMutation { + return wsu.mutation +} + +// ClearStat clears the "stat" edge to the Stats entity. +func (wsu *WeaponStatsUpdate) ClearStat() *WeaponStatsUpdate { + wsu.mutation.ClearStat() + return wsu +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (wsu *WeaponStatsUpdate) Save(ctx context.Context) (int, error) { + var ( + err error + affected int + ) + if len(wsu.hooks) == 0 { + affected, err = wsu.sqlSave(ctx) + } else { + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*WeaponStatsMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + wsu.mutation = mutation + affected, err = wsu.sqlSave(ctx) + mutation.done = true + return affected, err + }) + for i := len(wsu.hooks) - 1; i >= 0; i-- { + if wsu.hooks[i] == nil { + return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") + } + mut = wsu.hooks[i](mut) + } + if _, err := mut.Mutate(ctx, wsu.mutation); err != nil { + return 0, err + } + } + return affected, err +} + +// SaveX is like Save, but panics if an error occurs. +func (wsu *WeaponStatsUpdate) SaveX(ctx context.Context) int { + affected, err := wsu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (wsu *WeaponStatsUpdate) Exec(ctx context.Context) error { + _, err := wsu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (wsu *WeaponStatsUpdate) ExecX(ctx context.Context) { + if err := wsu.Exec(ctx); err != nil { + panic(err) + } +} + +func (wsu *WeaponStatsUpdate) sqlSave(ctx context.Context) (n int, err error) { + _spec := &sqlgraph.UpdateSpec{ + Node: &sqlgraph.NodeSpec{ + Table: weaponstats.Table, + Columns: weaponstats.Columns, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: weaponstats.FieldID, + }, + }, + } + if ps := wsu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := wsu.mutation.Victim(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint64, + Value: value, + Column: weaponstats.FieldVictim, + }) + } + if value, ok := wsu.mutation.AddedVictim(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint64, + Value: value, + Column: weaponstats.FieldVictim, + }) + } + if value, ok := wsu.mutation.Dmg(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: weaponstats.FieldDmg, + }) + } + if value, ok := wsu.mutation.AddedDmg(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: weaponstats.FieldDmg, + }) + } + if value, ok := wsu.mutation.EqType(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: weaponstats.FieldEqType, + }) + } + if value, ok := wsu.mutation.AddedEqType(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: weaponstats.FieldEqType, + }) + } + if value, ok := wsu.mutation.HitGroup(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: weaponstats.FieldHitGroup, + }) + } + if value, ok := wsu.mutation.AddedHitGroup(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: weaponstats.FieldHitGroup, + }) + } + if wsu.mutation.StatCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: weaponstats.StatTable, + Columns: []string{weaponstats.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 := wsu.mutation.StatIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: weaponstats.StatTable, + Columns: []string{weaponstats.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, wsu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{weaponstats.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} + } + return 0, err + } + return n, nil +} + +// WeaponStatsUpdateOne is the builder for updating a single WeaponStats entity. +type WeaponStatsUpdateOne struct { + config + fields []string + hooks []Hook + mutation *WeaponStatsMutation +} + +// SetVictim sets the "victim" field. +func (wsuo *WeaponStatsUpdateOne) SetVictim(u uint64) *WeaponStatsUpdateOne { + wsuo.mutation.ResetVictim() + wsuo.mutation.SetVictim(u) + return wsuo +} + +// AddVictim adds u to the "victim" field. +func (wsuo *WeaponStatsUpdateOne) AddVictim(u uint64) *WeaponStatsUpdateOne { + wsuo.mutation.AddVictim(u) + return wsuo +} + +// SetDmg sets the "dmg" field. +func (wsuo *WeaponStatsUpdateOne) SetDmg(u uint) *WeaponStatsUpdateOne { + wsuo.mutation.ResetDmg() + wsuo.mutation.SetDmg(u) + return wsuo +} + +// AddDmg adds u to the "dmg" field. +func (wsuo *WeaponStatsUpdateOne) AddDmg(u uint) *WeaponStatsUpdateOne { + wsuo.mutation.AddDmg(u) + return wsuo +} + +// SetEqType sets the "eq_type" field. +func (wsuo *WeaponStatsUpdateOne) SetEqType(i int) *WeaponStatsUpdateOne { + wsuo.mutation.ResetEqType() + wsuo.mutation.SetEqType(i) + return wsuo +} + +// AddEqType adds i to the "eq_type" field. +func (wsuo *WeaponStatsUpdateOne) AddEqType(i int) *WeaponStatsUpdateOne { + wsuo.mutation.AddEqType(i) + return wsuo +} + +// SetHitGroup sets the "hit_group" field. +func (wsuo *WeaponStatsUpdateOne) SetHitGroup(i int) *WeaponStatsUpdateOne { + wsuo.mutation.ResetHitGroup() + wsuo.mutation.SetHitGroup(i) + return wsuo +} + +// AddHitGroup adds i to the "hit_group" field. +func (wsuo *WeaponStatsUpdateOne) AddHitGroup(i int) *WeaponStatsUpdateOne { + wsuo.mutation.AddHitGroup(i) + return wsuo +} + +// SetStatID sets the "stat" edge to the Stats entity by ID. +func (wsuo *WeaponStatsUpdateOne) SetStatID(id int) *WeaponStatsUpdateOne { + wsuo.mutation.SetStatID(id) + return wsuo +} + +// SetNillableStatID sets the "stat" edge to the Stats entity by ID if the given value is not nil. +func (wsuo *WeaponStatsUpdateOne) SetNillableStatID(id *int) *WeaponStatsUpdateOne { + if id != nil { + wsuo = wsuo.SetStatID(*id) + } + return wsuo +} + +// SetStat sets the "stat" edge to the Stats entity. +func (wsuo *WeaponStatsUpdateOne) SetStat(s *Stats) *WeaponStatsUpdateOne { + return wsuo.SetStatID(s.ID) +} + +// Mutation returns the WeaponStatsMutation object of the builder. +func (wsuo *WeaponStatsUpdateOne) Mutation() *WeaponStatsMutation { + return wsuo.mutation +} + +// ClearStat clears the "stat" edge to the Stats entity. +func (wsuo *WeaponStatsUpdateOne) ClearStat() *WeaponStatsUpdateOne { + wsuo.mutation.ClearStat() + return wsuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (wsuo *WeaponStatsUpdateOne) Select(field string, fields ...string) *WeaponStatsUpdateOne { + wsuo.fields = append([]string{field}, fields...) + return wsuo +} + +// Save executes the query and returns the updated WeaponStats entity. +func (wsuo *WeaponStatsUpdateOne) Save(ctx context.Context) (*WeaponStats, error) { + var ( + err error + node *WeaponStats + ) + if len(wsuo.hooks) == 0 { + node, err = wsuo.sqlSave(ctx) + } else { + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*WeaponStatsMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + wsuo.mutation = mutation + node, err = wsuo.sqlSave(ctx) + mutation.done = true + return node, err + }) + for i := len(wsuo.hooks) - 1; i >= 0; i-- { + if wsuo.hooks[i] == nil { + return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") + } + mut = wsuo.hooks[i](mut) + } + if _, err := mut.Mutate(ctx, wsuo.mutation); err != nil { + return nil, err + } + } + return node, err +} + +// SaveX is like Save, but panics if an error occurs. +func (wsuo *WeaponStatsUpdateOne) SaveX(ctx context.Context) *WeaponStats { + node, err := wsuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (wsuo *WeaponStatsUpdateOne) Exec(ctx context.Context) error { + _, err := wsuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (wsuo *WeaponStatsUpdateOne) ExecX(ctx context.Context) { + if err := wsuo.Exec(ctx); err != nil { + panic(err) + } +} + +func (wsuo *WeaponStatsUpdateOne) sqlSave(ctx context.Context) (_node *WeaponStats, err error) { + _spec := &sqlgraph.UpdateSpec{ + Node: &sqlgraph.NodeSpec{ + Table: weaponstats.Table, + Columns: weaponstats.Columns, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: weaponstats.FieldID, + }, + }, + } + id, ok := wsuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing WeaponStats.ID for update")} + } + _spec.Node.ID.Value = id + if fields := wsuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, weaponstats.FieldID) + for _, f := range fields { + if !weaponstats.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != weaponstats.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := wsuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := wsuo.mutation.Victim(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint64, + Value: value, + Column: weaponstats.FieldVictim, + }) + } + if value, ok := wsuo.mutation.AddedVictim(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint64, + Value: value, + Column: weaponstats.FieldVictim, + }) + } + if value, ok := wsuo.mutation.Dmg(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: weaponstats.FieldDmg, + }) + } + if value, ok := wsuo.mutation.AddedDmg(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: value, + Column: weaponstats.FieldDmg, + }) + } + if value, ok := wsuo.mutation.EqType(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: weaponstats.FieldEqType, + }) + } + if value, ok := wsuo.mutation.AddedEqType(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: weaponstats.FieldEqType, + }) + } + if value, ok := wsuo.mutation.HitGroup(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: weaponstats.FieldHitGroup, + }) + } + if value, ok := wsuo.mutation.AddedHitGroup(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: weaponstats.FieldHitGroup, + }) + } + if wsuo.mutation.StatCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: weaponstats.StatTable, + Columns: []string{weaponstats.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 := wsuo.mutation.StatIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: weaponstats.StatTable, + Columns: []string{weaponstats.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 = &WeaponStats{config: wsuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, wsuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{weaponstats.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} + } + return nil, err + } + return _node, nil +} diff --git a/go.mod b/go.mod index ab6de20..9f270b8 100644 --- a/go.mod +++ b/go.mod @@ -10,21 +10,22 @@ require ( github.com/go-redis/redis/v8 v8.11.4 github.com/gorilla/handlers v1.5.1 github.com/gorilla/mux v1.8.0 + github.com/lib/pq v1.10.2 github.com/markus-wa/demoinfocs-golang/v2 v2.10.1 github.com/mattn/go-sqlite3 v1.14.8 github.com/sirupsen/logrus v1.8.1 github.com/wercker/journalhook v0.0.0-20180428041537-5d0a5ae867b3 go.uber.org/ratelimit v0.2.0 google.golang.org/protobuf v1.27.1 - gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b ) require ( github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect - github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e // indirect + github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect - github.com/felixge/httpsnoop v1.0.1 // indirect + github.com/felixge/httpsnoop v1.0.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 // indirect github.com/google/uuid v1.3.0 // indirect @@ -37,7 +38,7 @@ require ( github.com/vmihailenco/go-tinylfu v0.2.2 // indirect github.com/vmihailenco/msgpack/v5 v5.3.4 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect - golang.org/x/exp v0.0.0-20210916165020-5cb4fee858ee // indirect + golang.org/x/exp v0.0.0-20211012155715-ffe10e552389 // indirect golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect - golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect + golang.org/x/sys v0.0.0-20211013075003-97ac67df715c // indirect ) diff --git a/go.sum b/go.sum index 3619f72..b24a2f5 100644 --- a/go.sum +++ b/go.sum @@ -66,8 +66,9 @@ github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e h1:Wf6HqHfScWJN9/ZjdUKyjop4mf3Qdd+1TvvltAvM3m8= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf h1:iW4rZ826su+pqaw19uhpSCzhj44qo35pNgKFGqzDKkU= +github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= @@ -92,8 +93,9 @@ github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.m github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/felixge/httpsnoop v1.0.1 h1:lvB5Jl89CsZtGIWuTcDM1E/vkVs49/Ml7JJe07l8SPQ= github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/felixge/httpsnoop v1.0.2 h1:+nS9g82KMXccJ/wp0zyRW9ZBHFETmMGtkk+2CTTrW4o= +github.com/felixge/httpsnoop v1.0.2/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= @@ -112,7 +114,6 @@ github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9 github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logr/logr v0.4.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= -github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4= github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4= github.com/go-redis/cache/v8 v8.4.3 h1:+RZ0pQM+zOd6h/oWCsOl3+nsCgii9rn26oCYmU87kN8= github.com/go-redis/cache/v8 v8.4.3/go.mod h1:5lQPQ63uyBt4aZuRmdvUJOJRRjPxfLtJtlcJ/z8o1jA= @@ -243,6 +244,7 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/lib/pq v1.10.2 h1:AqzbZs4ZoCBp+GtejcpCpcxM3zlSMx29dXbUSeVtJb8= github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= @@ -264,7 +266,6 @@ github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaO github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-sqlite3 v1.14.8 h1:gDp86IdQsN/xWjIEmr9MF6o9mpksUgh0fu+9ByFxzIU= github.com/mattn/go-sqlite3 v1.14.8/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= @@ -298,7 +299,6 @@ github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtb github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= -github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -378,12 +378,10 @@ github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasO github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= -github.com/spf13/cobra v1.1.3 h1:xghbfqPkxzxP3C/f3n5DdpAbdKLj4ZE4BWQI362l53M= github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= @@ -461,8 +459,9 @@ golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxT golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56/go.mod h1:JhuoJpWY28nO4Vef9tZUw9qufEGTyX1+7lmHxV5q5G4= golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= -golang.org/x/exp v0.0.0-20210916165020-5cb4fee858ee h1:qlrAyYdKz4o7rWVUjiKqQJMa4PEpd55fqBU8jpsl4Iw= golang.org/x/exp v0.0.0-20210916165020-5cb4fee858ee/go.mod h1:a3o/VtDNHN+dCVLEpzjjUHOzR+Ln3DHX056ZPzoZGGA= +golang.org/x/exp v0.0.0-20211012155715-ffe10e552389 h1:qFfBYVpJAdBCk6Nmd7ZbcyhGmKmv8fps+OyoOfpjvu8= +golang.org/x/exp v0.0.0-20211012155715-ffe10e552389/go.mod h1:a3o/VtDNHN+dCVLEpzjjUHOzR+Ln3DHX056ZPzoZGGA= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= @@ -483,7 +482,6 @@ golang.org/x/mod v0.1.1-0.20191209134235-331c550502dd/go.mod h1:s0Qsj1ACt9ePp/hM golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.5.1-0.20210830214625-1b1db11ec8f4 h1:7Qds88gNaRx0Dz/1wOwXlR7asekh1B1u26wEwN6FcEI= golang.org/x/mod v0.5.1-0.20210830214625-1b1db11ec8f4/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -553,8 +551,9 @@ golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211013075003-97ac67df715c h1:taxlMj0D/1sOAuv/CbSD+MMDof2vbyPTqz5FNYKpXt8= +golang.org/x/sys v0.0.0-20211013075003-97ac67df715c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -595,7 +594,6 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= -golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -671,8 +669,9 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/main.go b/main.go index 89d1110..51078d6 100644 --- a/main.go +++ b/main.go @@ -9,12 +9,14 @@ import ( "csgowtfd/ent/player" "csgowtfd/ent/stats" "csgowtfd/utils" + "entgo.io/ent/dialect/sql" "flag" "fmt" "github.com/go-redis/cache/v8" "github.com/go-redis/redis/v8" "github.com/gorilla/handlers" "github.com/gorilla/mux" + _ "github.com/lib/pq" _ "github.com/mattn/go-sqlite3" log "github.com/sirupsen/logrus" "github.com/wercker/journalhook" @@ -44,42 +46,6 @@ var ( journalLogFlag = flag.Bool("journal", false, "Log to systemd journal instead of stdout") ) -type PlayerResponse struct { - SteamID64 uint64 `json:"steamid64,string"` - Name string `json:"name"` - Avatar string `json:"avatar"` - VAC bool `json:"vac"` - Tracked bool `json:"tracked"` - VanityURL string `json:"vanity_url,omitempty"` - MatchStats utils.MatchStats `json:"match_stats,omitempty"` - Matches []*MatchResponse `json:"matches,omitempty"` -} - -type MatchResponse struct { - MatchId uint64 `json:"match_id,string"` - ShareCode string `json:"share_code"` - Map string `json:"map"` - Date time.Time `json:"date"` - Score [2]int `json:"score"` - Duration int `json:"duration"` - MatchResult int `json:"match_result"` - MaxRounds int `json:"max_rounds,omitempty"` - Parsed bool `json:"parsed"` - Stats []*StatsResponse `json:"stats"` -} - -type StatsResponse struct { - TeamID int `json:"team_id"` - Kills int `json:"kills"` - Deaths int `json:"deaths"` - Assists int `json:"assists"` - Headshot int `json:"headshot"` - MVP int `json:"mvp"` - Score int `json:"score"` - Player PlayerResponse `json:"player"` - Extended interface{} `json:"extended,omitempty"` -} - func housekeeping() { for { if !firstHK { @@ -98,9 +64,7 @@ func housekeeping() { continue } - for _, tPlayer := range tPlayerNeedSteamUpdate { - _, err = utils.UpdatePlayerFromSteam(tPlayer, conf.Steam.APIKey, db.Lock, rL) - } + _, err = utils.UpdatePlayerFromSteam(tPlayerNeedSteamUpdate, db.Client, conf.Steam.APIKey, db.Lock, rL) // getting new sharecodes if !demoLoader.GCReady { @@ -169,18 +133,22 @@ func getPlayer(w http.ResponseWriter, r *http.Request) { return } - response := PlayerResponse{ + response := utils.PlayerResponse{ SteamID64: tPlayer.ID, Name: tPlayer.Name, Avatar: tPlayer.AvatarURL, VAC: tPlayer.Vac, VanityURL: tPlayer.VanityURLReal, Tracked: tPlayer.AuthCode != "", - Matches: []*MatchResponse{}, + Matches: []*utils.MatchResponse{}, + } + + if !tPlayer.VacDate.IsZero() { + response.VACDate = &tPlayer.VacDate } db.Lock.RLock() - tMatches, err := tPlayer.QueryMatches().Order(ent.Desc(match.FieldDate)).Limit(20).All(context.Background()) + tMatches, err := tPlayer.QueryMatches().Order(ent.Desc(match.FieldDate)).Limit(10).All(context.Background()) db.Lock.RUnlock() if err != nil { log.Debugf("[GP] No matches found for player %s", id) @@ -226,9 +194,8 @@ func getPlayer(w http.ResponseWriter, r *http.Request) { } for _, iMatch := range tMatches { - mResponse := &MatchResponse{ + mResponse := &utils.MatchResponse{ MatchId: iMatch.ID, - ShareCode: iMatch.ShareCode, Map: iMatch.Map, Date: iMatch.Date, Score: [2]int{iMatch.ScoreTeamA, iMatch.ScoreTeamB}, @@ -236,31 +203,49 @@ func getPlayer(w http.ResponseWriter, r *http.Request) { MatchResult: iMatch.MatchResult, MaxRounds: iMatch.MaxRounds, Parsed: iMatch.DemoParsed, - Stats: []*StatsResponse{}, } db.Lock.RLock() - tStats, err := iMatch.QueryStats().Where(stats.HasPlayersWith(player.ID(tPlayer.ID))).WithPlayers().All(context.Background()) + tStats, err := iMatch.QueryStats().Modify(func(s *sql.Selector) { + s.Select(stats.FieldTeamID, stats.FieldKills, stats.FieldDeaths, stats.FieldAssists, stats.FieldHeadshot, + stats.FieldMvp, stats.FieldScore, stats.FieldMk2, stats.FieldMk3, stats.FieldMk4, stats.FieldMk5, + stats.FieldRankOld, stats.FieldRankNew, stats.FieldDmgTeam, stats.FieldDmgEnemy) + s.Where(sql.EQ(s.C(stats.PlayersColumn), tPlayer.ID)) + }).Only(context.Background()) db.Lock.RUnlock() if err != nil { response.Matches = append(response.Matches, mResponse) continue } - for _, iStats := range tStats { - sResponse := &StatsResponse{ - TeamID: iStats.TeamID, - Kills: iStats.Kills, - Deaths: iStats.Deaths, - Assists: iStats.Assists, - Headshot: iStats.Headshot, - MVP: iStats.Mvp, - Score: iStats.Score, - Extended: iStats.Extended, - } - - mResponse.Stats = append(mResponse.Stats, sResponse) + sResponse := &utils.StatsResponse{ + TeamID: tStats.TeamID, + Kills: tStats.Kills, + Deaths: tStats.Deaths, + Assists: tStats.Assists, + Headshot: tStats.Headshot, + MVP: tStats.Mvp, + Score: tStats.Score, } + + sResponse.MultiKills = &utils.MultiKills{ + Duo: tStats.Mk2, + Triple: tStats.Mk3, + Quad: tStats.Mk4, + Pent: tStats.Mk5, + } + + sResponse.Rank = &utils.Rank{ + Old: tStats.RankOld, + New: tStats.RankNew, + } + + sResponse.Dmg = &utils.Damage{ + Enemy: tStats.DmgEnemy, + Team: tStats.DmgTeam, + } + + mResponse.Stats = sResponse response.Matches = append(response.Matches, mResponse) } @@ -322,7 +307,7 @@ func postPlayerTrackMe(w http.ResponseWriter, r *http.Request) { } } - w.WriteHeader(http.StatusOK) + w.WriteHeader(http.StatusAccepted) } func getMatchParse(w http.ResponseWriter, r *http.Request) { @@ -344,7 +329,65 @@ func getMatchParse(w http.ResponseWriter, r *http.Request) { return } - w.WriteHeader(http.StatusOK) + w.WriteHeader(http.StatusAccepted) +} + +func getMatchWeapons(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Access-Control-Allow-Origin", conf.Httpd.CORSAllowDomains) + id := mux.Vars(r)["id"] + + if id == "" { + w.WriteHeader(http.StatusBadRequest) + return + } + + matchId, err := strconv.ParseUint(id, 10, 64) + if err != nil { + log.Warningf("[GM] Error parsing matchID %s: %v", id, err) + w.WriteHeader(http.StatusBadRequest) + return + } + + mResponse := make([]*utils.WeaponResponse, 0) + + db.Lock.RLock() + tStats, err := db.Client.Stats.Query().Where(stats.HasMatchesWith(match.ID(matchId))).All(context.Background()) + db.Lock.RUnlock() + if err != nil { + log.Warningf("[GMW] match %d not found: %+v", matchId, err) + w.WriteHeader(http.StatusNotFound) + return + } + + for _, stat := range tStats { + db.Lock.RLock() + mWs, err := stat.QueryWeaponStats().All(context.Background()) + db.Lock.RUnlock() + if err != nil { + log.Warningf("[GMW] Unbale to get WeaponStats for player %d: %v", stat.PlayerStats, err) + continue + } + + mWr := &utils.WeaponResponse{ + Player: &utils.PlayerResponse{SteamID64: stat.PlayerStats}, + } + + for _, wr := range mWs { + mWr.Eq = append(mWr.Eq, &utils.EqResponse{ + Victim: wr.Victim, + Type: wr.EqType, + HitGroup: wr.HitGroup, + Dmg: wr.Dmg, + }) + } + mResponse = append(mResponse, mWr) + } + + err = utils.SendJSON(mResponse, w) + if err != nil { + log.Errorf("[GM] JSON: %+v", err) + w.WriteHeader(http.StatusInternalServerError) + } } func getMatch(w http.ResponseWriter, r *http.Request) { @@ -372,7 +415,7 @@ func getMatch(w http.ResponseWriter, r *http.Request) { return } - mResponse := &MatchResponse{ + mResponse := &utils.MatchResponse{ MatchId: tMatch.ID, ShareCode: tMatch.ShareCode, Map: tMatch.Map, @@ -382,7 +425,7 @@ func getMatch(w http.ResponseWriter, r *http.Request) { MatchResult: tMatch.MatchResult, MaxRounds: tMatch.MaxRounds, Parsed: tMatch.DemoParsed, - Stats: []*StatsResponse{}, + Stats: []*utils.StatsResponse{}, } db.Lock.RLock() @@ -394,9 +437,11 @@ func getMatch(w http.ResponseWriter, r *http.Request) { return } + tmpStats := make([]*utils.StatsResponse, 0) + for _, iStats := range tStats { - sResponse := &StatsResponse{ - Player: PlayerResponse{ + sResponse := &utils.StatsResponse{ + Player: utils.PlayerResponse{ SteamID64: iStats.Edges.Players.ID, Name: iStats.Edges.Players.Name, Avatar: iStats.Edges.Players.AvatarURL, @@ -411,11 +456,65 @@ func getMatch(w http.ResponseWriter, r *http.Request) { Headshot: iStats.Headshot, MVP: iStats.Mvp, Score: iStats.Score, - Extended: iStats.Extended, + + Dmg: &utils.Damage{ + Team: iStats.DmgTeam, + Enemy: iStats.DmgEnemy, + UD: &utils.UD{ + HE: iStats.UdHe, + Smoke: iStats.UdSmoke, + Flash: iStats.UdFlash, + Decoy: iStats.UdDecoy, + Flames: iStats.UdFlames, + }, + HitGroup: &utils.HitGroup{ + Gear: iStats.HitGroupGear, + LeftLeg: iStats.HitGroupLeftLeg, + RightLeg: iStats.HitGroupRightLeg, + RightArm: iStats.HitGroupRightArm, + LeftArm: iStats.HitGroupLeftArm, + Stomach: iStats.HitGroupStomach, + Chest: iStats.HitGroupChest, + Head: iStats.HitGroupHead, + }, + }, + Color: iStats.Color.String(), + Crosshair: iStats.Crosshair, + KAST: iStats.Kast, + Rank: &utils.Rank{ + Old: iStats.RankOld, + New: iStats.RankNew, + }, + Flash: &utils.Flash{ + Total: &utils.SelfTeamEnemy{ + Enemy: iStats.FlashTotalEnemy, + Team: iStats.FlashTotalTeam, + Self: iStats.FlashTotalSelf, + }, + Duration: &utils.SelfTeamEnemy{ + Enemy: iStats.FlashDurationEnemy, + Team: iStats.FlashDurationTeam, + Self: iStats.FlashDurationSelf, + }, + }, + MultiKills: &utils.MultiKills{ + Duo: iStats.Mk2, + Triple: iStats.Mk3, + Quad: iStats.Mk4, + Pent: iStats.Mk5, + }, } - mResponse.Stats = append(mResponse.Stats, sResponse) + if !iStats.Edges.Players.VacDate.IsZero() { + switch s := sResponse.Player.(type) { + case utils.PlayerResponse: + s.VACDate = &iStats.Edges.Players.VacDate + } + } + + tmpStats = append(tmpStats, sResponse) } + mResponse.Stats = tmpStats err = utils.SendJSON(mResponse, w) if err != nil { @@ -461,13 +560,17 @@ func main() { db.Client, err = ent.Open(conf.Db.Driver, conf.Db.ConnectTo) if err != nil { - log.Panicf("Failed to open database %s: %v", "opencsgo.db", err) + log.Panicf("Failed to open database %s: %v", conf.Db.ConnectTo, err) } defer func(dbSQLite *ent.Client) { _ = dbSQLite.Close() }(db.Client) - if err := db.Client.Schema.Create(context.Background(), migrate.WithDropIndex(true), migrate.WithDropColumn(true)); err != nil { + if err := db.Client.Schema.Create( + context.Background(), + migrate.WithDropIndex(true), + migrate.WithDropColumn(true), + ); err != nil { log.Panicf("Automigrate failed: %v", err) } @@ -516,6 +619,7 @@ func main() { router.HandleFunc("/player/trackme", postPlayerTrackMe).Methods(http.MethodPost, http.MethodOptions) router.HandleFunc("/match/parse/{sharecode}", getMatchParse).Methods(http.MethodGet, http.MethodOptions) router.HandleFunc("/match/{id:[0-9]{19}}", getMatch).Methods(http.MethodGet, http.MethodOptions) + router.HandleFunc("/match/{id:[0-9]{19}}/weapons", getMatchWeapons).Methods(http.MethodGet, http.MethodOptions) router.Use(mux.CORSMethodMiddleware(router)) loggedRouter := handlers.LoggingHandler(os.Stdout, router) proxyRouter := handlers.ProxyHeaders(loggedRouter) diff --git a/utils/utils.go b/utils/utils.go index 363c405..b610097 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -7,7 +7,6 @@ import ( "csgowtfd/ent/player" "csgowtfd/ent/stats" "encoding/json" - "encoding/xml" "entgo.io/ent/dialect/sql" "fmt" "github.com/Philipp15b/go-steamapi" @@ -16,6 +15,7 @@ import ( "io" "io/ioutil" "net/http" + "path" "regexp" "strconv" "strings" @@ -83,6 +83,110 @@ type MatchStats struct { Loss int `json:"loss,omitempty"` } +type MultiKills struct { + Duo uint `json:"duo,omitempty"` + Triple uint `json:"triple,omitempty"` + Quad uint `json:"quad,omitempty"` + Pent uint `json:"pent,omitempty"` +} + +type Rank struct { + Old int `json:"old,omitempty"` + New int `json:"new,omitempty"` +} + +type HitGroup struct { + Head uint `json:"head,omitempty"` + Chest uint `json:"chest,omitempty"` + Stomach uint `json:"stomach,omitempty"` + LeftArm uint `json:"left_arm,omitempty"` + RightArm uint `json:"right_arm,omitempty"` + LeftLeg uint `json:"left_leg,omitempty"` + RightLeg uint `json:"right_leg,omitempty"` + Gear uint `json:"gear,omitempty"` +} + +type UD struct { + HE uint `json:"he,omitempty"` + Flames uint `json:"flames,omitempty"` + Flash uint `json:"flash,omitempty"` + Decoy uint `json:"decoy,omitempty"` + Smoke uint `json:"smoke,omitempty"` +} + +type Damage struct { + Enemy uint `json:"enemy,omitempty"` + Team uint `json:"team,omitempty"` + UD *UD `json:"ud,omitempty"` + HitGroup *HitGroup `json:"hit_group,omitempty"` +} + +type SelfTeamEnemy struct { + Self interface{} `json:"self,omitempty"` + Team interface{} `json:"team,omitempty"` + Enemy interface{} `json:"enemy,omitempty"` +} + +type Flash struct { + Duration *SelfTeamEnemy `json:"duration,omitempty"` + Total *SelfTeamEnemy `json:"total,omitempty"` +} + +type StatsResponse struct { + TeamID int `json:"team_id"` + Kills int `json:"kills"` + Deaths int `json:"deaths"` + Assists int `json:"assists"` + Headshot int `json:"headshot"` + MVP uint `json:"mvp"` + Score int `json:"score"` + Player interface{} `json:"player,omitempty"` + Rank *Rank `json:"rank,omitempty"` + MultiKills *MultiKills `json:"multi_kills,omitempty"` + Dmg *Damage `json:"dmg,omitempty"` + Flash *Flash `json:"flash,omitempty"` + Crosshair string `json:"crosshair,omitempty"` + Color string `json:"color,omitempty"` + KAST int `json:"kast,omitempty"` +} + +type PlayerResponse struct { + SteamID64 uint64 `json:"steamid64,string"` + Name string `json:"name"` + Avatar string `json:"avatar"` + VAC bool `json:"vac"` + VACDate *time.Time `json:"vac_date,omitempty"` + Tracked bool `json:"tracked"` + VanityURL string `json:"vanity_url,omitempty"` + MatchStats MatchStats `json:"match_stats,omitempty"` + Matches []*MatchResponse `json:"matches,omitempty"` +} + +type EqResponse struct { + Victim uint64 `json:"victim"` + Type int `json:"type"` + HitGroup int `json:"hit_group"` + Dmg uint `json:"dmg"` +} + +type WeaponResponse struct { + Player *PlayerResponse `json:"player"` + Eq []*EqResponse `json:"eq,omitempty"` +} + +type MatchResponse struct { + MatchId uint64 `json:"match_id,string"` + ShareCode string `json:"share_code,omitempty"` + Map string `json:"map"` + Date time.Time `json:"date"` + Score [2]int `json:"score"` + Duration int `json:"duration"` + MatchResult int `json:"match_result"` + MaxRounds int `json:"max_rounds,omitempty"` + Parsed bool `json:"parsed"` + Stats interface{} `json:"stats,omitempty"` +} + const ( steamID64Entry = "https://steamcommunity.com/profiles/%d?xml=1" steamVanityURLEntry = "https://steamcommunity.com/id/%s?xml=1" @@ -262,13 +366,13 @@ func GetPlayer(db *DBWithLock, id interface{}, apiKey string, rl ratelimit.Limit return GetPlayerFromSteamID64(db, steamID64, apiKey, rl) } - return GetPlayerFromVanityURL(db, e) + return GetPlayerFromVanityURL(db, e, apiKey, rl) default: return nil, fmt.Errorf("invalid arguments") } } -func GetPlayerFromVanityURL(db *DBWithLock, id string) (*ent.Player, error) { +func GetPlayerFromVanityURL(db *DBWithLock, id string, apiKey string, rl ratelimit.Limiter) (*ent.Player, error) { if id == "" { return nil, fmt.Errorf("invalid arguments") } @@ -279,28 +383,28 @@ func GetPlayerFromVanityURL(db *DBWithLock, id string) (*ent.Player, error) { if err == nil { return tPlayer, nil } else { - profile, err := SteamProfile2XML(id, 0) + rl.Take() + resp, err := steamapi.ResolveVanityURL(id, apiKey) if err != nil { return nil, err } - if profile.Error != "" { - return nil, fmt.Errorf("profile not found") + if resp.Success != 1 { + return nil, fmt.Errorf("vanity url not found") } - db.Lock.Lock() - nPlayer, err := db.Client.Player.Create().SetID(profile.SteamID64).SetVanityURL(strings.ToLower(profile.VanityURL)).SetVac(profile.VacBanned).SetAvatarURL(profile.AvatarURL).SetName(profile.ProfileName).Save(context.Background()) - db.Lock.Unlock() + nPlayer, err := GetPlayerFromSteamID64(db, resp.SteamID, apiKey, rl) if err != nil { return nil, err } + return nPlayer, nil } } func GetPlayerFromSteamID64(db *DBWithLock, steamID uint64, apiKey string, rl ratelimit.Limiter) (*ent.Player, error) { db.Lock.RLock() - tPlayer, err := db.Client.Player.Query().Where(player.ID(steamID)).Only(context.Background()) + tPlayer, err := db.Client.Player.Get(context.Background(), steamID) db.Lock.RUnlock() if err == nil { return tPlayer, nil @@ -312,75 +416,78 @@ func GetPlayerFromSteamID64(db *DBWithLock, steamID uint64, apiKey string, rl ra return nil, err } - nPlayer, err = UpdatePlayerFromSteam(nPlayer, apiKey, db.Lock, rl) + uPlayer, err := UpdatePlayerFromSteam([]*ent.Player{nPlayer}, db.Client, apiKey, db.Lock, rl) if err != nil { return nil, err } - return nPlayer, nil + + if len(uPlayer) > 0 { + return uPlayer[0], nil + } else { + return nil, nil + } } } -func SteamProfile2XML(id string, steamID64 uint64) (*CommunityXML, error) { - var r *http.Response - var err error - if steamID64 != 0 { - r, err = http.Get(fmt.Sprintf(steamID64Entry, steamID64)) - } else { - r, err = http.Get(fmt.Sprintf(steamVanityURLEntry, id)) - } - if err != nil { - return nil, err - } - defer func(Body io.ReadCloser) { - _ = Body.Close() - }(r.Body) +func UpdatePlayerFromSteam(players []*ent.Player, db *ent.Client, apiKey string, lock *sync.RWMutex, rl ratelimit.Limiter) ([]*ent.Player, error) { + var idsToUpdate []uint64 - body, err := ioutil.ReadAll(r.Body) - if err != nil { - return nil, err - } - - cXML := &CommunityXML{} - err = xml.Unmarshal(body, cXML) - if err != nil { - return nil, err - } - return cXML, nil -} - -func UpdatePlayerFromSteam(player *ent.Player, apiKey string, lock *sync.RWMutex, rl ratelimit.Limiter) (*ent.Player, error) { - profile, err := SteamProfile2XML("", player.ID) - if err != nil { - return nil, err - } - - if profile.Error != "" { - return nil, fmt.Errorf("profile not found") - } - - lock.Lock() - tPlayer, err := player.Update().SetName(profile.ProfileName).SetVac(profile.VacBanned).SetAvatarURL(profile.AvatarURL).SetSteamUpdated(time.Now().UTC()).SetVanityURL(strings.ToLower(profile.VanityURL)).SetVanityURLReal(profile.VanityURL).SetSteamUpdated(time.Now().UTC()).Save(context.Background()) - lock.Unlock() - if err != nil { - return nil, err + for _, updatePlayer := range players { + idsToUpdate = append(idsToUpdate, updatePlayer.ID) } rl.Take() - bans, err := steamapi.GetPlayerBans([]uint64{profile.SteamID64}, apiKey) + playerSum, err := steamapi.GetPlayerSummaries(idsToUpdate, apiKey) if err != nil { return nil, err } - if len(bans) > 0 && bans[0].NumberOfVACBans > 0 { - banDate := time.Now().UTC().AddDate(0, 0, -1*int(bans[0].DaysSinceLastBan)) + var nPlayers []*ent.Player + for _, pS := range playerSum { + // TODO: what happens if a player deleted their profile? + + // check for vanityURL + if SteamId64RegEx.MatchString(path.Base(pS.ProfileURL)) { + pS.ProfileURL = "" + } else { + pS.ProfileURL = path.Base(pS.ProfileURL) + } lock.Lock() - err := tPlayer.Update().SetVacCount(int(bans[0].NumberOfVACBans)).SetVacDate(banDate).Exec(context.Background()) + tPlayer, err := db.Player.UpdateOneID(pS.SteamID). + SetName(pS.PersonaName). + SetAvatarURL(pS.LargeAvatarURL). + SetSteamUpdated(time.Now().UTC()). + SetVanityURL(strings.ToLower(pS.ProfileURL)). + SetVanityURLReal(pS.ProfileURL). + SetSteamUpdated(time.Now().UTC()). + SetProfileCreated(time.Unix(pS.TimeCreated, 0).UTC()). + Save(context.Background()) lock.Unlock() if err != nil { return nil, err } + nPlayers = append(nPlayers, tPlayer) } - return tPlayer, nil + rl.Take() + bans, err := steamapi.GetPlayerBans(idsToUpdate, apiKey) + if err != nil { + return nil, err + } + + for _, ban := range bans { + if ban.NumberOfVACBans > 0 { + banDate := time.Now().UTC().AddDate(0, 0, -1*int(bans[0].DaysSinceLastBan)) + + lock.Lock() + err := db.Player.UpdateOneID(ban.SteamID).SetVacCount(int(ban.NumberOfVACBans)).SetVacDate(banDate).Exec(context.Background()) + lock.Unlock() + if err != nil { + return nil, err + } + } + } + + return nPlayers, nil }