[FEATURE] Detailed stats about player weapon usage and hitgroups (#1)
Reviewed-on: https://git.harting.dev/CSGOWTF/csgowtfd/pulls/1 Co-authored-by: Giovanni Harting <539@idlegandalf.com> Co-committed-by: Giovanni Harting <539@idlegandalf.com>
This commit is contained in:
@@ -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())
|
||||
|
@@ -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))
|
||||
|
129
ent/client.go
129
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
|
||||
@@ -81,6 +85,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
|
||||
Match: NewMatchClient(cfg),
|
||||
Player: NewPlayerClient(cfg),
|
||||
Stats: NewStatsClient(cfg),
|
||||
WeaponStats: NewWeaponStatsClient(cfg),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -102,6 +107,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
|
||||
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
|
||||
}
|
||||
|
@@ -27,6 +27,7 @@ type hooks struct {
|
||||
Match []ent.Hook
|
||||
Player []ent.Hook
|
||||
Stats []ent.Hook
|
||||
WeaponStats []ent.Hook
|
||||
}
|
||||
|
||||
// Options applies the options on the config object.
|
||||
|
@@ -6,6 +6,7 @@ import (
|
||||
"csgowtfd/ent/match"
|
||||
"csgowtfd/ent/player"
|
||||
"csgowtfd/ent/stats"
|
||||
"csgowtfd/ent/weaponstats"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
@@ -34,6 +35,7 @@ func columnChecker(table string) func(string) error {
|
||||
match.Table: match.ValidColumn,
|
||||
player.Table: player.ValidColumn,
|
||||
stats.Table: stats.ValidColumn,
|
||||
weaponstats.Table: weaponstats.ValidColumn,
|
||||
}
|
||||
check, ok := checks[table]
|
||||
if !ok {
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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)
|
||||
}
|
||||
|
@@ -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
|
||||
}
|
||||
|
4382
ent/mutation.go
4382
ent/mutation.go
File diff suppressed because it is too large
Load Diff
@@ -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=<sensitive>")
|
||||
builder.WriteString(", profile_created=")
|
||||
builder.WriteString(pl.ProfileCreated.Format(time.ANSIC))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
@@ -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 (
|
||||
|
@@ -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) {
|
||||
|
@@ -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,
|
||||
|
@@ -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)
|
||||
}
|
||||
|
@@ -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,
|
||||
|
@@ -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)
|
||||
|
@@ -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(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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),
|
||||
}
|
||||
}
|
||||
|
29
ent/schema/weaponstats.go
Normal file
29
ent/schema/weaponstats.go
Normal file
@@ -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(),
|
||||
}
|
||||
}
|
418
ent/stats.go
418
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
|
||||
}
|
||||
|
||||
// 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()
|
||||
}
|
||||
|
@@ -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)
|
||||
}
|
||||
}
|
||||
|
3092
ent/stats/where.go
3092
ent/stats/where.go
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||
|
@@ -8,6 +8,8 @@ import (
|
||||
"csgowtfd/ent/player"
|
||||
"csgowtfd/ent/predicate"
|
||||
"csgowtfd/ent/stats"
|
||||
"csgowtfd/ent/weaponstats"
|
||||
"database/sql/driver"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
@@ -29,7 +31,7 @@ type StatsQuery struct {
|
||||
// eager-loading edges.
|
||||
withMatches *MatchQuery
|
||||
withPlayers *PlayerQuery
|
||||
withFKs bool
|
||||
withWeaponStats *WeaponStatsQuery
|
||||
modifiers []func(s *sql.Selector)
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
@@ -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) {
|
||||
@@ -294,6 +318,7 @@ func (sq *StatsQuery) Clone() *StatsQuery {
|
||||
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
|
||||
}
|
||||
|
||||
|
3271
ent/stats_update.go
3271
ent/stats_update.go
File diff suppressed because it is too large
Load Diff
@@ -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.
|
||||
|
169
ent/weaponstats.go
Normal file
169
ent/weaponstats.go
Normal file
@@ -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
|
||||
}
|
||||
}
|
59
ent/weaponstats/weaponstats.go
Normal file
59
ent/weaponstats/weaponstats.go
Normal file
@@ -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
|
||||
}
|
485
ent/weaponstats/where.go
Normal file
485
ent/weaponstats/where.go
Normal file
@@ -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())
|
||||
})
|
||||
}
|
311
ent/weaponstats_create.go
Normal file
311
ent/weaponstats_create.go
Normal file
@@ -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)
|
||||
}
|
||||
}
|
111
ent/weaponstats_delete.go
Normal file
111
ent/weaponstats_delete.go
Normal file
@@ -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)
|
||||
}
|
1016
ent/weaponstats_query.go
Normal file
1016
ent/weaponstats_query.go
Normal file
File diff suppressed because it is too large
Load Diff
575
ent/weaponstats_update.go
Normal file
575
ent/weaponstats_update.go
Normal file
@@ -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
|
||||
}
|
11
go.mod
11
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
|
||||
)
|
||||
|
23
go.sum
23
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=
|
||||
|
238
main.go
238
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,
|
||||
sResponse := &utils.StatsResponse{
|
||||
TeamID: tStats.TeamID,
|
||||
Kills: tStats.Kills,
|
||||
Deaths: tStats.Deaths,
|
||||
Assists: tStats.Assists,
|
||||
Headshot: tStats.Headshot,
|
||||
MVP: tStats.Mvp,
|
||||
Score: tStats.Score,
|
||||
}
|
||||
|
||||
mResponse.Stats = append(mResponse.Stats, sResponse)
|
||||
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)
|
||||
|
219
utils/utils.go
219
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
|
||||
}
|
||||
}
|
||||
|
||||
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))
|
||||
if len(uPlayer) > 0 {
|
||||
return uPlayer[0], nil
|
||||
} else {
|
||||
r, err = http.Get(fmt.Sprintf(steamVanityURLEntry, id))
|
||||
return nil, nil
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer func(Body io.ReadCloser) {
|
||||
_ = Body.Close()
|
||||
}(r.Body)
|
||||
|
||||
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(players []*ent.Player, db *ent.Client, apiKey string, lock *sync.RWMutex, rl ratelimit.Limiter) ([]*ent.Player, error) {
|
||||
var idsToUpdate []uint64
|
||||
|
||||
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 {
|
||||
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()
|
||||
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)
|
||||
}
|
||||
|
||||
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 := tPlayer.Update().SetVacCount(int(bans[0].NumberOfVACBans)).SetVacDate(banDate).Exec(context.Background())
|
||||
err := db.Player.UpdateOneID(ban.SteamID).SetVacCount(int(ban.NumberOfVACBans)).SetVacDate(banDate).Exec(context.Background())
|
||||
lock.Unlock()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return tPlayer, nil
|
||||
}
|
||||
|
||||
return nPlayers, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user