Compare commits

108 Commits
1.0 ... master

Author SHA1 Message Date
5358d9dd0f update deps 2023-09-01 16:16:43 +02:00
1c14817e5e updated go-steamapi, minor log fixes 2023-08-08 11:40:29 +02:00
a2a9c8d391 updated to go-steamapi 1.1.1 2023-08-07 23:40:29 +02:00
dacc86dd83 updated deps; code cleanup; updated golangci linter conf 2023-08-07 22:38:24 +02:00
3fd0a4204b updated deps & regen ent 2023-05-16 18:09:10 +02:00
e9e3e02a39 set sitemap back to <10k, since 50k does not seem to work with some search engines 2023-03-26 12:04:55 +02:00
0e126df3db pass listen struct to defer func directly 2023-03-09 14:10:41 +01:00
7a5acb5fc3 added /sitemap/index and return 400 if index parsing fails 2023-03-09 12:15:43 +01:00
1cae00e85d restored 50k sitemaps 2023-03-06 01:52:15 +01:00
05b6f17136 reduced urls in sitemaps to 5k 2023-03-04 16:58:25 +01:00
8f11a3586a added 10k url limit; update dep 2023-03-04 16:14:31 +01:00
2f1c5d0d83 added gzip compression to sitemap endpoints 2023-03-04 15:03:18 +01:00
4a46e43ce7 added head requests to sitemaps 2023-03-04 00:22:17 +01:00
5c3abbe463 added /matches to sitemap 2023-03-03 21:09:12 +01:00
c5b8d90f3c update deps 2023-03-03 21:02:41 +01:00
793032ffd7 serve index on sitemap.xml 2023-03-03 20:53:29 +01:00
84f8f866b0 return 404 is no sitemap exists 2023-03-03 20:47:00 +01:00
762c137de1 updated gositemap 2023-03-03 20:44:11 +01:00
ea8a91c0d3 test different path param /2 2023-03-03 20:35:59 +01:00
2b0384e3a8 test different path param 2023-03-03 20:34:30 +01:00
ed283c92f3 replaced old module path in source 2023-03-03 20:16:12 +01:00
f7903d1781 upped go default version 2023-03-03 20:12:29 +01:00
83834c3f34 switched module path to new domain 2023-03-03 20:11:23 +01:00
727d530378 updated deps; switched sitemap lib; ent regen 2023-03-03 20:10:31 +01:00
e9a5daa9e3 merge loops 2022-12-29 18:49:49 +01:00
0060e82aff added avg ping recording 2022-12-29 18:47:37 +01:00
f6f73096e0 replace invalid utf8 chars in text messages 2022-12-22 02:52:39 +01:00
cb8185e5bb use buffer to deliver sitemap 2022-12-07 15:39:17 +01:00
ba1a1cf31f do not close writer prematurely 2022-12-07 15:31:12 +01:00
b6407514da fixed content length 2022-12-07 15:21:34 +01:00
97cf95185b added sitemap 2022-12-07 15:19:35 +01:00
eb8487d0c4 fixed demos not found error 2022-11-28 19:26:26 +01:00
56059d2cd0 separated rate limiter for sharecode endpoint 2022-11-28 19:05:58 +01:00
e99dfd320d fixed read on closed body 2022-11-28 18:05:43 +01:00
ca914ea42b logging improvements 2022-11-28 13:11:06 +01:00
d856b32139 fixed wrong player append logic 2022-11-28 13:01:59 +01:00
c6ddf14a26 fixed unmarshalling into nil-pointer 2022-11-28 12:53:04 +01:00
1ac07c2f5a reworked sharecode return 2022-11-28 12:48:19 +01:00
43c91b694e some more code cleanup 2022-11-27 20:02:31 +01:00
4304a5a1d6 more code cleanup 2022-11-27 01:24:10 +01:00
4b2c948a9f updated golangci linter config 2022-11-20 19:19:47 +01:00
741fe4c4dd final linter fixes 2022-11-20 18:34:19 +01:00
64fd38709b more linter fixes 2022-11-20 18:31:09 +01:00
5b938f4d06 updated deps, added golangci linter 2022-11-20 18:11:52 +01:00
d10a134a34 fixed no reconnect after error from login handler 2022-11-20 14:27:27 +01:00
6543226526 improved log message 2022-11-16 08:49:33 +01:00
40f95cfb6e error handling for tracked players having no match found 2022-11-16 08:33:09 +01:00
cd58741188 init connectionwait 2022-11-04 23:18:20 +01:00
984cc51ead minor inspection fix 2022-11-03 03:47:01 +01:00
7fda18a182 added missing commit to loader 2022-11-03 03:42:00 +01:00
3e4b90a1bd some formatting fixes 2022-11-03 03:39:22 +01:00
4d36ce8899 fixed inverted stop logic 2022-11-03 03:23:26 +01:00
8e9fc43e4c use log format closer to apache common 2022-11-03 03:21:46 +01:00
6db43ad5f0 removed leftover gorilla mux 2022-11-03 03:20:37 +01:00
abd8b74c08 switched to transactional queries for demo loading & parsing 2022-11-03 03:18:24 +01:00
ff3bbe0037 updated deps; regen ent 2022-11-03 02:19:19 +01:00
4b256dd594 fixed new lang selector 2022-09-13 13:28:05 +02:00
20289eb01f fixed panic if no Accept-Lang header os set 2022-09-13 06:04:40 +02:00
64cba30917 switched to go-retry for steam login; moved match reparsing higher in housekeeping 2022-08-26 17:15:59 +02:00
25965cdde7 use better demo locking to prevent double parsing 2022-08-20 16:03:39 +02:00
657ca32bb3 updated deps; regen ent 2022-08-15 12:10:15 +02:00
b8b9f82067 use fallback if not x-forwarded-for is present 2022-05-17 23:47:24 +02:00
2300d740d2 fixed x-forwarded-for 2022-05-16 22:14:27 +02:00
2887db2d4b added trusted proxies 2022-05-16 22:09:24 +02:00
e3ee2a5e08 code cleanup 2022-05-15 14:22:19 +02:00
49344e0a04 check if sender exists 2022-04-29 03:37:57 +02:00
04b42d47ab fixed missing function 2022-04-17 21:12:06 +02:00
6ffefa3616 fixed query param translate 2022-04-17 20:44:39 +02:00
9ae02cf593 switched to gin 2022-04-17 20:42:15 +02:00
39aea94a59 just check if decryption key is 16 bytes long 2022-04-03 18:35:00 +02:00
caf173eb1c fixed decryption key not being 16 bytes long 2022-04-03 18:30:46 +02:00
0cf73c2aab fixed wrong batch size calc 2022-04-01 16:08:24 +02:00
8a3385bdc4 revert player-based locks 2022-03-31 19:19:05 +02:00
bb13027b93 fixed uninitalized maps 2022-03-30 20:55:27 +02:00
acbfb97014 switched to rate.Limiter 2022-03-30 15:32:25 +02:00
ac512aec2f updated deps & goent 2022-03-30 15:14:35 +02:00
cecdbc7a00 lock player, so that only one match can be parsed at a time/player 2022-03-30 15:11:30 +02:00
9834095806 move login retry max to config 2022-03-07 12:56:56 +01:00
95c92d44f8 improvements around connection logic 2022-03-02 09:58:36 +01:00
e350f940c8 improved logging 2022-03-01 21:28:36 +01:00
0d2a5ef084 fixed initial steam connection /2 2022-03-01 21:24:46 +01:00
126e96a4a9 fixed initial steam connection 2022-03-01 21:23:34 +01:00
d0679bd3b7 another try at improving connection handling 2022-03-01 21:21:24 +01:00
7260bedfa4 do not return translation if it matches the src text 2022-02-26 09:34:26 +01:00
8aaf60005d fixed error handling 2022-02-24 08:23:31 +01:00
fd5a065de2 added more login failed handling to steam connection manager 2022-02-23 07:08:00 +01:00
11b08e42a3 corrected small typo 2022-02-16 07:19:43 +01:00
a80d8af91b fixed wrong else position 2022-02-12 02:59:56 +01:00
442add4a29 fixed translations being sent regardless of setting 2022-02-12 02:58:35 +01:00
47fce4fc1a fixed lang being wrongly used 2022-02-12 02:53:38 +01:00
ede3b58f7e added some debugging for language selections 2022-02-12 02:47:28 +01:00
1e2541c76b added caching to chat translation 2022-02-12 02:19:23 +01:00
8c672f7186 added timout to deepl post request 2022-02-12 01:59:32 +01:00
8fe8ec5233 moved translation to utils.go 2022-02-12 01:51:42 +01:00
5d299dfa17 do not add language tags to already good language 2022-02-12 01:27:21 +01:00
f2a859d084 fixed module path; added translate endpoint to chat API 2022-02-12 01:18:29 +01:00
440aa41396 added timeouts to config 2022-02-04 15:07:07 +01:00
cc2c40dc56 fixed all demos being skipped as currently parsing 2022-02-04 07:13:29 +01:00
466a000c86 reworked preventing parsing one match multiple times 2022-02-04 05:43:29 +01:00
6a4e2f3ee3 prevent HK from trying to reparse while parsing is in progress 2022-02-03 17:15:32 +01:00
182c7d8fc1 tracking tickrate 2022-02-03 16:27:29 +01:00
ff0ea43cea do not warn about missing avg rank 2022-02-02 11:49:08 +01:00
ede713c3df do not pass pointer to cache.Cache.Get() 2022-02-01 19:55:09 +01:00
f6b28cb4d2 fixed time not being updated 2022-02-01 19:41:43 +01:00
1aa7cc260a update steam profiles only once a day 2022-02-01 19:23:41 +01:00
4b3b8d8053 trim whitespaces so sharecode does match 2022-02-01 03:17:37 +01:00
c822ce9396 try parsing match first 2022-02-01 02:31:00 +01:00
26c5e0558c return 400 if player without matches tries to track himself without providing a valid sharecode 2022-02-01 00:53:56 +01:00
74 changed files with 7579 additions and 13813 deletions

95
.golangci.yaml Normal file
View File

@@ -0,0 +1,95 @@
linters-settings:
dupl:
threshold: 100
goconst:
min-len: 3
min-occurrences: 4
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
disabled-checks:
- whyNoLint
- filepathJoin
gomnd:
checks:
- argument
- case
- condition
- return
ignored-numbers:
- '0'
- '0.5'
- '1'
- '2'
- '3'
- '4'
- '5'
- '6'
- '7'
- '8'
- '9'
- '10'
- '20'
- '100'
- '1000'
ignored-functions:
- strings.SplitN
- os.OpenFile
- os.MkdirAll
- os.WriteFile
govet:
check-shadowing: false
lll:
line-length: 140
misspell:
locale: US
nolintlint:
allow-unused: false # report any unused nolint directives
require-explanation: false # don't require an explanation for nolint directives
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
tagliatelle:
case:
use-field-name: true
rules:
# Any struct tag type can be used.
# Support string case: `camel`, `pascal`, `kebab`, `snake`, `upperSnake`, `goCamel`, `goPascal`, `goKebab`, `goSnake`, `upper`, `lower`, `header`.
json: snake
yaml: snake
xml: camel
linters:
enable-all: true
disable:
- gochecknoglobals
- depguard
- gci
- gofumpt
- goimports
- varnamelen
- funlen
- cyclop
- wsl
- nosnakecase
- nlreturn
- godot
- nestif
- wrapcheck
- gocognit
- gocyclo
- maintidx
- nonamedreturns
- exhaustivestruct
- exhaustruct
- forcetypeassert
- godox
- nakedret
- tagalign
- maligned
# remove for new projects
- errname
- goerr113
- tagliatelle

View File

@@ -17,6 +17,8 @@ steam:
rate_per_sec: 1
sentry: ".sentry"
login_key: ".login_key"
# maximum amount of time (in minutes) to wait before trying to reconnect to steam
max_retry_wait: 30
redis:
address: "localhost:6379"
@@ -43,3 +45,18 @@ csgowtfd:
demos_expire: 30
# ms between shots to count as spray
spray_timeout: 500
# timeouts
timeout:
# seconds before incoming request with no data send timeout
read: 5
# seconds to write a response before timeout
write: 30
# seconds before closing idle connections
idle: 120
deepl:
base_url: api-free.deepl.com
# get your API key on deepl.com
api_key: <api_key>
# timeout in sec to wait for deepl response
timeout: 15

View File

@@ -2,21 +2,20 @@ package csgo
import (
"context"
"csgowtfd/ent"
"csgowtfd/utils"
"fmt"
"github.com/an0nfunc/go-steam/v3"
"github.com/an0nfunc/go-steam/v3/csgo/protocol/protobuf"
"github.com/an0nfunc/go-steam/v3/netutil"
"github.com/an0nfunc/go-steam/v3/protocol/gamecoordinator"
"github.com/an0nfunc/go-steam/v3/protocol/steamlang"
"github.com/go-redis/cache/v8"
"github.com/pkg/errors"
"github.com/sethvargo/go-retry"
log "github.com/sirupsen/logrus"
"go.uber.org/ratelimit"
"golang.org/x/time/rate"
"google.golang.org/protobuf/proto"
"io/ioutil"
"os"
"strconv"
"somegit.dev/csgowtf/csgowtfd/ent"
"somegit.dev/csgowtf/csgowtfd/utils"
"strings"
"sync"
"time"
@@ -24,6 +23,8 @@ import (
const (
APPID = 730
LoginFailed = iota
LoginSuccess
)
type DemoMatchLoaderConfig struct {
@@ -32,12 +33,13 @@ type DemoMatchLoaderConfig struct {
AuthCode string
Sentry string
LoginKey string
Db *ent.Client
DB *ent.Client
Worker int
ApiKey string
RateLimit ratelimit.Limiter
APIKey string
RateLimit *rate.Limiter
Cache *cache.Cache
SprayTimeout int
RetryTimeout int
}
type DemoMatchLoader struct {
@@ -45,37 +47,62 @@ type DemoMatchLoader struct {
GCReady bool
steamLogin *steam.LogOnDetails
matchRecv chan *protobuf.CMsgGCCStrike15V2_MatchList
cmList []*netutil.PortAddr
sentryFile string
loginKey string
db *ent.Client
dp *DemoParser
parseDemo chan *Demo
parseMap map[string]bool
parseMapL *sync.Mutex
parseMapL *sync.RWMutex
cache *cache.Cache
connecting bool
connectionWait retry.Backoff
connectionWaitTmpl retry.Backoff
connectFeedback chan int
LoggedIn bool
}
func AccountId2SteamId(accId uint32) uint64 {
return uint64(accId) + 76561197960265728
func AccountID2SteamID(accID uint32) uint64 {
return uint64(accID) + 76561197960265728 //nolint:gomnd
}
func SteamId2AccountId(steamId uint64) uint32 {
return uint32(steamId - 76561197960265728)
func SteamID2AccountID(steamID uint64) uint32 {
return uint32(steamID - 76561197960265728) //nolint:gomnd
}
func playerStatsFromRound(round *protobuf.CMsgGCCStrike15V2_MatchmakingServerRoundStats, p *ent.Player) (kills int32, deaths int32, assists int32, headshots int32, score int32, mvps int32) {
func playerStatsFromRound(round *protobuf.CMsgGCCStrike15V2_MatchmakingServerRoundStats, p *ent.Player) (kills int32,
deaths int32, assists int32, headshots int32, score int32, mvps int32) {
for i, acc := range round.GetReservation().GetAccountIds() {
if AccountId2SteamId(acc) == p.ID {
return round.GetKills()[i], round.GetDeaths()[i], round.GetAssists()[i], round.GetEnemyHeadshots()[i], round.GetScores()[i], round.GetMvps()[i]
if AccountID2SteamID(acc) == p.ID {
return round.GetKills()[i], round.GetDeaths()[i], round.GetAssists()[i], round.GetEnemyHeadshots()[i],
round.GetScores()[i], round.GetMvps()[i]
}
}
return 0, 0, 0, 0, 0, 0
}
func (d *DemoMatchLoader) HandleGCPacket(pkg *gamecoordinator.GCPacket) {
func (dml *DemoMatchLoader) IsLoading(demo *Demo) bool {
dml.parseMapL.RLock()
defer dml.parseMapL.RUnlock()
if _, ok := dml.parseMap[demo.ShareCode]; ok {
return true
}
return false
}
func (dml *DemoMatchLoader) unlockDemo(demo *Demo) {
dml.parseMapL.Lock()
defer dml.parseMapL.Unlock()
delete(dml.parseMap, demo.ShareCode)
}
func (dml *DemoMatchLoader) lockDemo(demo *Demo) {
dml.parseMapL.Lock()
defer dml.parseMapL.Unlock()
dml.parseMap[demo.ShareCode] = true
}
func (dml *DemoMatchLoader) HandleGCPacket(pkg *gamecoordinator.GCPacket) {
switch pkg.MsgType {
case uint32(protobuf.EGCBaseClientMsg_k_EMsgGCClientWelcome):
msg := &protobuf.CMsgClientWelcome{}
@@ -84,324 +111,335 @@ func (d *DemoMatchLoader) HandleGCPacket(pkg *gamecoordinator.GCPacket) {
log.Errorf("[DL] Unable to unmarshal event %v: %v", pkg.MsgType, err)
}
log.Debugf("[GC] Welcome: %+v", msg)
d.GCReady = true
dml.GCReady = true
case uint32(protobuf.EGCBaseClientMsg_k_EMsgGCClientConnectionStatus):
msg := &protobuf.CMsgConnectionStatus{}
err := proto.Unmarshal(pkg.Body, msg)
if err != nil {
log.Errorf("[DL] Unable to unmarshal event %v: %v", pkg.MsgType, err)
log.Errorf("[GC] Unable to unmarshal event %v: %v", pkg.MsgType, err)
}
log.Debugf("[GC] Status: %+v", msg)
if msg.GetStatus() != protobuf.GCConnectionStatus_GCConnectionStatus_HAVE_SESSION {
d.GCReady = false
go d.greetGC()
dml.GCReady = false
go dml.greetGC()
}
case uint32(protobuf.ECsgoGCMsg_k_EMsgGCCStrike15_v2_GC2ClientGlobalStats):
msg := &protobuf.GlobalStatistics{}
err := proto.Unmarshal(pkg.Body, msg)
if err != nil {
log.Errorf("[DL] Unable to unmarshal event %v: %v", pkg.MsgType, err)
log.Errorf("[GC] Unable to unmarshal event %v: %v", pkg.MsgType, err)
}
log.Debugf("[GC] Stats: %+v", msg)
d.GCReady = true
dml.GCReady = true
case uint32(protobuf.ECsgoGCMsg_k_EMsgGCCStrike15_v2_MatchList):
msg := &protobuf.CMsgGCCStrike15V2_MatchList{}
err := proto.Unmarshal(pkg.Body, msg)
if err != nil {
log.Errorf("[DL] Unable to unmarshal event %v: %v", pkg.MsgType, err)
log.Errorf("[GC] Unable to unmarshal event %v: %v", pkg.MsgType, err)
}
d.matchRecv <- msg
dml.matchRecv <- msg
default:
log.Debugf("[GC] Unhandled GC message: %+v", pkg)
log.Debugf("[GC] Unhandled message: %+v", pkg)
}
}
func (d *DemoMatchLoader) getMatchDetails(sharecode string) (*protobuf.CMsgGCCStrike15V2_MatchList, error) {
if !d.GCReady {
func (dml *DemoMatchLoader) getMatchDetails(sharecode string) (*protobuf.CMsgGCCStrike15V2_MatchList, error) {
if !dml.GCReady {
return nil, fmt.Errorf("gc not ready")
}
matchId, outcomeId, tokenId, err := DecodeSharecode(sharecode)
matchID, outcomeID, tokenID, err := DecodeSharecode(sharecode)
if err != nil {
return nil, err
}
err = d.requestDemoInfo(matchId, outcomeId, uint32(tokenId))
err = dml.requestDemoInfo(matchID, outcomeID, uint32(tokenID))
if err != nil {
return nil, err
}
for {
select {
case matchDetails := <-d.matchRecv:
if *matchDetails.Matches[0].Matchid == matchId {
for matchDetails := range dml.matchRecv {
if *matchDetails.Matches[0].Matchid == matchID {
return matchDetails, nil
} else {
d.matchRecv <- matchDetails
}
}
dml.matchRecv <- matchDetails
}
return nil, err
}
func (d *DemoMatchLoader) connectToSteam() error {
if d.client.Connected() {
func (dml *DemoMatchLoader) connectToSteam() error {
if dml.client.Connected() {
return nil
}
_, err := d.client.Connect()
if err != nil {
if _, err := dml.client.Connect(); err != nil {
return err
}
return nil
}
func (d *DemoMatchLoader) Setup(config *DemoMatchLoaderConfig) error {
d.loginKey = config.LoginKey
d.sentryFile = config.Sentry
d.db = config.Db
d.dp = &DemoParser{}
d.parseMap = map[string]bool{}
d.parseMapL = new(sync.Mutex)
d.cache = config.Cache
err := d.dp.Setup(config.Db, config.Worker, config.SprayTimeout)
func (dml *DemoMatchLoader) Setup(config *DemoMatchLoaderConfig) error {
dml.loginKey = config.LoginKey
dml.sentryFile = config.Sentry
dml.db = config.DB
dml.dp = &DemoParser{}
dml.parseMap = map[string]bool{}
dml.parseMapL = new(sync.RWMutex)
dml.cache = config.Cache
dml.connectFeedback = make(chan int, 10)
dml.connectionWait = retry.WithCappedDuration(time.Minute*time.Duration(config.RetryTimeout), retry.NewExponential(time.Minute))
dml.connectionWaitTmpl = retry.WithCappedDuration(time.Minute*time.Duration(config.RetryTimeout), retry.NewExponential(time.Minute))
err := dml.dp.Setup(config.DB, config.Worker, config.SprayTimeout)
if err != nil {
return err
}
d.steamLogin = new(steam.LogOnDetails)
d.steamLogin.Username = config.Username
d.steamLogin.Password = config.Password
d.steamLogin.AuthCode = config.AuthCode
d.steamLogin.ShouldRememberPassword = true
dml.steamLogin = new(steam.LogOnDetails)
dml.steamLogin.Username = config.Username
dml.steamLogin.Password = config.Password
dml.steamLogin.AuthCode = config.AuthCode
dml.steamLogin.ShouldRememberPassword = true
if _, err := os.Stat(d.sentryFile); err == nil {
hash, err := ioutil.ReadFile(d.sentryFile)
if _, err := os.Stat(dml.sentryFile); err == nil {
hash, err := os.ReadFile(dml.sentryFile)
if err != nil {
return err
}
d.steamLogin.SentryFileHash = hash
dml.steamLogin.SentryFileHash = hash
}
if _, err := os.Stat(d.loginKey); err == nil {
hash, err := ioutil.ReadFile(d.loginKey)
if _, err := os.Stat(dml.loginKey); err == nil {
hash, err := os.ReadFile(dml.loginKey)
if err != nil {
return err
}
d.steamLogin.LoginKey = string(hash)
dml.steamLogin.LoginKey = string(hash)
}
d.client = steam.NewClient()
dml.client = steam.NewClient()
err = steam.InitializeSteamDirectory()
if err != nil {
return err
}
d.matchRecv = make(chan *protobuf.CMsgGCCStrike15V2_MatchList, 1000)
d.parseDemo = make(chan *Demo, 1000)
dml.matchRecv = make(chan *protobuf.CMsgGCCStrike15V2_MatchList, 1000)
dml.parseDemo = make(chan *Demo, 1000)
go d.connectLoop()
go d.steamEventHandler()
go dml.connectLoop()
go dml.steamEventHandler()
go dml.demoWorker()
for i := 0; i < config.Worker; i++ {
go d.gcWorker(config.ApiKey, config.RateLimit)
go dml.gcWorker(config.APIKey, config.RateLimit)
}
dml.connectFeedback <- LoginFailed
return nil
}
func (d DemoMatchLoader) LoadDemo(demo *Demo) error {
func (dml *DemoMatchLoader) LoadDemo(demo *Demo) error {
if dml.IsLoading(demo) {
log.Infof("[DL] Skipping %s: parsing in progress", demo.ShareCode)
return nil
}
dml.lockDemo(demo)
select {
case d.parseDemo <- demo:
case dml.parseDemo <- demo:
return nil
default:
dml.unlockDemo(demo)
return fmt.Errorf("queue full")
}
}
func (d DemoMatchLoader) connectLoop() {
if !d.connecting {
d.connecting = true
for d.connectToSteam() != nil {
log.Infof("[DL] Retrying connecting to steam...")
time.Sleep(time.Minute * 10)
func (dml *DemoMatchLoader) connectLoop() {
for res := range dml.connectFeedback {
switch res {
case LoginFailed:
if sleep, ok := dml.connectionWait.Next(); !ok {
time.Sleep(sleep)
} else {
panic("retry should never stop")
}
if !dml.LoggedIn {
log.Infof("[DL] Connecting to steam...")
err := dml.connectToSteam()
if err != nil {
log.Warningf("[DL] Error connecting to steam: %v", err)
}
}
case LoginSuccess:
log.Info("[DL] Steam login successfully restored")
dml.connectionWait = dml.connectionWaitTmpl
}
}
}
func (d *DemoMatchLoader) steamEventHandler() {
for event := range d.client.Events() {
func (dml *DemoMatchLoader) steamEventHandler() {
for event := range dml.client.Events() {
switch e := event.(type) {
case *steam.ConnectedEvent:
log.Debug("[DL] Connected!")
d.client.Auth.LogOn(d.steamLogin)
dml.client.Auth.LogOn(dml.steamLogin)
case *steam.MachineAuthUpdateEvent:
log.Debug("[DL] Got sentry!")
err := ioutil.WriteFile(d.sentryFile, e.Hash, os.ModePerm)
err := os.WriteFile(dml.sentryFile, e.Hash, os.ModePerm)
if err != nil {
log.Errorf("[DL] Unable write sentry file: %v", err)
}
case *steam.LoggedOnEvent:
log.Debug("[DL] Login successfully!")
d.client.Social.SetPersonaState(steamlang.EPersonaState_Online)
go d.setPlaying()
log.Debug("[DL] Steam login success!")
dml.LoggedIn = true
dml.connectFeedback <- LoginSuccess
dml.client.Social.SetPersonaState(steamlang.EPersonaState_Online)
go dml.setPlaying()
case *steam.LogOnFailedEvent:
log.Warningf("[DL] Steam login denied: %+v", e)
switch e.Result {
log.Debugf("[DL] Steam login denied: %+v", e)
switch e.Result { //nolint:exhaustive
case steamlang.EResult_AccountLogonDenied:
log.Fatalf("[DL] Please provide AuthCode in config")
case steamlang.EResult_InvalidPassword:
_ = os.Remove(d.sentryFile)
_ = os.Remove(d.loginKey)
log.Warningf("[DL] Steam login wrong")
go d.connectLoop()
_ = os.Remove(dml.sentryFile)
_ = os.Remove(dml.loginKey)
log.Warningf("[DL] Steam login failed: InvalidPassword")
case steamlang.EResult_InvalidLoginAuthCode:
log.Fatalf("[DL] Steam auth code wrong")
default:
log.Warningf("[DL] Unhandled login failed event %+v", e)
}
case *steam.DisconnectedEvent:
log.Warningf("Steam disconnected, trying to reconnect...")
go d.connectLoop()
log.Warningf("[DL] Steam disconnected, trying to reconnect...")
dml.GCReady = false
dml.LoggedIn = false
dml.connectFeedback <- LoginFailed
case *steam.LoginKeyEvent:
log.Debug("Got login_key!")
err := ioutil.WriteFile(d.loginKey, []byte(e.LoginKey), os.ModePerm)
err := os.WriteFile(dml.loginKey, []byte(e.LoginKey), os.ModePerm)
if err != nil {
log.Errorf("[DL] Unable write login_key: %v", err)
}
case steam.FatalErrorEvent:
case *steam.FatalErrorEvent:
log.Debugf("[DL] Got FatalError %+v", e)
case error:
log.Fatalf("[DL] Got error %+v", e)
log.Warningf("[DL] Error: %+v", e)
dml.GCReady = false
dml.LoggedIn = false
dml.connectFeedback <- LoginFailed
default:
log.Debugf("[DL] %T: %v", e, e)
}
}
}
func (d *DemoMatchLoader) setPlaying() {
d.client.GC.SetGamesPlayed(APPID)
d.client.GC.RegisterPacketHandler(d)
go d.greetGC()
func (dml *DemoMatchLoader) setPlaying() {
dml.client.GC.SetGamesPlayed(APPID)
dml.client.GC.RegisterPacketHandler(dml)
go dml.greetGC()
}
func (d *DemoMatchLoader) greetGC() {
for !d.GCReady {
func (dml *DemoMatchLoader) greetGC() {
for !dml.GCReady {
log.Debugf("[DL] Sending GC greeting")
msg := protobuf.CMsgClientHello{}
d.client.GC.Write(gamecoordinator.NewGCMsgProtobuf(APPID, uint32(protobuf.EGCBaseClientMsg_k_EMsgGCClientHello), &msg))
time.Sleep(500 * time.Millisecond)
dml.client.GC.Write(gamecoordinator.NewGCMsgProtobuf(APPID, uint32(protobuf.EGCBaseClientMsg_k_EMsgGCClientHello), &msg))
time.Sleep(1 * time.Second)
}
}
func (d *DemoMatchLoader) requestDemoInfo(matchId uint64, conclusionId uint64, tokenId uint32) error {
if !d.GCReady {
func (dml *DemoMatchLoader) requestDemoInfo(matchID, conclusionID uint64, tokenID uint32) error {
if !dml.GCReady {
return fmt.Errorf("gc not ready")
}
msg := protobuf.CMsgGCCStrike15V2_MatchListRequestFullGameInfo{Matchid: &matchId,
Outcomeid: &conclusionId,
Token: &tokenId}
msg := protobuf.CMsgGCCStrike15V2_MatchListRequestFullGameInfo{
Matchid: &matchID,
Outcomeid: &conclusionID,
Token: &tokenID,
}
d.client.GC.Write(gamecoordinator.NewGCMsgProtobuf(APPID, uint32(protobuf.ECsgoGCMsg_k_EMsgGCCStrike15_v2_MatchListRequestFullGameInfo), &msg))
dml.client.GC.Write(gamecoordinator.NewGCMsgProtobuf(APPID,
uint32(protobuf.ECsgoGCMsg_k_EMsgGCCStrike15_v2_MatchListRequestFullGameInfo), &msg))
return nil
}
func (d *DemoMatchLoader) gcWorker(apiKey string, rl ratelimit.Limiter) {
for demo := range d.parseDemo {
d.parseMapL.Lock()
if _, ok := d.parseMap[demo.ShareCode]; ok {
log.Infof("[DL] Skipping %s: parsing in progress", demo.ShareCode)
d.parseMapL.Unlock()
continue
} else {
d.parseMap[demo.ShareCode] = true
func (dml *DemoMatchLoader) demoWorker() {
for demo := range dml.dp.Done {
dml.unlockDemo(demo)
}
}
d.parseMapL.Unlock()
if !d.GCReady {
log.Infof("[DL] Postponing match %d (%s): GC not ready", demo.MatchId, demo.ShareCode)
func (dml *DemoMatchLoader) handleDemo(demo *Demo, apiKey string, rl *rate.Limiter) error {
defer dml.unlockDemo(demo)
if !dml.GCReady {
log.Infof("[DL] Postponing match %d (%s): GC not ready", demo.MatchID, demo.ShareCode)
time.Sleep(5 * time.Second)
d.parseMapL.Lock()
delete(d.parseMap, demo.ShareCode)
d.parseMapL.Unlock()
d.parseDemo <- demo
continue
dml.parseDemo <- demo
return nil
}
matchId, _, _, err := DecodeSharecode(demo.ShareCode)
if err != nil || matchId == 0 {
log.Warningf("[DL] Can't parse match with sharecode %s: %v", demo.ShareCode, err)
d.parseMapL.Lock()
delete(d.parseMap, demo.ShareCode)
d.parseMapL.Unlock()
continue
matchID, _, _, err := DecodeSharecode(demo.ShareCode)
if err != nil || matchID == 0 {
return fmt.Errorf("error decoding sharecode %s: %w", demo.ShareCode, err)
}
iMatch, err := d.db.Match.Get(context.Background(), matchId)
if err != nil {
switch e := err.(type) {
case *ent.NotFoundError:
break
default:
log.Errorf("[DL] Failure trying to lookup match %d in db: %v", matchId, e)
d.parseMapL.Lock()
delete(d.parseMap, demo.ShareCode)
d.parseMapL.Unlock()
continue
}
} else {
if iMatch.DemoParsed == false && iMatch.Date.After(time.Now().UTC().AddDate(0, 0, -30)) {
iMatch, err := dml.db.Match.Get(context.Background(), matchID)
if err != nil && !ent.IsNotFound(err) {
return fmt.Errorf("error looking up match: %w", err)
} else if err == nil {
if !iMatch.DemoParsed && iMatch.Date.After(time.Now().UTC().AddDate(0, 0, -30)) {
log.Infof("[DL] Match %d is loaded, but not parsed. Try parsing.", iMatch.ID)
demo.MatchId = matchId
demo.Url = iMatch.ReplayURL
demo.MatchID = matchID
demo.URL = iMatch.ReplayURL
demo.DecryptionKey = iMatch.DecryptionKey
err := d.dp.ParseDemo(demo)
err := dml.dp.ParseDemo(demo)
if err != nil {
log.Warningf("[DL] Parsing demo from match %d failed: %v", demo.MatchId, err)
return fmt.Errorf("error parsing match %d: %w", demo.MatchID, err)
}
d.parseMapL.Lock()
delete(d.parseMap, demo.ShareCode)
d.parseMapL.Unlock()
continue
return nil
}
log.Infof("[DL] Skipped match %d: already loaded", matchId)
d.parseMapL.Lock()
delete(d.parseMap, demo.ShareCode)
d.parseMapL.Unlock()
continue
log.Infof("[DL] Skipped match %d: already loaded", matchID)
return nil
}
log.Infof("[DL] Requesting match %d from GC", matchId)
log.Infof("[DL] Requesting match %d from GC", matchID)
t := time.Now()
matchDetails, err := d.getMatchDetails(demo.ShareCode)
matchDetails, err := dml.getMatchDetails(demo.ShareCode)
if err != nil {
log.Warningf("[DL] Failure to get match-details for %d from GC: %v", demo.MatchId, err)
d.parseMapL.Lock()
delete(d.parseMap, demo.ShareCode)
d.parseMapL.Unlock()
continue
return fmt.Errorf("error getting match-details for %d: %w", demo.MatchID, err)
}
log.Infof("[DL] Recieved matchdetails for match %d (%s)", matchId, time.Since(t))
log.Infof("[DL] Received matchdetails for match %d (%s)", matchID, time.Since(t))
// init tx
tx, err := dml.db.Tx(context.Background())
if err != nil {
return errors.Wrap(err, "error creating transaction")
}
matchZero := matchDetails.GetMatches()[0]
lastRound := matchZero.GetRoundstatsall()[len(matchZero.Roundstatsall)-1]
var players []*ent.Player
var players []*ent.Player //nolint:prealloc
for _, accountId := range lastRound.GetReservation().GetAccountIds() {
tPlayer, err := utils.Player(d.db, AccountId2SteamId(accountId), apiKey, rl)
for _, accountID := range lastRound.GetReservation().GetAccountIds() {
tPlayer, err := utils.Player(tx.Client(), AccountID2SteamID(accountID), apiKey, rl)
if err != nil {
log.Warningf("[DL] Unable to get player for steamid %d: %v", AccountId2SteamId(accountId), err)
continue
err = utils.Rollback(tx, err)
return fmt.Errorf("error getting player for steamid %d: %w", AccountID2SteamID(accountID), err)
}
players = append(players, tPlayer)
}
demo.Url = lastRound.GetMap()
demo.MatchId = matchZero.GetMatchid()
demo.DecryptionKey = []byte(strings.ToUpper(strconv.FormatUint(matchZero.GetWatchablematchinfo().GetClDecryptdataKeyPub(), 16)))
demo.URL = lastRound.GetMap()
demo.MatchID = matchZero.GetMatchid()
demo.DecryptionKey = []byte(strings.ToUpper(fmt.Sprintf("%016x", matchZero.GetWatchablematchinfo().GetClDecryptdataKeyPub())))
tMatch, err := d.db.Match.Create().
tMatch, err := tx.Match.Create().
SetID(matchZero.GetMatchid()).
AddPlayers(players...).
SetDate(time.Unix(int64(matchZero.GetMatchtime()), 0).UTC()).
@@ -415,35 +453,27 @@ func (d *DemoMatchLoader) gcWorker(apiKey string, rl ratelimit.Limiter) {
SetDecryptionKey(demo.DecryptionKey).
Save(context.Background())
if err != nil {
log.Warningf("[DL] Unable to create match %d: %v", matchZero.GetMatchid(), err)
d.parseMapL.Lock()
delete(d.parseMap, demo.ShareCode)
d.parseMapL.Unlock()
continue
err = utils.Rollback(tx, err)
return fmt.Errorf("error creating match %d: %w", matchZero.GetMatchid(), err)
}
for i, mPlayer := range players {
var (
teamId int
mk2 uint
mk3 uint
mk4 uint
mk5 uint
teamID int
mk2, mk3, mk4, mk5 uint
)
if i > 4 {
teamId = 2
teamID = 2
} else {
teamId = 1
teamID = 1
}
var oldKills int32
for _, round := range matchZero.GetRoundstatsall() {
kills, _, _, _, _, _ := playerStatsFromRound(round, mPlayer)
killDiff := kills - oldKills
switch killDiff {
switch kills - oldKills {
case 2:
mk2++
case 3:
@@ -457,10 +487,10 @@ func (d *DemoMatchLoader) gcWorker(apiKey string, rl ratelimit.Limiter) {
}
kills, deaths, assists, hs, score, mvp := playerStatsFromRound(lastRound, mPlayer)
err := d.db.MatchPlayer.Create().
err = tx.MatchPlayer.Create().
SetMatches(tMatch).
SetPlayers(mPlayer).
SetTeamID(teamId).
SetTeamID(teamID).
SetKills(int(kills)).
SetDeaths(int(deaths)).
SetAssists(int(assists)).
@@ -473,34 +503,48 @@ func (d *DemoMatchLoader) gcWorker(apiKey string, rl ratelimit.Limiter) {
SetMk5(mk5).
Exec(context.Background())
if err != nil {
log.Warningf("[DL] Unable to create stats for player %d in match %d: %v", mPlayer.ID, tMatch.ID, err)
err = utils.Rollback(tx, err)
return fmt.Errorf("error creating stats for player %d in match %d: %w", mPlayer.ID, tMatch.ID, err)
}
}
// clear cache or regen values player
for _, p := range players {
err = d.cache.Delete(context.Background(), fmt.Sprintf(utils.SideMetaCacheKey, p.ID))
err = dml.cache.Delete(context.Background(), fmt.Sprintf(utils.SideMetaCacheKey, p.ID))
if err != nil {
log.Warningf("[DL] Unable to delete cache key %s: %v", fmt.Sprintf(utils.SideMetaCacheKey, p.ID), err)
err = utils.Rollback(tx, err)
return fmt.Errorf("error deleting cache key %s: %w", fmt.Sprintf(utils.SideMetaCacheKey, p.ID), err)
}
w, l, t, err := utils.GetWinLossTieForPlayer(p)
if err != nil {
log.Warningf("[DL] Failure to calculate WinLossTie for player %d: %v", p.ID, err)
continue
err = utils.Rollback(tx, err)
return fmt.Errorf("error calculating WinLossTie for player %d: %w", p.ID, err)
}
err = p.Update().SetWins(w).SetTies(t).SetLooses(l).Exec(context.Background())
if err != nil {
log.Warningf("[DL] Failure to save WinLossTie for player %d: %v", p.ID, err)
err = utils.Rollback(tx, err)
return fmt.Errorf("error saving WinLossTie for player %d: %w", p.ID, err)
}
}
err = d.dp.ParseDemo(demo)
err = tx.Commit()
if err != nil {
log.Warningf("[DL] Can't queue demo %d for parsing: %v", demo.MatchId, err)
return errors.Wrap(err, "[DP] error committing to db")
}
err = dml.dp.ParseDemo(demo)
if err != nil {
return fmt.Errorf("error queueing demo %d for parsing: %w", demo.MatchID, err)
}
return nil
}
func (dml *DemoMatchLoader) gcWorker(apiKey string, rl *rate.Limiter) {
for demo := range dml.parseDemo {
err := dml.handleDemo(demo, apiKey, rl)
if err != nil {
log.Warningf("[DL] Error handling demo: %v", err)
}
d.parseMapL.Lock()
delete(d.parseMap, demo.ShareCode)
d.parseMapL.Unlock()
}
}

View File

@@ -4,34 +4,36 @@ import (
"bytes"
"compress/bzip2"
"context"
"csgowtfd/ent"
"csgowtfd/ent/match"
"csgowtfd/ent/matchplayer"
"csgowtfd/ent/player"
"encoding/gob"
"errors"
"fmt"
"github.com/aclements/go-moremath/stats"
"github.com/golang/geo/r2"
"github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs"
"github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/common"
"github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/events"
"github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs"
"github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs/common"
"github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs/events"
log "github.com/sirupsen/logrus"
"io"
"net/http"
"somegit.dev/csgowtf/csgowtfd/ent"
"somegit.dev/csgowtf/csgowtfd/ent/matchplayer"
"somegit.dev/csgowtf/csgowtfd/utils"
"strings"
"time"
)
type Demo struct {
ShareCode string
MatchId uint64
Url string
MatchID uint64
URL string
DecryptionKey []byte
}
type DemoParser struct {
demoQueue chan *Demo
tempDir string
db *ent.Client
sprayTimeout int
Done chan *Demo
}
type Encounter struct {
@@ -54,9 +56,9 @@ type Spray struct {
Spray [][]float32
}
type DemoNotFoundError struct {
error
}
var (
ErrorDemoNotFound = errors.New("demo not found")
)
func (s *Sprays) Add(currentTime time.Duration, sprayPoint []float32, timeout int) {
sprayFound := false
@@ -105,19 +107,20 @@ func (s *Sprays) Avg() (avg [][]float32) {
return
}
func (p *DemoParser) Setup(db *ent.Client, worker int, sprayTimeout int) error {
p.demoQueue = make(chan *Demo, 1000)
p.db = db
p.sprayTimeout = sprayTimeout
func (dp *DemoParser) Setup(db *ent.Client, worker, sprayTimeout int) error {
dp.demoQueue = make(chan *Demo, 1000)
dp.db = db
dp.sprayTimeout = sprayTimeout
dp.Done = make(chan *Demo, worker)
for i := 0; i < worker; i++ {
go p.parseWorker()
go dp.parseWorker()
}
return nil
}
func (p *DemoParser) ParseDemo(demo *Demo) error {
func (dp *DemoParser) ParseDemo(demo *Demo) error {
select {
case p.demoQueue <- demo:
case dp.demoQueue <- demo:
return nil
default:
return fmt.Errorf("queue full")
@@ -125,39 +128,26 @@ func (p *DemoParser) ParseDemo(demo *Demo) error {
}
func (d *Demo) download() (io.Reader, error) {
log.Debugf("[DP] Downloading replay for %d", d.MatchId)
log.Debugf("[DP] Downloading replay for %d", d.MatchID)
r, err := http.Get(d.Url)
r, err := http.Get(d.URL) //nolint:bodyclose,noctx
if err != nil {
return nil, err
}
if r.StatusCode != http.StatusOK {
return nil, DemoNotFoundError{fmt.Errorf("demo not found")}
return nil, ErrorDemoNotFound
}
return bzip2.NewReader(r.Body), nil
}
func (p *DemoParser) getDBPlayer(demo *Demo, demoPlayer *common.Player) (*ent.MatchPlayer, error) {
tMatchPlayer, err := p.db.MatchPlayer.Query().WithMatches(func(q *ent.MatchQuery) {
q.Where(match.ID(demo.MatchId))
}).WithPlayers(func(q *ent.PlayerQuery) {
q.Where(player.ID(demoPlayer.SteamID64))
}).Only(context.Background())
if err != nil {
return nil, err
}
return tMatchPlayer, nil
}
func (p *DemoParser) MatchPlayerBySteamID(stats []*ent.MatchPlayer, steamId uint64) (*ent.MatchPlayer, error) {
for _, tStats := range stats {
func (dp *DemoParser) MatchPlayerBySteamID(mStats []*ent.MatchPlayer, steamID uint64) (*ent.MatchPlayer, error) {
for _, tStats := range mStats {
tPLayer, err := tStats.Edges.PlayersOrErr()
if err != nil {
return nil, fmt.Errorf("Unbale to get Stats from statList: %v", err)
return nil, fmt.Errorf("unable to get stats from statList: %w", err)
}
if tPLayer.ID == steamId {
if tPLayer.ID == steamID {
return tStats, nil
}
}
@@ -171,63 +161,80 @@ func setMatchPlayerColor(matchPlayer *ent.MatchPlayer, demoPlayer *common.Player
}
matchPlayer.Crosshair = demoPlayer.CrosshairCode()
switch demoPlayer.Color() {
color, _ := demoPlayer.ColorOrErr()
switch color {
case common.Yellow:
matchPlayer.Color = matchplayer.ColorYellow
break
case common.Green:
matchPlayer.Color = matchplayer.ColorGreen
break
case common.Purple:
matchPlayer.Color = matchplayer.ColorPurple
break
case common.Blue:
matchPlayer.Color = matchplayer.ColorBlue
break
case common.Orange:
matchPlayer.Color = matchplayer.ColorOrange
break
case common.Grey:
matchPlayer.Color = matchplayer.ColorGrey
}
}
func (p *DemoParser) parseWorker() {
for demo := range p.demoQueue {
if demo.MatchId == 0 {
func (dp *DemoParser) parseWorker() {
workloop:
for demo := range dp.demoQueue {
if demo.MatchID == 0 {
log.Warningf("[DP] can't parse match %s: no matchid found", demo.ShareCode)
dp.Done <- demo
continue
}
tMatch, err := p.db.Match.Get(context.Background(), demo.MatchId)
// init tx
tx, err := dp.db.Tx(context.Background())
if err != nil {
log.Errorf("[DP] Unable to get match %d: %v", demo.MatchId, err)
log.Errorf("[DP] error creating transaction: %v", err)
dp.Done <- demo
return
}
tMatch, err := tx.Match.Get(context.Background(), demo.MatchID)
if err != nil {
err = utils.Rollback(tx, err)
log.Errorf("[DP] Unable to get match %d: %v", demo.MatchID, err)
dp.Done <- demo
continue
}
if tMatch.DemoParsed {
log.Infof("[DP] skipped already parsed %d", demo.MatchId)
_ = utils.Rollback(tx, err)
log.Infof("[DP] skipped already parsed %d", demo.MatchID)
dp.Done <- demo
continue
}
startTime := time.Now()
fDemo, err := demo.download()
if err != nil {
if _, ok := err.(DemoNotFoundError); ok {
if errors.Is(err, ErrorDemoNotFound) {
_ = utils.Rollback(tx, err)
if tMatch.Date.Before(time.Now().UTC().AddDate(0, 0, -30)) {
log.Infof("[DP] demo expired for match %d", tMatch.ID)
} else {
log.Infof("[DP] demo 404 not found for match %d. Trying again later.", demo.MatchId)
log.Infof("[DP] demo 404 not found for match %d. Retrying later.", demo.MatchID)
}
continue
} else {
log.Errorf("[DP] Unable to download demo for %d: %v", demo.MatchId, err)
dp.Done <- demo
continue
}
err = utils.Rollback(tx, err)
log.Errorf("[DP] Unable to download demo for %d: %v", demo.MatchID, err)
dp.Done <- demo
continue
}
downloadTime := time.Since(startTime)
tStats, err := tMatch.QueryStats().WithPlayers().All(context.Background())
if err != nil {
log.Errorf("[DP] Failed to find players for match %d: %v", demo.MatchId, err)
err = utils.Rollback(tx, err)
log.Errorf("[DP] Failed to find players for match %d: %v", demo.MatchID, err)
dp.Done <- demo
continue
}
@@ -242,20 +249,22 @@ func (p *DemoParser) parseWorker() {
EqV int
Bank int
Spent int
}, 0)
})
encounters := make([]*Encounter, 0)
spays := make([]*Sprays, 0)
pingMap := make(map[uint64][]float64)
cfg := demoinfocs.DefaultParserConfig
if len(demo.DecryptionKey) >= 16 {
if len(demo.DecryptionKey) == 16 { //nolint:gomnd
cfg.NetMessageDecryptionKey = demo.DecryptionKey
}
demoParser := demoinfocs.NewParserWithConfig(fDemo, cfg)
// onChatMessage
demoParser.RegisterEventHandler(func(e events.ChatMessage) {
if e.Sender != nil {
gs := demoParser.GameState()
tAttacker, err := p.MatchPlayerBySteamID(tStats, e.Sender.SteamID64)
tAttacker, err := dp.MatchPlayerBySteamID(tStats, e.Sender.SteamID64)
if err != nil {
log.Warningf("[DP] Unable to get player for id %d: %v", e.Sender.SteamID64, err)
return
@@ -266,6 +275,7 @@ func (p *DemoParser) parseWorker() {
AllChat: e.IsChatAll,
Tick: gs.IngameTick(),
})
}
})
// onPlayerSpotted
@@ -292,7 +302,7 @@ func (p *DemoParser) parseWorker() {
for _, spray := range spays {
if e.Shooter.SteamID64 == spray.Sprayer && int(e.Weapon.Type) == spray.Weapon {
playerWeaponFound = true
spray.Add(demoParser.CurrentTime(), []float32{e.Shooter.ViewDirectionX(), e.Shooter.ViewDirectionY()}, p.sprayTimeout)
spray.Add(demoParser.CurrentTime(), []float32{e.Shooter.ViewDirectionX(), e.Shooter.ViewDirectionY()}, dp.sprayTimeout)
}
}
@@ -311,7 +321,7 @@ func (p *DemoParser) parseWorker() {
return
}
tAttacker, err := p.MatchPlayerBySteamID(tStats, e.Attacker.SteamID64)
tAttacker, err := dp.MatchPlayerBySteamID(tStats, e.Attacker.SteamID64)
if err != nil {
log.Warningf("[DP] Unable to get player for id %d: %v", e.Attacker.SteamID64, err)
return
@@ -356,7 +366,7 @@ func (p *DemoParser) parseWorker() {
return
}
// track eco
// track eco & ping
for _, p := range gs.Participants().Playing() {
ecoMap[p.SteamID64] = append(ecoMap[p.SteamID64], &struct {
Round int
@@ -364,6 +374,8 @@ func (p *DemoParser) parseWorker() {
Bank int
Spent int
}{Round: gs.TotalRoundsPlayed(), EqV: p.EquipmentValueCurrent(), Bank: p.Money(), Spent: p.MoneySpentThisRound()})
pingMap[p.SteamID64] = append(pingMap[p.SteamID64], float64(p.Ping()))
}
})
@@ -373,7 +385,7 @@ func (p *DemoParser) parseWorker() {
return
}
tAttacker, err := p.MatchPlayerBySteamID(tStats, e.Attacker.SteamID64)
tAttacker, err := dp.MatchPlayerBySteamID(tStats, e.Attacker.SteamID64)
if err != nil {
log.Warningf("[DP] Unable to get player for id %d: %v", e.Attacker.SteamID64, err)
return
@@ -401,7 +413,7 @@ func (p *DemoParser) parseWorker() {
// onPlayerConnected
demoParser.RegisterEventHandler(func(e events.PlayerTeamChange) {
if e.Player != nil && e.Player.SteamID64 != 0 {
tMatchPlayer, err := p.MatchPlayerBySteamID(tStats, e.Player.SteamID64)
tMatchPlayer, err := dp.MatchPlayerBySteamID(tStats, e.Player.SteamID64)
if err != nil {
log.Warningf("[DP] Unable to get player for id %d: %v", e.Player.SteamID64, err)
return
@@ -416,7 +428,7 @@ func (p *DemoParser) parseWorker() {
for _, demoPlayer := range gs.Participants().Playing() {
if demoPlayer != nil && demoPlayer.SteamID64 != 0 {
tMatchPlayer, err := p.MatchPlayerBySteamID(tStats, demoPlayer.SteamID64)
tMatchPlayer, err := dp.MatchPlayerBySteamID(tStats, demoPlayer.SteamID64)
if err != nil {
log.Warningf("[DP] Unable to get player for id %d: %v", demoPlayer.SteamID64, err)
return
@@ -429,7 +441,7 @@ func (p *DemoParser) parseWorker() {
// onRankUpdate
demoParser.RegisterEventHandler(func(e events.RankUpdate) {
if e.SteamID64() != 0 {
tMatchPlayer, err := p.MatchPlayerBySteamID(tStats, e.SteamID64())
tMatchPlayer, err := dp.MatchPlayerBySteamID(tStats, e.SteamID64())
if err != nil {
log.Warningf("[DP] Unable to get player for id %d: %v", e.SteamID64(), err)
return
@@ -442,13 +454,21 @@ func (p *DemoParser) parseWorker() {
err = demoParser.ParseToEnd()
if err != nil {
err = utils.Rollback(tx, err)
log.Errorf("[DP] Error parsing replay: %v", err)
dp.Done <- demo
continue
}
err = tMatch.Update().SetMap(demoParser.Header().MapName).SetDemoParsed(true).Exec(context.Background())
err = tMatch.Update().
SetMap(demoParser.Header().MapName).
SetDemoParsed(true).
SetTickRate(demoParser.TickRate()).
Exec(context.Background())
if err != nil {
log.Errorf("[DP] Unable to update match %d in database: %v", demo.MatchId, err)
err = utils.Rollback(tx, err)
log.Errorf("[DP] Unable to update match %d in database: %v", demo.MatchID, err)
dp.Done <- demo
continue
}
@@ -457,6 +477,8 @@ func (p *DemoParser) parseWorker() {
tMatchPlayer.Color = matchplayer.ColorGrey
}
avgPing := stats.GeoMean(pingMap[tMatchPlayer.PlayerStats])
nMatchPLayer, err := tMatchPlayer.Update().
SetDmgTeam(tMatchPlayer.DmgTeam).
SetDmgEnemy(tMatchPlayer.DmgEnemy).
@@ -467,6 +489,7 @@ func (p *DemoParser) parseWorker() {
SetRankOld(tMatchPlayer.RankOld).
SetRankNew(tMatchPlayer.RankNew).
SetColor(tMatchPlayer.Color).
SetAvgPing(avgPing).
SetCrosshair(tMatchPlayer.Crosshair).
SetFlashDurationTeam(tMatchPlayer.FlashDurationTeam).
SetFlashDurationSelf(tMatchPlayer.FlashDurationSelf).
@@ -478,21 +501,41 @@ func (p *DemoParser) parseWorker() {
SetDmgEnemy(tMatchPlayer.DmgEnemy).
Save(context.Background())
if err != nil {
err = utils.Rollback(tx, err)
log.Errorf("[DP] Unable to update stats %d in database: %v", tMatchPlayer.PlayerStats, err)
continue
dp.Done <- demo
continue workloop
}
for _, eqDmg := range eqMap[tMatchPlayer.PlayerStats] {
err := p.db.Weapon.Create().SetStat(nMatchPLayer).SetDmg(eqDmg.Dmg).SetVictim(eqDmg.To).SetHitGroup(eqDmg.HitGroup).SetEqType(eqDmg.Eq).Exec(context.Background())
err = tx.Weapon.Create().
SetStat(nMatchPLayer).
SetDmg(eqDmg.Dmg).
SetVictim(eqDmg.To).
SetHitGroup(eqDmg.HitGroup).
SetEqType(eqDmg.Eq).
Exec(context.Background())
if err != nil {
err = utils.Rollback(tx, err)
log.Errorf("[DP] Unable to create WeaponStat: %v", err)
dp.Done <- demo
continue workloop
}
}
for _, eco := range ecoMap[tMatchPlayer.PlayerStats] {
err := p.db.RoundStats.Create().SetMatchPlayer(nMatchPLayer).SetRound(uint(eco.Round)).SetBank(uint(eco.Bank)).SetEquipment(uint(eco.EqV)).SetSpent(uint(eco.Spent)).Exec(context.Background())
err := tx.RoundStats.Create().
SetMatchPlayer(nMatchPLayer).
SetRound(uint(eco.Round)).
SetBank(uint(eco.Bank)).
SetEquipment(uint(eco.EqV)).
SetSpent(uint(eco.Spent)).
Exec(context.Background())
if err != nil {
err = utils.Rollback(tx, err)
log.Errorf("[DP] Unable to create RoundStat: %v", err)
dp.Done <- demo
continue workloop
}
}
@@ -503,35 +546,59 @@ func (p *DemoParser) parseWorker() {
enc := gob.NewEncoder(sprayBuf)
err = enc.Encode(sprayAvg)
if err != nil {
err = utils.Rollback(tx, err)
log.Warningf("[DP] Failure to encode spray %v as bytes: %v", spray, err)
dp.Done <- demo
continue workloop
}
err = tx.Spray.Create().
SetMatchPlayers(nMatchPLayer).
SetWeapon(spray.Weapon).
SetSpray(sprayBuf.Bytes()).
Exec(context.Background())
if err != nil {
err = utils.Rollback(tx, err)
log.Warningf("[DP] Failure adding spray to database: %v", err)
dp.Done <- demo
continue workloop
}
}
}
}
var bulk []*ent.MessagesCreate
for _, msg := range tMatchPlayer.Edges.Messages {
bulk = append(bulk, tx.Messages.Create().
SetMessage(strings.ToValidUTF8(msg.Message, "")).
SetAllChat(msg.AllChat).
SetTick(msg.Tick).
SetMatchPlayer(tMatchPlayer))
}
if len(bulk) > 0 {
err = tx.Messages.CreateBulk(bulk...).Exec(context.Background())
if err != nil {
err = utils.Rollback(tx, err)
log.Warningf("[DP] Failure adding messages to db: %v", err)
dp.Done <- demo
continue workloop
}
}
}
err = tx.Commit()
if err != nil {
log.Errorf("[DP] error commting to db: %v", err)
dp.Done <- demo
continue
}
err = p.db.Spray.Create().SetMatchPlayers(nMatchPLayer).SetWeapon(spray.Weapon).SetSpray(sprayBuf.Bytes()).Exec(context.Background())
if err != nil {
log.Warningf("[DP] Failure adding spray to database: %v", err)
}
}
}
}
bulk := make([]*ent.MessagesCreate, 0)
for _, msg := range tMatchPlayer.Edges.Messages {
bulk = append(bulk, p.db.Messages.Create().SetMessage(msg.Message).SetAllChat(msg.AllChat).SetTick(msg.Tick).SetMatchPlayer(tMatchPlayer))
}
if len(bulk) > 0 {
err = p.db.Messages.CreateBulk(bulk...).Exec(context.Background())
if err != nil {
log.Warningf("[DP] Failure adding messages to database: %v", err)
}
}
}
log.Infof("[DP] parsed match %d (took %s/%s)", demo.MatchId, downloadTime, time.Since(startTime))
log.Infof("[DP] parsed match %d (took %s/%s)", demo.MatchID, downloadTime, time.Since(startTime))
err = demoParser.Close()
if err != nil {
log.Errorf("[DP] Unable close demo file for match %d: %v", demo.MatchId, err)
}
log.Errorf("[DP] Unable close demo file for match %d: %v", demo.MatchID, err)
}
dp.Done <- demo
}
}

View File

@@ -9,10 +9,11 @@ import (
)
//goland:noinspection SpellCheckingInspection
var DICT = "ABCDEFGHJKLMNOPQRSTUVWXYZabcdefhijkmnopqrstuvwxyz23456789"
var sharecodeRexEx = regexp.MustCompile("^CSGO(?:-?[\\w]{5}){5}$")
const Base57Chars = "ABCDEFGHJKLMNOPQRSTUVWXYZabcdefhijkmnopqrstuvwxyz23456789"
func DecodeSharecode(code string) (uint64, uint64, uint16, error) {
var sharecodeRexEx = regexp.MustCompile(`^CSGO(?:-?\w{5}){5}$`)
func DecodeSharecode(code string) (matchID, outcomeID uint64, tokenID uint16, err error) {
if !sharecodeRexEx.MatchString(code) {
return 0, 0, 0, fmt.Errorf("not a CSGO sharecode: %s", code)
}
@@ -21,24 +22,24 @@ func DecodeSharecode(code string) (uint64, uint64, uint16, error) {
chars := ReverseString(strings.Split(cleanCode, ""))
bigInt := new(big.Int)
dictLenBig := big.NewInt(int64(len(DICT)))
dictLenBig := big.NewInt(int64(len(Base57Chars)))
for _, c := range chars {
bigInt.Mul(bigInt, dictLenBig)
bigInt.Add(bigInt, big.NewInt(int64(strings.Index(DICT, c))))
bigInt.Add(bigInt, big.NewInt(int64(strings.Index(Base57Chars, c))))
}
if bigInt.BitLen() > 144 {
if bigInt.BitLen() > 144 { //nolint:gomnd
return 0, 0, 0, fmt.Errorf("invalid sharecode")
}
bytes := make([]byte, 18)
bytes := make([]byte, 18) //nolint:gomnd
bigInt.FillBytes(bytes)
matchId := binary.LittleEndian.Uint64(bytes[0:8])
outcomeId := binary.LittleEndian.Uint64(bytes[8:16])
tokenId := binary.LittleEndian.Uint16(bytes[16:18])
matchID = binary.LittleEndian.Uint64(bytes[0:8])
outcomeID = binary.LittleEndian.Uint64(bytes[8:16])
tokenID = binary.LittleEndian.Uint16(bytes[16:18])
return matchId, outcomeId, tokenId, nil
return
}
func ReverseString(numbers []string) []string {

View File

@@ -2,7 +2,6 @@ package csgo
import "testing"
//goland:noinspection SpellCheckingInspection
func TestGoodSharecodes(t *testing.T) {
eMatchId := uint64(3505575050994516382)
eOutcomeId := uint64(3505581094013501947)

View File

@@ -1,25 +1,26 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"log"
"csgowtfd/ent/migrate"
"csgowtfd/ent/match"
"csgowtfd/ent/matchplayer"
"csgowtfd/ent/messages"
"csgowtfd/ent/player"
"csgowtfd/ent/roundstats"
"csgowtfd/ent/spray"
"csgowtfd/ent/weapon"
"somegit.dev/csgowtf/csgowtfd/ent/migrate"
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"somegit.dev/csgowtf/csgowtfd/ent/match"
"somegit.dev/csgowtf/csgowtfd/ent/matchplayer"
"somegit.dev/csgowtf/csgowtfd/ent/messages"
"somegit.dev/csgowtf/csgowtfd/ent/player"
"somegit.dev/csgowtf/csgowtfd/ent/roundstats"
"somegit.dev/csgowtf/csgowtfd/ent/spray"
"somegit.dev/csgowtf/csgowtfd/ent/weapon"
)
// Client is the client that holds all ent builders.
@@ -45,7 +46,7 @@ type Client struct {
// NewClient creates a new client configured with the given options.
func NewClient(opts ...Option) *Client {
cfg := config{log: log.Println, hooks: &hooks{}}
cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}}
cfg.options(opts...)
client := &Client{config: cfg}
client.init()
@@ -63,6 +64,55 @@ func (c *Client) init() {
c.Weapon = NewWeaponClient(c.config)
}
type (
// config is the configuration for the client and its builder.
config struct {
// driver used for executing database requests.
driver dialect.Driver
// debug enable a debug logging.
debug bool
// log used for logging on debug mode.
log func(...any)
// hooks to execute on mutations.
hooks *hooks
// interceptors to execute on queries.
inters *inters
}
// Option function to configure the client.
Option func(*config)
)
// options applies the options on the config object.
func (c *config) options(opts ...Option) {
for _, opt := range opts {
opt(c)
}
if c.debug {
c.driver = dialect.Debug(c.driver, c.log)
}
}
// Debug enables debug logging on the ent.Driver.
func Debug() Option {
return func(c *config) {
c.debug = true
}
}
// Log sets the logging function for debug mode.
func Log(fn func(...any)) Option {
return func(c *config) {
c.log = fn
}
}
// Driver configures the client driver.
func Driver(driver dialect.Driver) Option {
return func(c *config) {
c.driver = driver
}
}
// Open opens a database/sql.DB specified by the driver name and
// the data source name, and returns a new client attached to it.
// Optional parameters can be added for configuring the client.
@@ -83,7 +133,7 @@ func Open(driverName, dataSourceName string, options ...Option) (*Client, error)
// is used until the transaction is committed or rolled back.
func (c *Client) Tx(ctx context.Context) (*Tx, error) {
if _, ok := c.driver.(*txDriver); ok {
return nil, fmt.Errorf("ent: cannot start a transaction within a transaction")
return nil, errors.New("ent: cannot start a transaction within a transaction")
}
tx, err := newTx(ctx, c.driver)
if err != nil {
@@ -107,7 +157,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
// BeginTx returns a transactional client with specified options.
func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) {
if _, ok := c.driver.(*txDriver); ok {
return nil, fmt.Errorf("ent: cannot start a transaction within a transaction")
return nil, errors.New("ent: cannot start a transaction within a transaction")
}
tx, err := c.driver.(interface {
BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error)
@@ -136,7 +186,6 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
// Match.
// Query().
// Count(ctx)
//
func (c *Client) Debug() *Client {
if c.debug {
return c
@@ -156,13 +205,43 @@ func (c *Client) Close() error {
// Use adds the mutation hooks to all the entity clients.
// In order to add hooks to a specific client, call: `client.Node.Use(...)`.
func (c *Client) Use(hooks ...Hook) {
c.Match.Use(hooks...)
c.MatchPlayer.Use(hooks...)
c.Messages.Use(hooks...)
c.Player.Use(hooks...)
c.RoundStats.Use(hooks...)
c.Spray.Use(hooks...)
c.Weapon.Use(hooks...)
for _, n := range []interface{ Use(...Hook) }{
c.Match, c.MatchPlayer, c.Messages, c.Player, c.RoundStats, c.Spray, c.Weapon,
} {
n.Use(hooks...)
}
}
// Intercept adds the query interceptors to all the entity clients.
// In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`.
func (c *Client) Intercept(interceptors ...Interceptor) {
for _, n := range []interface{ Intercept(...Interceptor) }{
c.Match, c.MatchPlayer, c.Messages, c.Player, c.RoundStats, c.Spray, c.Weapon,
} {
n.Intercept(interceptors...)
}
}
// Mutate implements the ent.Mutator interface.
func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
switch m := m.(type) {
case *MatchMutation:
return c.Match.mutate(ctx, m)
case *MatchPlayerMutation:
return c.MatchPlayer.mutate(ctx, m)
case *MessagesMutation:
return c.Messages.mutate(ctx, m)
case *PlayerMutation:
return c.Player.mutate(ctx, m)
case *RoundStatsMutation:
return c.RoundStats.mutate(ctx, m)
case *SprayMutation:
return c.Spray.mutate(ctx, m)
case *WeaponMutation:
return c.Weapon.mutate(ctx, m)
default:
return nil, fmt.Errorf("ent: unknown mutation type %T", m)
}
}
// MatchClient is a client for the Match schema.
@@ -181,7 +260,13 @@ func (c *MatchClient) Use(hooks ...Hook) {
c.hooks.Match = append(c.hooks.Match, hooks...)
}
// Create returns a create builder for Match.
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `match.Intercept(f(g(h())))`.
func (c *MatchClient) Intercept(interceptors ...Interceptor) {
c.inters.Match = append(c.inters.Match, interceptors...)
}
// Create returns a builder for creating a Match entity.
func (c *MatchClient) Create() *MatchCreate {
mutation := newMatchMutation(c.config, OpCreate)
return &MatchCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
@@ -216,12 +301,12 @@ func (c *MatchClient) Delete() *MatchDelete {
return &MatchDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a delete builder for the given entity.
// DeleteOne returns a builder for deleting the given entity.
func (c *MatchClient) DeleteOne(m *Match) *MatchDeleteOne {
return c.DeleteOneID(m.ID)
}
// DeleteOneID returns a delete builder for the given id.
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *MatchClient) DeleteOneID(id uint64) *MatchDeleteOne {
builder := c.Delete().Where(match.ID(id))
builder.mutation.id = &id
@@ -233,6 +318,8 @@ func (c *MatchClient) DeleteOneID(id uint64) *MatchDeleteOne {
func (c *MatchClient) Query() *MatchQuery {
return &MatchQuery{
config: c.config,
ctx: &QueryContext{Type: TypeMatch},
inters: c.Interceptors(),
}
}
@@ -252,8 +339,8 @@ func (c *MatchClient) GetX(ctx context.Context, id uint64) *Match {
// QueryStats queries the stats edge of a Match.
func (c *MatchClient) QueryStats(m *Match) *MatchPlayerQuery {
query := &MatchPlayerQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
query := (&MatchPlayerClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := m.ID
step := sqlgraph.NewStep(
sqlgraph.From(match.Table, match.FieldID, id),
@@ -268,8 +355,8 @@ func (c *MatchClient) QueryStats(m *Match) *MatchPlayerQuery {
// QueryPlayers queries the players edge of a Match.
func (c *MatchClient) QueryPlayers(m *Match) *PlayerQuery {
query := &PlayerQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
query := (&PlayerClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := m.ID
step := sqlgraph.NewStep(
sqlgraph.From(match.Table, match.FieldID, id),
@@ -287,6 +374,26 @@ func (c *MatchClient) Hooks() []Hook {
return c.hooks.Match
}
// Interceptors returns the client interceptors.
func (c *MatchClient) Interceptors() []Interceptor {
return c.inters.Match
}
func (c *MatchClient) mutate(ctx context.Context, m *MatchMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&MatchCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&MatchUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&MatchUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&MatchDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown Match mutation op: %q", m.Op())
}
}
// MatchPlayerClient is a client for the MatchPlayer schema.
type MatchPlayerClient struct {
config
@@ -303,7 +410,13 @@ func (c *MatchPlayerClient) Use(hooks ...Hook) {
c.hooks.MatchPlayer = append(c.hooks.MatchPlayer, hooks...)
}
// Create returns a create builder for MatchPlayer.
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `matchplayer.Intercept(f(g(h())))`.
func (c *MatchPlayerClient) Intercept(interceptors ...Interceptor) {
c.inters.MatchPlayer = append(c.inters.MatchPlayer, interceptors...)
}
// Create returns a builder for creating a MatchPlayer entity.
func (c *MatchPlayerClient) Create() *MatchPlayerCreate {
mutation := newMatchPlayerMutation(c.config, OpCreate)
return &MatchPlayerCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
@@ -338,12 +451,12 @@ func (c *MatchPlayerClient) Delete() *MatchPlayerDelete {
return &MatchPlayerDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a delete builder for the given entity.
// DeleteOne returns a builder for deleting the given entity.
func (c *MatchPlayerClient) DeleteOne(mp *MatchPlayer) *MatchPlayerDeleteOne {
return c.DeleteOneID(mp.ID)
}
// DeleteOneID returns a delete builder for the given id.
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *MatchPlayerClient) DeleteOneID(id int) *MatchPlayerDeleteOne {
builder := c.Delete().Where(matchplayer.ID(id))
builder.mutation.id = &id
@@ -355,6 +468,8 @@ func (c *MatchPlayerClient) DeleteOneID(id int) *MatchPlayerDeleteOne {
func (c *MatchPlayerClient) Query() *MatchPlayerQuery {
return &MatchPlayerQuery{
config: c.config,
ctx: &QueryContext{Type: TypeMatchPlayer},
inters: c.Interceptors(),
}
}
@@ -374,8 +489,8 @@ func (c *MatchPlayerClient) GetX(ctx context.Context, id int) *MatchPlayer {
// QueryMatches queries the matches edge of a MatchPlayer.
func (c *MatchPlayerClient) QueryMatches(mp *MatchPlayer) *MatchQuery {
query := &MatchQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
query := (&MatchClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := mp.ID
step := sqlgraph.NewStep(
sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id),
@@ -390,8 +505,8 @@ func (c *MatchPlayerClient) QueryMatches(mp *MatchPlayer) *MatchQuery {
// QueryPlayers queries the players edge of a MatchPlayer.
func (c *MatchPlayerClient) QueryPlayers(mp *MatchPlayer) *PlayerQuery {
query := &PlayerQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
query := (&PlayerClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := mp.ID
step := sqlgraph.NewStep(
sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id),
@@ -406,8 +521,8 @@ func (c *MatchPlayerClient) QueryPlayers(mp *MatchPlayer) *PlayerQuery {
// QueryWeaponStats queries the weapon_stats edge of a MatchPlayer.
func (c *MatchPlayerClient) QueryWeaponStats(mp *MatchPlayer) *WeaponQuery {
query := &WeaponQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
query := (&WeaponClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := mp.ID
step := sqlgraph.NewStep(
sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id),
@@ -422,8 +537,8 @@ func (c *MatchPlayerClient) QueryWeaponStats(mp *MatchPlayer) *WeaponQuery {
// QueryRoundStats queries the round_stats edge of a MatchPlayer.
func (c *MatchPlayerClient) QueryRoundStats(mp *MatchPlayer) *RoundStatsQuery {
query := &RoundStatsQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
query := (&RoundStatsClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := mp.ID
step := sqlgraph.NewStep(
sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id),
@@ -438,8 +553,8 @@ func (c *MatchPlayerClient) QueryRoundStats(mp *MatchPlayer) *RoundStatsQuery {
// QuerySpray queries the spray edge of a MatchPlayer.
func (c *MatchPlayerClient) QuerySpray(mp *MatchPlayer) *SprayQuery {
query := &SprayQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
query := (&SprayClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := mp.ID
step := sqlgraph.NewStep(
sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id),
@@ -454,8 +569,8 @@ func (c *MatchPlayerClient) QuerySpray(mp *MatchPlayer) *SprayQuery {
// QueryMessages queries the messages edge of a MatchPlayer.
func (c *MatchPlayerClient) QueryMessages(mp *MatchPlayer) *MessagesQuery {
query := &MessagesQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
query := (&MessagesClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := mp.ID
step := sqlgraph.NewStep(
sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id),
@@ -473,6 +588,26 @@ func (c *MatchPlayerClient) Hooks() []Hook {
return c.hooks.MatchPlayer
}
// Interceptors returns the client interceptors.
func (c *MatchPlayerClient) Interceptors() []Interceptor {
return c.inters.MatchPlayer
}
func (c *MatchPlayerClient) mutate(ctx context.Context, m *MatchPlayerMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&MatchPlayerCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&MatchPlayerUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&MatchPlayerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&MatchPlayerDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown MatchPlayer mutation op: %q", m.Op())
}
}
// MessagesClient is a client for the Messages schema.
type MessagesClient struct {
config
@@ -489,7 +624,13 @@ func (c *MessagesClient) Use(hooks ...Hook) {
c.hooks.Messages = append(c.hooks.Messages, hooks...)
}
// Create returns a create builder for Messages.
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `messages.Intercept(f(g(h())))`.
func (c *MessagesClient) Intercept(interceptors ...Interceptor) {
c.inters.Messages = append(c.inters.Messages, interceptors...)
}
// Create returns a builder for creating a Messages entity.
func (c *MessagesClient) Create() *MessagesCreate {
mutation := newMessagesMutation(c.config, OpCreate)
return &MessagesCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
@@ -524,12 +665,12 @@ func (c *MessagesClient) Delete() *MessagesDelete {
return &MessagesDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a delete builder for the given entity.
// DeleteOne returns a builder for deleting the given entity.
func (c *MessagesClient) DeleteOne(m *Messages) *MessagesDeleteOne {
return c.DeleteOneID(m.ID)
}
// DeleteOneID returns a delete builder for the given id.
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *MessagesClient) DeleteOneID(id int) *MessagesDeleteOne {
builder := c.Delete().Where(messages.ID(id))
builder.mutation.id = &id
@@ -541,6 +682,8 @@ func (c *MessagesClient) DeleteOneID(id int) *MessagesDeleteOne {
func (c *MessagesClient) Query() *MessagesQuery {
return &MessagesQuery{
config: c.config,
ctx: &QueryContext{Type: TypeMessages},
inters: c.Interceptors(),
}
}
@@ -560,8 +703,8 @@ func (c *MessagesClient) GetX(ctx context.Context, id int) *Messages {
// QueryMatchPlayer queries the match_player edge of a Messages.
func (c *MessagesClient) QueryMatchPlayer(m *Messages) *MatchPlayerQuery {
query := &MatchPlayerQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
query := (&MatchPlayerClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := m.ID
step := sqlgraph.NewStep(
sqlgraph.From(messages.Table, messages.FieldID, id),
@@ -579,6 +722,26 @@ func (c *MessagesClient) Hooks() []Hook {
return c.hooks.Messages
}
// Interceptors returns the client interceptors.
func (c *MessagesClient) Interceptors() []Interceptor {
return c.inters.Messages
}
func (c *MessagesClient) mutate(ctx context.Context, m *MessagesMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&MessagesCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&MessagesUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&MessagesUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&MessagesDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown Messages mutation op: %q", m.Op())
}
}
// PlayerClient is a client for the Player schema.
type PlayerClient struct {
config
@@ -595,7 +758,13 @@ func (c *PlayerClient) Use(hooks ...Hook) {
c.hooks.Player = append(c.hooks.Player, hooks...)
}
// Create returns a create builder for Player.
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `player.Intercept(f(g(h())))`.
func (c *PlayerClient) Intercept(interceptors ...Interceptor) {
c.inters.Player = append(c.inters.Player, interceptors...)
}
// Create returns a builder for creating a Player entity.
func (c *PlayerClient) Create() *PlayerCreate {
mutation := newPlayerMutation(c.config, OpCreate)
return &PlayerCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
@@ -630,12 +799,12 @@ func (c *PlayerClient) Delete() *PlayerDelete {
return &PlayerDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a delete builder for the given entity.
// DeleteOne returns a builder for deleting the given entity.
func (c *PlayerClient) DeleteOne(pl *Player) *PlayerDeleteOne {
return c.DeleteOneID(pl.ID)
}
// DeleteOneID returns a delete builder for the given id.
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *PlayerClient) DeleteOneID(id uint64) *PlayerDeleteOne {
builder := c.Delete().Where(player.ID(id))
builder.mutation.id = &id
@@ -647,6 +816,8 @@ func (c *PlayerClient) DeleteOneID(id uint64) *PlayerDeleteOne {
func (c *PlayerClient) Query() *PlayerQuery {
return &PlayerQuery{
config: c.config,
ctx: &QueryContext{Type: TypePlayer},
inters: c.Interceptors(),
}
}
@@ -666,8 +837,8 @@ func (c *PlayerClient) GetX(ctx context.Context, id uint64) *Player {
// QueryStats queries the stats edge of a Player.
func (c *PlayerClient) QueryStats(pl *Player) *MatchPlayerQuery {
query := &MatchPlayerQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
query := (&MatchPlayerClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := pl.ID
step := sqlgraph.NewStep(
sqlgraph.From(player.Table, player.FieldID, id),
@@ -682,8 +853,8 @@ func (c *PlayerClient) QueryStats(pl *Player) *MatchPlayerQuery {
// QueryMatches queries the matches edge of a Player.
func (c *PlayerClient) QueryMatches(pl *Player) *MatchQuery {
query := &MatchQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
query := (&MatchClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := pl.ID
step := sqlgraph.NewStep(
sqlgraph.From(player.Table, player.FieldID, id),
@@ -701,6 +872,26 @@ func (c *PlayerClient) Hooks() []Hook {
return c.hooks.Player
}
// Interceptors returns the client interceptors.
func (c *PlayerClient) Interceptors() []Interceptor {
return c.inters.Player
}
func (c *PlayerClient) mutate(ctx context.Context, m *PlayerMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&PlayerCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&PlayerUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&PlayerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&PlayerDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown Player mutation op: %q", m.Op())
}
}
// RoundStatsClient is a client for the RoundStats schema.
type RoundStatsClient struct {
config
@@ -717,7 +908,13 @@ func (c *RoundStatsClient) Use(hooks ...Hook) {
c.hooks.RoundStats = append(c.hooks.RoundStats, hooks...)
}
// Create returns a create builder for RoundStats.
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `roundstats.Intercept(f(g(h())))`.
func (c *RoundStatsClient) Intercept(interceptors ...Interceptor) {
c.inters.RoundStats = append(c.inters.RoundStats, interceptors...)
}
// Create returns a builder for creating a RoundStats entity.
func (c *RoundStatsClient) Create() *RoundStatsCreate {
mutation := newRoundStatsMutation(c.config, OpCreate)
return &RoundStatsCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
@@ -752,12 +949,12 @@ func (c *RoundStatsClient) Delete() *RoundStatsDelete {
return &RoundStatsDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a delete builder for the given entity.
// DeleteOne returns a builder for deleting the given entity.
func (c *RoundStatsClient) DeleteOne(rs *RoundStats) *RoundStatsDeleteOne {
return c.DeleteOneID(rs.ID)
}
// DeleteOneID returns a delete builder for the given id.
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *RoundStatsClient) DeleteOneID(id int) *RoundStatsDeleteOne {
builder := c.Delete().Where(roundstats.ID(id))
builder.mutation.id = &id
@@ -769,6 +966,8 @@ func (c *RoundStatsClient) DeleteOneID(id int) *RoundStatsDeleteOne {
func (c *RoundStatsClient) Query() *RoundStatsQuery {
return &RoundStatsQuery{
config: c.config,
ctx: &QueryContext{Type: TypeRoundStats},
inters: c.Interceptors(),
}
}
@@ -788,8 +987,8 @@ func (c *RoundStatsClient) GetX(ctx context.Context, id int) *RoundStats {
// QueryMatchPlayer queries the match_player edge of a RoundStats.
func (c *RoundStatsClient) QueryMatchPlayer(rs *RoundStats) *MatchPlayerQuery {
query := &MatchPlayerQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
query := (&MatchPlayerClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := rs.ID
step := sqlgraph.NewStep(
sqlgraph.From(roundstats.Table, roundstats.FieldID, id),
@@ -807,6 +1006,26 @@ func (c *RoundStatsClient) Hooks() []Hook {
return c.hooks.RoundStats
}
// Interceptors returns the client interceptors.
func (c *RoundStatsClient) Interceptors() []Interceptor {
return c.inters.RoundStats
}
func (c *RoundStatsClient) mutate(ctx context.Context, m *RoundStatsMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&RoundStatsCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&RoundStatsUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&RoundStatsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&RoundStatsDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown RoundStats mutation op: %q", m.Op())
}
}
// SprayClient is a client for the Spray schema.
type SprayClient struct {
config
@@ -823,7 +1042,13 @@ func (c *SprayClient) Use(hooks ...Hook) {
c.hooks.Spray = append(c.hooks.Spray, hooks...)
}
// Create returns a create builder for Spray.
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `spray.Intercept(f(g(h())))`.
func (c *SprayClient) Intercept(interceptors ...Interceptor) {
c.inters.Spray = append(c.inters.Spray, interceptors...)
}
// Create returns a builder for creating a Spray entity.
func (c *SprayClient) Create() *SprayCreate {
mutation := newSprayMutation(c.config, OpCreate)
return &SprayCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
@@ -858,12 +1083,12 @@ func (c *SprayClient) Delete() *SprayDelete {
return &SprayDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a delete builder for the given entity.
// DeleteOne returns a builder for deleting the given entity.
func (c *SprayClient) DeleteOne(s *Spray) *SprayDeleteOne {
return c.DeleteOneID(s.ID)
}
// DeleteOneID returns a delete builder for the given id.
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *SprayClient) DeleteOneID(id int) *SprayDeleteOne {
builder := c.Delete().Where(spray.ID(id))
builder.mutation.id = &id
@@ -875,6 +1100,8 @@ func (c *SprayClient) DeleteOneID(id int) *SprayDeleteOne {
func (c *SprayClient) Query() *SprayQuery {
return &SprayQuery{
config: c.config,
ctx: &QueryContext{Type: TypeSpray},
inters: c.Interceptors(),
}
}
@@ -894,8 +1121,8 @@ func (c *SprayClient) GetX(ctx context.Context, id int) *Spray {
// QueryMatchPlayers queries the match_players edge of a Spray.
func (c *SprayClient) QueryMatchPlayers(s *Spray) *MatchPlayerQuery {
query := &MatchPlayerQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
query := (&MatchPlayerClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := s.ID
step := sqlgraph.NewStep(
sqlgraph.From(spray.Table, spray.FieldID, id),
@@ -913,6 +1140,26 @@ func (c *SprayClient) Hooks() []Hook {
return c.hooks.Spray
}
// Interceptors returns the client interceptors.
func (c *SprayClient) Interceptors() []Interceptor {
return c.inters.Spray
}
func (c *SprayClient) mutate(ctx context.Context, m *SprayMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&SprayCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&SprayUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&SprayUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&SprayDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown Spray mutation op: %q", m.Op())
}
}
// WeaponClient is a client for the Weapon schema.
type WeaponClient struct {
config
@@ -929,7 +1176,13 @@ func (c *WeaponClient) Use(hooks ...Hook) {
c.hooks.Weapon = append(c.hooks.Weapon, hooks...)
}
// Create returns a create builder for Weapon.
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `weapon.Intercept(f(g(h())))`.
func (c *WeaponClient) Intercept(interceptors ...Interceptor) {
c.inters.Weapon = append(c.inters.Weapon, interceptors...)
}
// Create returns a builder for creating a Weapon entity.
func (c *WeaponClient) Create() *WeaponCreate {
mutation := newWeaponMutation(c.config, OpCreate)
return &WeaponCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
@@ -964,12 +1217,12 @@ func (c *WeaponClient) Delete() *WeaponDelete {
return &WeaponDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a delete builder for the given entity.
// DeleteOne returns a builder for deleting the given entity.
func (c *WeaponClient) DeleteOne(w *Weapon) *WeaponDeleteOne {
return c.DeleteOneID(w.ID)
}
// DeleteOneID returns a delete builder for the given id.
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *WeaponClient) DeleteOneID(id int) *WeaponDeleteOne {
builder := c.Delete().Where(weapon.ID(id))
builder.mutation.id = &id
@@ -981,6 +1234,8 @@ func (c *WeaponClient) DeleteOneID(id int) *WeaponDeleteOne {
func (c *WeaponClient) Query() *WeaponQuery {
return &WeaponQuery{
config: c.config,
ctx: &QueryContext{Type: TypeWeapon},
inters: c.Interceptors(),
}
}
@@ -1000,8 +1255,8 @@ func (c *WeaponClient) GetX(ctx context.Context, id int) *Weapon {
// QueryStat queries the stat edge of a Weapon.
func (c *WeaponClient) QueryStat(w *Weapon) *MatchPlayerQuery {
query := &MatchPlayerQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
query := (&MatchPlayerClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := w.ID
step := sqlgraph.NewStep(
sqlgraph.From(weapon.Table, weapon.FieldID, id),
@@ -1018,3 +1273,34 @@ func (c *WeaponClient) QueryStat(w *Weapon) *MatchPlayerQuery {
func (c *WeaponClient) Hooks() []Hook {
return c.hooks.Weapon
}
// Interceptors returns the client interceptors.
func (c *WeaponClient) Interceptors() []Interceptor {
return c.inters.Weapon
}
func (c *WeaponClient) mutate(ctx context.Context, m *WeaponMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&WeaponCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&WeaponUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&WeaponUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&WeaponDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown Weapon mutation op: %q", m.Op())
}
}
// hooks and interceptors per client, for fast access.
type (
hooks struct {
Match, MatchPlayer, Messages, Player, RoundStats, Spray, Weapon []ent.Hook
}
inters struct {
Match, MatchPlayer, Messages, Player, RoundStats, Spray,
Weapon []ent.Interceptor
}
)

View File

@@ -1,65 +0,0 @@
// Code generated by entc, DO NOT EDIT.
package ent
import (
"entgo.io/ent"
"entgo.io/ent/dialect"
)
// Option function to configure the client.
type Option func(*config)
// Config is the configuration for the client and its builder.
type config struct {
// driver used for executing database requests.
driver dialect.Driver
// debug enable a debug logging.
debug bool
// log used for logging on debug mode.
log func(...interface{})
// hooks to execute on mutations.
hooks *hooks
}
// hooks per client, for fast access.
type hooks struct {
Match []ent.Hook
MatchPlayer []ent.Hook
Messages []ent.Hook
Player []ent.Hook
RoundStats []ent.Hook
Spray []ent.Hook
Weapon []ent.Hook
}
// Options applies the options on the config object.
func (c *config) options(opts ...Option) {
for _, opt := range opts {
opt(c)
}
if c.debug {
c.driver = dialect.Debug(c.driver, c.log)
}
}
// Debug enables debug logging on the ent.Driver.
func Debug() Option {
return func(c *config) {
c.debug = true
}
}
// Log sets the logging function for debug mode.
func Log(fn func(...interface{})) Option {
return func(c *config) {
c.log = fn
}
}
// Driver configures the client driver.
func Driver(driver dialect.Driver) Option {
return func(c *config) {
c.driver = driver
}
}

View File

@@ -1,33 +0,0 @@
// Code generated by entc, DO NOT EDIT.
package ent
import (
"context"
)
type clientCtxKey struct{}
// FromContext returns a Client stored inside a context, or nil if there isn't one.
func FromContext(ctx context.Context) *Client {
c, _ := ctx.Value(clientCtxKey{}).(*Client)
return c
}
// NewContext returns a new context with the given Client attached.
func NewContext(parent context.Context, c *Client) context.Context {
return context.WithValue(parent, clientCtxKey{}, c)
}
type txCtxKey struct{}
// TxFromContext returns a Tx stored inside a context, or nil if there isn't one.
func TxFromContext(ctx context.Context) *Tx {
tx, _ := ctx.Value(txCtxKey{}).(*Tx)
return tx
}
// NewTxContext returns a new context with the given Tx attached.
func NewTxContext(parent context.Context, tx *Tx) context.Context {
return context.WithValue(parent, txCtxKey{}, tx)
}

View File

@@ -1,20 +1,24 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"csgowtfd/ent/match"
"csgowtfd/ent/matchplayer"
"csgowtfd/ent/messages"
"csgowtfd/ent/player"
"csgowtfd/ent/roundstats"
"csgowtfd/ent/spray"
"csgowtfd/ent/weapon"
"context"
"errors"
"fmt"
"reflect"
"sync"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"somegit.dev/csgowtf/csgowtfd/ent/match"
"somegit.dev/csgowtf/csgowtfd/ent/matchplayer"
"somegit.dev/csgowtf/csgowtfd/ent/messages"
"somegit.dev/csgowtf/csgowtfd/ent/player"
"somegit.dev/csgowtf/csgowtfd/ent/roundstats"
"somegit.dev/csgowtf/csgowtfd/ent/spray"
"somegit.dev/csgowtf/csgowtfd/ent/weapon"
)
// ent aliases to avoid import conflicts in user's code.
@@ -23,18 +27,58 @@ type (
Hook = ent.Hook
Value = ent.Value
Query = ent.Query
QueryContext = ent.QueryContext
Querier = ent.Querier
QuerierFunc = ent.QuerierFunc
Interceptor = ent.Interceptor
InterceptFunc = ent.InterceptFunc
Traverser = ent.Traverser
TraverseFunc = ent.TraverseFunc
Policy = ent.Policy
Mutator = ent.Mutator
Mutation = ent.Mutation
MutateFunc = ent.MutateFunc
)
type clientCtxKey struct{}
// FromContext returns a Client stored inside a context, or nil if there isn't one.
func FromContext(ctx context.Context) *Client {
c, _ := ctx.Value(clientCtxKey{}).(*Client)
return c
}
// NewContext returns a new context with the given Client attached.
func NewContext(parent context.Context, c *Client) context.Context {
return context.WithValue(parent, clientCtxKey{}, c)
}
type txCtxKey struct{}
// TxFromContext returns a Tx stored inside a context, or nil if there isn't one.
func TxFromContext(ctx context.Context) *Tx {
tx, _ := ctx.Value(txCtxKey{}).(*Tx)
return tx
}
// NewTxContext returns a new context with the given Tx attached.
func NewTxContext(parent context.Context, tx *Tx) context.Context {
return context.WithValue(parent, txCtxKey{}, tx)
}
// OrderFunc applies an ordering on the sql selector.
// Deprecated: Use Asc/Desc functions or the package builders instead.
type OrderFunc func(*sql.Selector)
// columnChecker returns a function indicates if the column exists in the given column.
func columnChecker(table string) func(string) error {
checks := map[string]func(string) bool{
var (
initCheck sync.Once
columnCheck sql.ColumnCheck
)
// columnChecker checks if the column exists in the given table.
func checkColumn(table, column string) error {
initCheck.Do(func() {
columnCheck = sql.NewColumnCheck(map[string]func(string) bool{
match.Table: match.ValidColumn,
matchplayer.Table: matchplayer.ValidColumn,
messages.Table: messages.ValidColumn,
@@ -42,27 +86,16 @@ func columnChecker(table string) func(string) error {
roundstats.Table: roundstats.ValidColumn,
spray.Table: spray.ValidColumn,
weapon.Table: weapon.ValidColumn,
}
check, ok := checks[table]
if !ok {
return func(string) error {
return fmt.Errorf("unknown table %q", table)
}
}
return func(column string) error {
if !check(column) {
return fmt.Errorf("unknown column %q for table %q", column, table)
}
return nil
}
})
})
return columnCheck(table, column)
}
// Asc applies the given fields in ASC order.
func Asc(fields ...string) OrderFunc {
func Asc(fields ...string) func(*sql.Selector) {
return func(s *sql.Selector) {
check := columnChecker(s.TableName())
for _, f := range fields {
if err := check(f); err != nil {
if err := checkColumn(s.TableName(), f); err != nil {
s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)})
}
s.OrderBy(sql.Asc(s.C(f)))
@@ -71,11 +104,10 @@ func Asc(fields ...string) OrderFunc {
}
// Desc applies the given fields in DESC order.
func Desc(fields ...string) OrderFunc {
func Desc(fields ...string) func(*sql.Selector) {
return func(s *sql.Selector) {
check := columnChecker(s.TableName())
for _, f := range fields {
if err := check(f); err != nil {
if err := checkColumn(s.TableName(), f); err != nil {
s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)})
}
s.OrderBy(sql.Desc(s.C(f)))
@@ -91,7 +123,6 @@ type AggregateFunc func(*sql.Selector) string
// GroupBy(field1, field2).
// Aggregate(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")).
// Scan(ctx, &v)
//
func As(fn AggregateFunc, end string) AggregateFunc {
return func(s *sql.Selector) string {
return sql.As(fn(s), end)
@@ -108,8 +139,7 @@ func Count() AggregateFunc {
// Max applies the "max" aggregation function on the given field of each group.
func Max(field string) AggregateFunc {
return func(s *sql.Selector) string {
check := columnChecker(s.TableName())
if err := check(field); err != nil {
if err := checkColumn(s.TableName(), field); err != nil {
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
return ""
}
@@ -120,8 +150,7 @@ func Max(field string) AggregateFunc {
// Mean applies the "mean" aggregation function on the given field of each group.
func Mean(field string) AggregateFunc {
return func(s *sql.Selector) string {
check := columnChecker(s.TableName())
if err := check(field); err != nil {
if err := checkColumn(s.TableName(), field); err != nil {
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
return ""
}
@@ -132,8 +161,7 @@ func Mean(field string) AggregateFunc {
// Min applies the "min" aggregation function on the given field of each group.
func Min(field string) AggregateFunc {
return func(s *sql.Selector) string {
check := columnChecker(s.TableName())
if err := check(field); err != nil {
if err := checkColumn(s.TableName(), field); err != nil {
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
return ""
}
@@ -144,8 +172,7 @@ func Min(field string) AggregateFunc {
// Sum applies the "sum" aggregation function on the given field of each group.
func Sum(field string) AggregateFunc {
return func(s *sql.Selector) string {
check := columnChecker(s.TableName())
if err := check(field); err != nil {
if err := checkColumn(s.TableName(), field); err != nil {
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
return ""
}
@@ -269,3 +296,325 @@ func IsConstraintError(err error) bool {
var e *ConstraintError
return errors.As(err, &e)
}
// selector embedded by the different Select/GroupBy builders.
type selector struct {
label string
flds *[]string
fns []AggregateFunc
scan func(context.Context, any) error
}
// ScanX is like Scan, but panics if an error occurs.
func (s *selector) ScanX(ctx context.Context, v any) {
if err := s.scan(ctx, v); err != nil {
panic(err)
}
}
// Strings returns list of strings from a selector. It is only allowed when selecting one field.
func (s *selector) Strings(ctx context.Context) ([]string, error) {
if len(*s.flds) > 1 {
return nil, errors.New("ent: Strings is not achievable when selecting more than 1 field")
}
var v []string
if err := s.scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// StringsX is like Strings, but panics if an error occurs.
func (s *selector) StringsX(ctx context.Context) []string {
v, err := s.Strings(ctx)
if err != nil {
panic(err)
}
return v
}
// String returns a single string from a selector. It is only allowed when selecting one field.
func (s *selector) String(ctx context.Context) (_ string, err error) {
var v []string
if v, err = s.Strings(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{s.label}
default:
err = fmt.Errorf("ent: Strings returned %d results when one was expected", len(v))
}
return
}
// StringX is like String, but panics if an error occurs.
func (s *selector) StringX(ctx context.Context) string {
v, err := s.String(ctx)
if err != nil {
panic(err)
}
return v
}
// Ints returns list of ints from a selector. It is only allowed when selecting one field.
func (s *selector) Ints(ctx context.Context) ([]int, error) {
if len(*s.flds) > 1 {
return nil, errors.New("ent: Ints is not achievable when selecting more than 1 field")
}
var v []int
if err := s.scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// IntsX is like Ints, but panics if an error occurs.
func (s *selector) IntsX(ctx context.Context) []int {
v, err := s.Ints(ctx)
if err != nil {
panic(err)
}
return v
}
// Int returns a single int from a selector. It is only allowed when selecting one field.
func (s *selector) Int(ctx context.Context) (_ int, err error) {
var v []int
if v, err = s.Ints(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{s.label}
default:
err = fmt.Errorf("ent: Ints returned %d results when one was expected", len(v))
}
return
}
// IntX is like Int, but panics if an error occurs.
func (s *selector) IntX(ctx context.Context) int {
v, err := s.Int(ctx)
if err != nil {
panic(err)
}
return v
}
// Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
func (s *selector) Float64s(ctx context.Context) ([]float64, error) {
if len(*s.flds) > 1 {
return nil, errors.New("ent: Float64s is not achievable when selecting more than 1 field")
}
var v []float64
if err := s.scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// Float64sX is like Float64s, but panics if an error occurs.
func (s *selector) Float64sX(ctx context.Context) []float64 {
v, err := s.Float64s(ctx)
if err != nil {
panic(err)
}
return v
}
// Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
func (s *selector) Float64(ctx context.Context) (_ float64, err error) {
var v []float64
if v, err = s.Float64s(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{s.label}
default:
err = fmt.Errorf("ent: Float64s returned %d results when one was expected", len(v))
}
return
}
// Float64X is like Float64, but panics if an error occurs.
func (s *selector) Float64X(ctx context.Context) float64 {
v, err := s.Float64(ctx)
if err != nil {
panic(err)
}
return v
}
// Bools returns list of bools from a selector. It is only allowed when selecting one field.
func (s *selector) Bools(ctx context.Context) ([]bool, error) {
if len(*s.flds) > 1 {
return nil, errors.New("ent: Bools is not achievable when selecting more than 1 field")
}
var v []bool
if err := s.scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// BoolsX is like Bools, but panics if an error occurs.
func (s *selector) BoolsX(ctx context.Context) []bool {
v, err := s.Bools(ctx)
if err != nil {
panic(err)
}
return v
}
// Bool returns a single bool from a selector. It is only allowed when selecting one field.
func (s *selector) Bool(ctx context.Context) (_ bool, err error) {
var v []bool
if v, err = s.Bools(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{s.label}
default:
err = fmt.Errorf("ent: Bools returned %d results when one was expected", len(v))
}
return
}
// BoolX is like Bool, but panics if an error occurs.
func (s *selector) BoolX(ctx context.Context) bool {
v, err := s.Bool(ctx)
if err != nil {
panic(err)
}
return v
}
// withHooks invokes the builder operation with the given hooks, if any.
func withHooks[V Value, M any, PM interface {
*M
Mutation
}](ctx context.Context, exec func(context.Context) (V, error), mutation PM, hooks []Hook) (value V, err error) {
if len(hooks) == 0 {
return exec(ctx)
}
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutationT, ok := any(m).(PM)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
// Set the mutation to the builder.
*mutation = *mutationT
return exec(ctx)
})
for i := len(hooks) - 1; i >= 0; i-- {
if hooks[i] == nil {
return value, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = hooks[i](mut)
}
v, err := mut.Mutate(ctx, mutation)
if err != nil {
return value, err
}
nv, ok := v.(V)
if !ok {
return value, fmt.Errorf("unexpected node type %T returned from %T", v, mutation)
}
return nv, nil
}
// setContextOp returns a new context with the given QueryContext attached (including its op) in case it does not exist.
func setContextOp(ctx context.Context, qc *QueryContext, op string) context.Context {
if ent.QueryFromContext(ctx) == nil {
qc.Op = op
ctx = ent.NewQueryContext(ctx, qc)
}
return ctx
}
func querierAll[V Value, Q interface {
sqlAll(context.Context, ...queryHook) (V, error)
}]() Querier {
return QuerierFunc(func(ctx context.Context, q Query) (Value, error) {
query, ok := q.(Q)
if !ok {
return nil, fmt.Errorf("unexpected query type %T", q)
}
return query.sqlAll(ctx)
})
}
func querierCount[Q interface {
sqlCount(context.Context) (int, error)
}]() Querier {
return QuerierFunc(func(ctx context.Context, q Query) (Value, error) {
query, ok := q.(Q)
if !ok {
return nil, fmt.Errorf("unexpected query type %T", q)
}
return query.sqlCount(ctx)
})
}
func withInterceptors[V Value](ctx context.Context, q Query, qr Querier, inters []Interceptor) (v V, err error) {
for i := len(inters) - 1; i >= 0; i-- {
qr = inters[i].Intercept(qr)
}
rv, err := qr.Query(ctx, q)
if err != nil {
return v, err
}
vt, ok := rv.(V)
if !ok {
return v, fmt.Errorf("unexpected type %T returned from %T. expected type: %T", vt, q, v)
}
return vt, nil
}
func scanWithInterceptors[Q1 ent.Query, Q2 interface {
sqlScan(context.Context, Q1, any) error
}](ctx context.Context, rootQuery Q1, selectOrGroup Q2, inters []Interceptor, v any) error {
rv := reflect.ValueOf(v)
var qr Querier = QuerierFunc(func(ctx context.Context, q Query) (Value, error) {
query, ok := q.(Q1)
if !ok {
return nil, fmt.Errorf("unexpected query type %T", q)
}
if err := selectOrGroup.sqlScan(ctx, query, v); err != nil {
return nil, err
}
if k := rv.Kind(); k == reflect.Pointer && rv.Elem().CanInterface() {
return rv.Elem().Interface(), nil
}
return v, nil
})
for i := len(inters) - 1; i >= 0; i-- {
qr = inters[i].Intercept(qr)
}
vv, err := qr.Query(ctx, rootQuery)
if err != nil {
return err
}
switch rv2 := reflect.ValueOf(vv); {
case rv.IsNil(), rv2.IsNil(), rv.Kind() != reflect.Pointer:
case rv.Type() == rv2.Type():
rv.Elem().Set(rv2.Elem())
case rv.Elem().Type() == rv2.Type():
rv.Elem().Set(rv2)
}
return nil
}
// queryHook describes an internal hook for the different sqlAll methods.
type queryHook func(context.Context, *sqlgraph.QuerySpec)

View File

@@ -1,14 +1,16 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package enttest
import (
"context"
"csgowtfd/ent"
"somegit.dev/csgowtf/csgowtfd/ent"
// required by schema hooks.
_ "csgowtfd/ent/runtime"
_ "somegit.dev/csgowtf/csgowtfd/ent/runtime"
"entgo.io/ent/dialect/sql/schema"
"somegit.dev/csgowtf/csgowtfd/ent/migrate"
)
type (
@@ -16,7 +18,7 @@ type (
// testing.T and testing.B and used by enttest.
TestingT interface {
FailNow()
Error(...interface{})
Error(...any)
}
// Option configures client creation.
@@ -58,10 +60,7 @@ func Open(t TestingT, driverName, dataSourceName string, opts ...Option) *ent.Cl
t.Error(err)
t.FailNow()
}
if err := c.Schema.Create(context.Background(), o.migrateOpts...); err != nil {
t.Error(err)
t.FailNow()
}
migrateSchema(t, c, o)
return c
}
@@ -69,9 +68,17 @@ func Open(t TestingT, driverName, dataSourceName string, opts ...Option) *ent.Cl
func NewClient(t TestingT, opts ...Option) *ent.Client {
o := newOptions(opts)
c := ent.NewClient(o.opts...)
if err := c.Schema.Create(context.Background(), o.migrateOpts...); err != nil {
migrateSchema(t, c, o)
return c
}
func migrateSchema(t TestingT, c *ent.Client, o *options) {
tables, err := schema.CopyTables(migrate.Tables)
if err != nil {
t.Error(err)
t.FailNow()
}
if err := migrate.Create(context.Background(), c.Schema, tables, o.migrateOpts...); err != nil {
t.Error(err)
t.FailNow()
}
return c
}

View File

@@ -1,11 +1,12 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package hook
import (
"context"
"csgowtfd/ent"
"fmt"
"somegit.dev/csgowtf/csgowtfd/ent"
)
// The MatchFunc type is an adapter to allow the use of ordinary
@@ -14,12 +15,11 @@ type MatchFunc func(context.Context, *ent.MatchMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f MatchFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
mv, ok := m.(*ent.MatchMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.MatchMutation", m)
}
if mv, ok := m.(*ent.MatchMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.MatchMutation", m)
}
// The MatchPlayerFunc type is an adapter to allow the use of ordinary
// function as MatchPlayer mutator.
@@ -27,12 +27,11 @@ type MatchPlayerFunc func(context.Context, *ent.MatchPlayerMutation) (ent.Value,
// Mutate calls f(ctx, m).
func (f MatchPlayerFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
mv, ok := m.(*ent.MatchPlayerMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.MatchPlayerMutation", m)
}
if mv, ok := m.(*ent.MatchPlayerMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.MatchPlayerMutation", m)
}
// The MessagesFunc type is an adapter to allow the use of ordinary
// function as Messages mutator.
@@ -40,12 +39,11 @@ type MessagesFunc func(context.Context, *ent.MessagesMutation) (ent.Value, error
// Mutate calls f(ctx, m).
func (f MessagesFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
mv, ok := m.(*ent.MessagesMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.MessagesMutation", m)
}
if mv, ok := m.(*ent.MessagesMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.MessagesMutation", m)
}
// The PlayerFunc type is an adapter to allow the use of ordinary
// function as Player mutator.
@@ -53,12 +51,11 @@ type PlayerFunc func(context.Context, *ent.PlayerMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f PlayerFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
mv, ok := m.(*ent.PlayerMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.PlayerMutation", m)
}
if mv, ok := m.(*ent.PlayerMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.PlayerMutation", m)
}
// The RoundStatsFunc type is an adapter to allow the use of ordinary
// function as RoundStats mutator.
@@ -66,12 +63,11 @@ type RoundStatsFunc func(context.Context, *ent.RoundStatsMutation) (ent.Value, e
// Mutate calls f(ctx, m).
func (f RoundStatsFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
mv, ok := m.(*ent.RoundStatsMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.RoundStatsMutation", m)
}
if mv, ok := m.(*ent.RoundStatsMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.RoundStatsMutation", m)
}
// The SprayFunc type is an adapter to allow the use of ordinary
// function as Spray mutator.
@@ -79,12 +75,11 @@ type SprayFunc func(context.Context, *ent.SprayMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f SprayFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
mv, ok := m.(*ent.SprayMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.SprayMutation", m)
}
if mv, ok := m.(*ent.SprayMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.SprayMutation", m)
}
// The WeaponFunc type is an adapter to allow the use of ordinary
// function as Weapon mutator.
@@ -92,12 +87,11 @@ type WeaponFunc func(context.Context, *ent.WeaponMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f WeaponFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
mv, ok := m.(*ent.WeaponMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.WeaponMutation", m)
}
if mv, ok := m.(*ent.WeaponMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.WeaponMutation", m)
}
// Condition is a hook condition function.
type Condition func(context.Context, ent.Mutation) bool
@@ -194,7 +188,6 @@ func HasFields(field string, fields ...string) Condition {
// If executes the given hook under condition.
//
// hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...)))
//
func If(hk ent.Hook, cond Condition) ent.Hook {
return func(next ent.Mutator) ent.Mutator {
return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) {
@@ -209,7 +202,6 @@ func If(hk ent.Hook, cond Condition) ent.Hook {
// On executes the given hook only for the given operation.
//
// hook.On(Log, ent.Delete|ent.Create)
//
func On(hk ent.Hook, op ent.Op) ent.Hook {
return If(hk, HasOp(op))
}
@@ -217,7 +209,6 @@ func On(hk ent.Hook, op ent.Op) ent.Hook {
// Unless skips the given hook only for the given operation.
//
// hook.Unless(Log, ent.Update|ent.UpdateOne)
//
func Unless(hk ent.Hook, op ent.Op) ent.Hook {
return If(hk, Not(HasOp(op)))
}
@@ -238,7 +229,6 @@ func FixedError(err error) ent.Hook {
// Reject(ent.Delete|ent.Update),
// }
// }
//
func Reject(op ent.Op) ent.Hook {
hk := FixedError(fmt.Errorf("%s operation is not allowed", op))
return On(hk, op)

View File

@@ -1,14 +1,15 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"csgowtfd/ent/match"
"fmt"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"somegit.dev/csgowtf/csgowtfd/ent/match"
)
// Match is the model entity for the Match schema.
@@ -42,9 +43,12 @@ type Match struct {
GamebanPresent bool `json:"gameban_present,omitempty"`
// DecryptionKey holds the value of the "decryption_key" field.
DecryptionKey []byte `json:"decryption_key,omitempty"`
// TickRate holds the value of the "tick_rate" field.
TickRate float64 `json:"tick_rate,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the MatchQuery when eager-loading is set.
Edges MatchEdges `json:"edges"`
selectValues sql.SelectValues
}
// MatchEdges holds the relations/edges for other nodes in the graph.
@@ -77,14 +81,16 @@ func (e MatchEdges) PlayersOrErr() ([]*Player, error) {
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Match) scanValues(columns []string) ([]interface{}, error) {
values := make([]interface{}, len(columns))
func (*Match) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case match.FieldDecryptionKey:
values[i] = new([]byte)
case match.FieldDemoParsed, match.FieldVacPresent, match.FieldGamebanPresent:
values[i] = new(sql.NullBool)
case match.FieldTickRate:
values[i] = new(sql.NullFloat64)
case match.FieldID, match.FieldScoreTeamA, match.FieldScoreTeamB, match.FieldDuration, match.FieldMatchResult, match.FieldMaxRounds:
values[i] = new(sql.NullInt64)
case match.FieldShareCode, match.FieldMap, match.FieldReplayURL:
@@ -92,7 +98,7 @@ func (*Match) scanValues(columns []string) ([]interface{}, error) {
case match.FieldDate:
values[i] = new(sql.NullTime)
default:
return nil, fmt.Errorf("unexpected column %q for type Match", columns[i])
values[i] = new(sql.UnknownType)
}
}
return values, nil
@@ -100,7 +106,7 @@ func (*Match) scanValues(columns []string) ([]interface{}, error) {
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the Match fields.
func (m *Match) assignValues(columns []string, values []interface{}) error {
func (m *Match) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
@@ -190,36 +196,50 @@ func (m *Match) assignValues(columns []string, values []interface{}) error {
} else if value != nil {
m.DecryptionKey = *value
}
case match.FieldTickRate:
if value, ok := values[i].(*sql.NullFloat64); !ok {
return fmt.Errorf("unexpected type %T for field tick_rate", values[i])
} else if value.Valid {
m.TickRate = value.Float64
}
default:
m.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the Match.
// This includes values selected through modifiers, order, etc.
func (m *Match) Value(name string) (ent.Value, error) {
return m.selectValues.Get(name)
}
// QueryStats queries the "stats" edge of the Match entity.
func (m *Match) QueryStats() *MatchPlayerQuery {
return (&MatchClient{config: m.config}).QueryStats(m)
return NewMatchClient(m.config).QueryStats(m)
}
// QueryPlayers queries the "players" edge of the Match entity.
func (m *Match) QueryPlayers() *PlayerQuery {
return (&MatchClient{config: m.config}).QueryPlayers(m)
return NewMatchClient(m.config).QueryPlayers(m)
}
// Update returns a builder for updating this Match.
// Note that you need to call Match.Unwrap() before calling this method if this Match
// was returned from a transaction, and the transaction was committed or rolled back.
func (m *Match) Update() *MatchUpdateOne {
return (&MatchClient{config: m.config}).UpdateOne(m)
return NewMatchClient(m.config).UpdateOne(m)
}
// Unwrap unwraps the Match 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 (m *Match) Unwrap() *Match {
tx, ok := m.config.driver.(*txDriver)
_tx, ok := m.config.driver.(*txDriver)
if !ok {
panic("ent: Match is not a transactional entity")
}
m.config.driver = tx.drv
m.config.driver = _tx.drv
return m
}
@@ -227,42 +247,51 @@ func (m *Match) Unwrap() *Match {
func (m *Match) String() string {
var builder strings.Builder
builder.WriteString("Match(")
builder.WriteString(fmt.Sprintf("id=%v", m.ID))
builder.WriteString(", share_code=")
builder.WriteString(fmt.Sprintf("id=%v, ", m.ID))
builder.WriteString("share_code=")
builder.WriteString(m.ShareCode)
builder.WriteString(", map=")
builder.WriteString(", ")
builder.WriteString("map=")
builder.WriteString(m.Map)
builder.WriteString(", date=")
builder.WriteString(", ")
builder.WriteString("date=")
builder.WriteString(m.Date.Format(time.ANSIC))
builder.WriteString(", score_team_a=")
builder.WriteString(", ")
builder.WriteString("score_team_a=")
builder.WriteString(fmt.Sprintf("%v", m.ScoreTeamA))
builder.WriteString(", score_team_b=")
builder.WriteString(", ")
builder.WriteString("score_team_b=")
builder.WriteString(fmt.Sprintf("%v", m.ScoreTeamB))
builder.WriteString(", replay_url=")
builder.WriteString(", ")
builder.WriteString("replay_url=")
builder.WriteString(m.ReplayURL)
builder.WriteString(", duration=")
builder.WriteString(", ")
builder.WriteString("duration=")
builder.WriteString(fmt.Sprintf("%v", m.Duration))
builder.WriteString(", match_result=")
builder.WriteString(", ")
builder.WriteString("match_result=")
builder.WriteString(fmt.Sprintf("%v", m.MatchResult))
builder.WriteString(", max_rounds=")
builder.WriteString(", ")
builder.WriteString("max_rounds=")
builder.WriteString(fmt.Sprintf("%v", m.MaxRounds))
builder.WriteString(", demo_parsed=")
builder.WriteString(", ")
builder.WriteString("demo_parsed=")
builder.WriteString(fmt.Sprintf("%v", m.DemoParsed))
builder.WriteString(", vac_present=")
builder.WriteString(", ")
builder.WriteString("vac_present=")
builder.WriteString(fmt.Sprintf("%v", m.VacPresent))
builder.WriteString(", gameban_present=")
builder.WriteString(", ")
builder.WriteString("gameban_present=")
builder.WriteString(fmt.Sprintf("%v", m.GamebanPresent))
builder.WriteString(", decryption_key=")
builder.WriteString(", ")
builder.WriteString("decryption_key=")
builder.WriteString(fmt.Sprintf("%v", m.DecryptionKey))
builder.WriteString(", ")
builder.WriteString("tick_rate=")
builder.WriteString(fmt.Sprintf("%v", m.TickRate))
builder.WriteByte(')')
return builder.String()
}
// Matches is a parsable slice of Match.
type Matches []*Match
func (m Matches) config(cfg config) {
for _i := range m {
m[_i].config = cfg
}
}

View File

@@ -1,7 +1,12 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package match
import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
const (
// Label holds the string label denoting the match type in the database.
Label = "match"
@@ -33,6 +38,8 @@ const (
FieldGamebanPresent = "gameban_present"
// FieldDecryptionKey holds the string denoting the decryption_key field in the database.
FieldDecryptionKey = "decryption_key"
// FieldTickRate holds the string denoting the tick_rate field in the database.
FieldTickRate = "tick_rate"
// EdgeStats holds the string denoting the stats edge name in mutations.
EdgeStats = "stats"
// EdgePlayers holds the string denoting the players edge name in mutations.
@@ -69,6 +76,7 @@ var Columns = []string{
FieldVacPresent,
FieldGamebanPresent,
FieldDecryptionKey,
FieldTickRate,
}
var (
@@ -95,3 +103,118 @@ var (
// DefaultGamebanPresent holds the default value on creation for the "gameban_present" field.
DefaultGamebanPresent bool
)
// OrderOption defines the ordering options for the Match queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByShareCode orders the results by the share_code field.
func ByShareCode(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldShareCode, opts...).ToFunc()
}
// ByMap orders the results by the map field.
func ByMap(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMap, opts...).ToFunc()
}
// ByDate orders the results by the date field.
func ByDate(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDate, opts...).ToFunc()
}
// ByScoreTeamA orders the results by the score_team_a field.
func ByScoreTeamA(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldScoreTeamA, opts...).ToFunc()
}
// ByScoreTeamB orders the results by the score_team_b field.
func ByScoreTeamB(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldScoreTeamB, opts...).ToFunc()
}
// ByReplayURL orders the results by the replay_url field.
func ByReplayURL(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldReplayURL, opts...).ToFunc()
}
// ByDuration orders the results by the duration field.
func ByDuration(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDuration, opts...).ToFunc()
}
// ByMatchResult orders the results by the match_result field.
func ByMatchResult(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMatchResult, opts...).ToFunc()
}
// ByMaxRounds orders the results by the max_rounds field.
func ByMaxRounds(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMaxRounds, opts...).ToFunc()
}
// ByDemoParsed orders the results by the demo_parsed field.
func ByDemoParsed(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDemoParsed, opts...).ToFunc()
}
// ByVacPresent orders the results by the vac_present field.
func ByVacPresent(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldVacPresent, opts...).ToFunc()
}
// ByGamebanPresent orders the results by the gameban_present field.
func ByGamebanPresent(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldGamebanPresent, opts...).ToFunc()
}
// ByTickRate orders the results by the tick_rate field.
func ByTickRate(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTickRate, opts...).ToFunc()
}
// ByStatsCount orders the results by stats count.
func ByStatsCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newStatsStep(), opts...)
}
}
// ByStats orders the results by stats terms.
func ByStats(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newStatsStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// ByPlayersCount orders the results by players count.
func ByPlayersCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newPlayersStep(), opts...)
}
}
// ByPlayers orders the results by players terms.
func ByPlayers(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newPlayersStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
func newStatsStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(StatsInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, StatsTable, StatsColumn),
)
}
func newPlayersStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(PlayersInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2M, true, PlayersTable, PlayersPrimaryKey...),
)
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,18 +1,18 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"csgowtfd/ent/match"
"csgowtfd/ent/matchplayer"
"csgowtfd/ent/player"
"errors"
"fmt"
"time"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"somegit.dev/csgowtf/csgowtfd/ent/match"
"somegit.dev/csgowtf/csgowtfd/ent/matchplayer"
"somegit.dev/csgowtf/csgowtfd/ent/player"
)
// MatchCreate is the builder for creating a Match entity.
@@ -140,6 +140,20 @@ func (mc *MatchCreate) SetDecryptionKey(b []byte) *MatchCreate {
return mc
}
// SetTickRate sets the "tick_rate" field.
func (mc *MatchCreate) SetTickRate(f float64) *MatchCreate {
mc.mutation.SetTickRate(f)
return mc
}
// SetNillableTickRate sets the "tick_rate" field if the given value is not nil.
func (mc *MatchCreate) SetNillableTickRate(f *float64) *MatchCreate {
if f != nil {
mc.SetTickRate(*f)
}
return mc
}
// SetID sets the "id" field.
func (mc *MatchCreate) SetID(u uint64) *MatchCreate {
mc.mutation.SetID(u)
@@ -183,44 +197,8 @@ func (mc *MatchCreate) Mutation() *MatchMutation {
// Save creates the Match in the database.
func (mc *MatchCreate) Save(ctx context.Context) (*Match, error) {
var (
err error
node *Match
)
mc.defaults()
if len(mc.hooks) == 0 {
if err = mc.check(); err != nil {
return nil, err
}
node, err = mc.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*MatchMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = mc.check(); err != nil {
return nil, err
}
mc.mutation = mutation
if node, err = mc.sqlSave(ctx); err != nil {
return nil, err
}
mutation.id = &node.ID
mutation.done = true
return node, err
})
for i := len(mc.hooks) - 1; i >= 0; i-- {
if mc.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = mc.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, mc.mutation); err != nil {
return nil, err
}
}
return node, err
return withHooks(ctx, mc.sqlSave, mc.mutation, mc.hooks)
}
// SaveX calls Save and panics if Save returns an error.
@@ -297,10 +275,13 @@ func (mc *MatchCreate) check() error {
}
func (mc *MatchCreate) sqlSave(ctx context.Context) (*Match, error) {
if err := mc.check(); err != nil {
return nil, err
}
_node, _spec := mc.createSpec()
if err := sqlgraph.CreateNode(ctx, mc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
@@ -308,128 +289,76 @@ func (mc *MatchCreate) sqlSave(ctx context.Context) (*Match, error) {
id := _spec.ID.Value.(int64)
_node.ID = uint64(id)
}
mc.mutation.id = &_node.ID
mc.mutation.done = true
return _node, nil
}
func (mc *MatchCreate) createSpec() (*Match, *sqlgraph.CreateSpec) {
var (
_node = &Match{config: mc.config}
_spec = &sqlgraph.CreateSpec{
Table: match.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUint64,
Column: match.FieldID,
},
}
_spec = sqlgraph.NewCreateSpec(match.Table, sqlgraph.NewFieldSpec(match.FieldID, field.TypeUint64))
)
if id, ok := mc.mutation.ID(); ok {
_node.ID = id
_spec.ID.Value = id
}
if value, ok := mc.mutation.ShareCode(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: match.FieldShareCode,
})
_spec.SetField(match.FieldShareCode, field.TypeString, value)
_node.ShareCode = value
}
if value, ok := mc.mutation.Map(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: match.FieldMap,
})
_spec.SetField(match.FieldMap, field.TypeString, value)
_node.Map = value
}
if value, ok := mc.mutation.Date(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeTime,
Value: value,
Column: match.FieldDate,
})
_spec.SetField(match.FieldDate, field.TypeTime, value)
_node.Date = value
}
if value, ok := mc.mutation.ScoreTeamA(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: match.FieldScoreTeamA,
})
_spec.SetField(match.FieldScoreTeamA, field.TypeInt, value)
_node.ScoreTeamA = value
}
if value, ok := mc.mutation.ScoreTeamB(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: match.FieldScoreTeamB,
})
_spec.SetField(match.FieldScoreTeamB, field.TypeInt, value)
_node.ScoreTeamB = value
}
if value, ok := mc.mutation.ReplayURL(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: match.FieldReplayURL,
})
_spec.SetField(match.FieldReplayURL, field.TypeString, value)
_node.ReplayURL = value
}
if value, ok := mc.mutation.Duration(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: match.FieldDuration,
})
_spec.SetField(match.FieldDuration, field.TypeInt, value)
_node.Duration = value
}
if value, ok := mc.mutation.MatchResult(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: match.FieldMatchResult,
})
_spec.SetField(match.FieldMatchResult, field.TypeInt, value)
_node.MatchResult = value
}
if value, ok := mc.mutation.MaxRounds(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: match.FieldMaxRounds,
})
_spec.SetField(match.FieldMaxRounds, field.TypeInt, value)
_node.MaxRounds = value
}
if value, ok := mc.mutation.DemoParsed(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeBool,
Value: value,
Column: match.FieldDemoParsed,
})
_spec.SetField(match.FieldDemoParsed, field.TypeBool, value)
_node.DemoParsed = value
}
if value, ok := mc.mutation.VacPresent(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeBool,
Value: value,
Column: match.FieldVacPresent,
})
_spec.SetField(match.FieldVacPresent, field.TypeBool, value)
_node.VacPresent = value
}
if value, ok := mc.mutation.GamebanPresent(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeBool,
Value: value,
Column: match.FieldGamebanPresent,
})
_spec.SetField(match.FieldGamebanPresent, field.TypeBool, value)
_node.GamebanPresent = value
}
if value, ok := mc.mutation.DecryptionKey(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeBytes,
Value: value,
Column: match.FieldDecryptionKey,
})
_spec.SetField(match.FieldDecryptionKey, field.TypeBytes, value)
_node.DecryptionKey = value
}
if value, ok := mc.mutation.TickRate(); ok {
_spec.SetField(match.FieldTickRate, field.TypeFloat64, value)
_node.TickRate = value
}
if nodes := mc.mutation.StatsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
@@ -438,10 +367,7 @@ func (mc *MatchCreate) createSpec() (*Match, *sqlgraph.CreateSpec) {
Columns: []string{match.StatsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
@@ -457,10 +383,7 @@ func (mc *MatchCreate) createSpec() (*Match, *sqlgraph.CreateSpec) {
Columns: match.PlayersPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeUint64,
Column: player.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(player.FieldID, field.TypeUint64),
},
}
for _, k := range nodes {
@@ -495,8 +418,8 @@ func (mcb *MatchCreateBulk) Save(ctx context.Context) ([]*Match, error) {
return nil, err
}
builder.mutation = mutation
nodes[i], specs[i] = builder.createSpec()
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, mcb.builders[i+1].mutation)
} else {
@@ -504,7 +427,7 @@ func (mcb *MatchCreateBulk) Save(ctx context.Context) ([]*Match, error) {
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, mcb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
@@ -512,11 +435,11 @@ func (mcb *MatchCreateBulk) Save(ctx context.Context) ([]*Match, error) {
return nil, err
}
mutation.id = &nodes[i].ID
mutation.done = true
if specs[i].ID.Value != nil && nodes[i].ID == 0 {
id := specs[i].ID.Value.(int64)
nodes[i].ID = uint64(id)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -1,16 +1,15 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"csgowtfd/ent/match"
"csgowtfd/ent/predicate"
"fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"somegit.dev/csgowtf/csgowtfd/ent/match"
"somegit.dev/csgowtf/csgowtfd/ent/predicate"
)
// MatchDelete is the builder for deleting a Match entity.
@@ -28,34 +27,7 @@ func (md *MatchDelete) Where(ps ...predicate.Match) *MatchDelete {
// Exec executes the deletion query and returns how many vertices were deleted.
func (md *MatchDelete) Exec(ctx context.Context) (int, error) {
var (
err error
affected int
)
if len(md.hooks) == 0 {
affected, err = md.sqlExec(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*MatchMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
md.mutation = mutation
affected, err = md.sqlExec(ctx)
mutation.done = true
return affected, err
})
for i := len(md.hooks) - 1; i >= 0; i-- {
if md.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = md.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, md.mutation); err != nil {
return 0, err
}
}
return affected, err
return withHooks(ctx, md.sqlExec, md.mutation, md.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
@@ -68,15 +40,7 @@ func (md *MatchDelete) ExecX(ctx context.Context) int {
}
func (md *MatchDelete) sqlExec(ctx context.Context) (int, error) {
_spec := &sqlgraph.DeleteSpec{
Node: &sqlgraph.NodeSpec{
Table: match.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUint64,
Column: match.FieldID,
},
},
}
_spec := sqlgraph.NewDeleteSpec(match.Table, sqlgraph.NewFieldSpec(match.FieldID, field.TypeUint64))
if ps := md.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
@@ -84,7 +48,12 @@ func (md *MatchDelete) sqlExec(ctx context.Context) (int, error) {
}
}
}
return sqlgraph.DeleteNodes(ctx, md.driver, _spec)
affected, err := sqlgraph.DeleteNodes(ctx, md.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
md.mutation.done = true
return affected, err
}
// MatchDeleteOne is the builder for deleting a single Match entity.
@@ -92,6 +61,12 @@ type MatchDeleteOne struct {
md *MatchDelete
}
// Where appends a list predicates to the MatchDelete builder.
func (mdo *MatchDeleteOne) Where(ps ...predicate.Match) *MatchDeleteOne {
mdo.md.mutation.Where(ps...)
return mdo
}
// Exec executes the deletion query.
func (mdo *MatchDeleteOne) Exec(ctx context.Context) error {
n, err := mdo.md.Exec(ctx)
@@ -107,5 +82,7 @@ func (mdo *MatchDeleteOne) Exec(ctx context.Context) error {
// ExecX is like Exec, but panics if an error occurs.
func (mdo *MatchDeleteOne) ExecX(ctx context.Context) {
mdo.md.ExecX(ctx)
if err := mdo.Exec(ctx); err != nil {
panic(err)
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +1,9 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"csgowtfd/ent/match"
"csgowtfd/ent/matchplayer"
"csgowtfd/ent/player"
"csgowtfd/ent/predicate"
"errors"
"fmt"
"time"
@@ -15,6 +11,10 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"somegit.dev/csgowtf/csgowtfd/ent/match"
"somegit.dev/csgowtf/csgowtfd/ent/matchplayer"
"somegit.dev/csgowtf/csgowtfd/ent/player"
"somegit.dev/csgowtf/csgowtfd/ent/predicate"
)
// MatchUpdate is the builder for updating Match entities.
@@ -22,6 +22,7 @@ type MatchUpdate struct {
config
hooks []Hook
mutation *MatchMutation
modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the MatchUpdate builder.
@@ -201,6 +202,33 @@ func (mu *MatchUpdate) ClearDecryptionKey() *MatchUpdate {
return mu
}
// SetTickRate sets the "tick_rate" field.
func (mu *MatchUpdate) SetTickRate(f float64) *MatchUpdate {
mu.mutation.ResetTickRate()
mu.mutation.SetTickRate(f)
return mu
}
// SetNillableTickRate sets the "tick_rate" field if the given value is not nil.
func (mu *MatchUpdate) SetNillableTickRate(f *float64) *MatchUpdate {
if f != nil {
mu.SetTickRate(*f)
}
return mu
}
// AddTickRate adds f to the "tick_rate" field.
func (mu *MatchUpdate) AddTickRate(f float64) *MatchUpdate {
mu.mutation.AddTickRate(f)
return mu
}
// ClearTickRate clears the value of the "tick_rate" field.
func (mu *MatchUpdate) ClearTickRate() *MatchUpdate {
mu.mutation.ClearTickRate()
return mu
}
// AddStatIDs adds the "stats" edge to the MatchPlayer entity by IDs.
func (mu *MatchUpdate) AddStatIDs(ids ...int) *MatchUpdate {
mu.mutation.AddStatIDs(ids...)
@@ -280,34 +308,7 @@ func (mu *MatchUpdate) RemovePlayers(p ...*Player) *MatchUpdate {
// Save executes the query and returns the number of nodes affected by the update operation.
func (mu *MatchUpdate) Save(ctx context.Context) (int, error) {
var (
err error
affected int
)
if len(mu.hooks) == 0 {
affected, err = mu.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*MatchMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
mu.mutation = mutation
affected, err = mu.sqlSave(ctx)
mutation.done = true
return affected, err
})
for i := len(mu.hooks) - 1; i >= 0; i-- {
if mu.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = mu.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, mu.mutation); err != nil {
return 0, err
}
}
return affected, err
return withHooks(ctx, mu.sqlSave, mu.mutation, mu.hooks)
}
// SaveX is like Save, but panics if an error occurs.
@@ -332,17 +333,14 @@ func (mu *MatchUpdate) ExecX(ctx context.Context) {
}
}
func (mu *MatchUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: match.Table,
Columns: match.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUint64,
Column: match.FieldID,
},
},
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (mu *MatchUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *MatchUpdate {
mu.modifiers = append(mu.modifiers, modifiers...)
return mu
}
func (mu *MatchUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := sqlgraph.NewUpdateSpec(match.Table, match.Columns, sqlgraph.NewFieldSpec(match.FieldID, field.TypeUint64))
if ps := mu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
@@ -351,148 +349,76 @@ func (mu *MatchUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
}
if value, ok := mu.mutation.ShareCode(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: match.FieldShareCode,
})
_spec.SetField(match.FieldShareCode, field.TypeString, value)
}
if value, ok := mu.mutation.Map(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: match.FieldMap,
})
_spec.SetField(match.FieldMap, field.TypeString, value)
}
if mu.mutation.MapCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeString,
Column: match.FieldMap,
})
_spec.ClearField(match.FieldMap, field.TypeString)
}
if value, ok := mu.mutation.Date(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeTime,
Value: value,
Column: match.FieldDate,
})
_spec.SetField(match.FieldDate, field.TypeTime, value)
}
if value, ok := mu.mutation.ScoreTeamA(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: match.FieldScoreTeamA,
})
_spec.SetField(match.FieldScoreTeamA, field.TypeInt, value)
}
if value, ok := mu.mutation.AddedScoreTeamA(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: match.FieldScoreTeamA,
})
_spec.AddField(match.FieldScoreTeamA, field.TypeInt, value)
}
if value, ok := mu.mutation.ScoreTeamB(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: match.FieldScoreTeamB,
})
_spec.SetField(match.FieldScoreTeamB, field.TypeInt, value)
}
if value, ok := mu.mutation.AddedScoreTeamB(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: match.FieldScoreTeamB,
})
_spec.AddField(match.FieldScoreTeamB, field.TypeInt, value)
}
if value, ok := mu.mutation.ReplayURL(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: match.FieldReplayURL,
})
_spec.SetField(match.FieldReplayURL, field.TypeString, value)
}
if mu.mutation.ReplayURLCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeString,
Column: match.FieldReplayURL,
})
_spec.ClearField(match.FieldReplayURL, field.TypeString)
}
if value, ok := mu.mutation.Duration(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: match.FieldDuration,
})
_spec.SetField(match.FieldDuration, field.TypeInt, value)
}
if value, ok := mu.mutation.AddedDuration(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: match.FieldDuration,
})
_spec.AddField(match.FieldDuration, field.TypeInt, value)
}
if value, ok := mu.mutation.MatchResult(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: match.FieldMatchResult,
})
_spec.SetField(match.FieldMatchResult, field.TypeInt, value)
}
if value, ok := mu.mutation.AddedMatchResult(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: match.FieldMatchResult,
})
_spec.AddField(match.FieldMatchResult, field.TypeInt, value)
}
if value, ok := mu.mutation.MaxRounds(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: match.FieldMaxRounds,
})
_spec.SetField(match.FieldMaxRounds, field.TypeInt, value)
}
if value, ok := mu.mutation.AddedMaxRounds(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: match.FieldMaxRounds,
})
_spec.AddField(match.FieldMaxRounds, field.TypeInt, value)
}
if value, ok := mu.mutation.DemoParsed(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeBool,
Value: value,
Column: match.FieldDemoParsed,
})
_spec.SetField(match.FieldDemoParsed, field.TypeBool, value)
}
if value, ok := mu.mutation.VacPresent(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeBool,
Value: value,
Column: match.FieldVacPresent,
})
_spec.SetField(match.FieldVacPresent, field.TypeBool, value)
}
if value, ok := mu.mutation.GamebanPresent(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeBool,
Value: value,
Column: match.FieldGamebanPresent,
})
_spec.SetField(match.FieldGamebanPresent, field.TypeBool, value)
}
if value, ok := mu.mutation.DecryptionKey(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeBytes,
Value: value,
Column: match.FieldDecryptionKey,
})
_spec.SetField(match.FieldDecryptionKey, field.TypeBytes, value)
}
if mu.mutation.DecryptionKeyCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeBytes,
Column: match.FieldDecryptionKey,
})
_spec.ClearField(match.FieldDecryptionKey, field.TypeBytes)
}
if value, ok := mu.mutation.TickRate(); ok {
_spec.SetField(match.FieldTickRate, field.TypeFloat64, value)
}
if value, ok := mu.mutation.AddedTickRate(); ok {
_spec.AddField(match.FieldTickRate, field.TypeFloat64, value)
}
if mu.mutation.TickRateCleared() {
_spec.ClearField(match.FieldTickRate, field.TypeFloat64)
}
if mu.mutation.StatsCleared() {
edge := &sqlgraph.EdgeSpec{
@@ -502,10 +428,7 @@ func (mu *MatchUpdate) sqlSave(ctx context.Context) (n int, err error) {
Columns: []string{match.StatsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
@@ -518,10 +441,7 @@ func (mu *MatchUpdate) sqlSave(ctx context.Context) (n int, err error) {
Columns: []string{match.StatsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
@@ -537,10 +457,7 @@ func (mu *MatchUpdate) sqlSave(ctx context.Context) (n int, err error) {
Columns: []string{match.StatsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
@@ -556,10 +473,7 @@ func (mu *MatchUpdate) sqlSave(ctx context.Context) (n int, err error) {
Columns: match.PlayersPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeUint64,
Column: player.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(player.FieldID, field.TypeUint64),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
@@ -572,10 +486,7 @@ func (mu *MatchUpdate) sqlSave(ctx context.Context) (n int, err error) {
Columns: match.PlayersPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeUint64,
Column: player.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(player.FieldID, field.TypeUint64),
},
}
for _, k := range nodes {
@@ -591,10 +502,7 @@ func (mu *MatchUpdate) sqlSave(ctx context.Context) (n int, err error) {
Columns: match.PlayersPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeUint64,
Column: player.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(player.FieldID, field.TypeUint64),
},
}
for _, k := range nodes {
@@ -602,14 +510,16 @@ func (mu *MatchUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_spec.AddModifiers(mu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, mu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{match.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
mu.mutation.done = true
return n, nil
}
@@ -619,6 +529,7 @@ type MatchUpdateOne struct {
fields []string
hooks []Hook
mutation *MatchMutation
modifiers []func(*sql.UpdateBuilder)
}
// SetShareCode sets the "share_code" field.
@@ -792,6 +703,33 @@ func (muo *MatchUpdateOne) ClearDecryptionKey() *MatchUpdateOne {
return muo
}
// SetTickRate sets the "tick_rate" field.
func (muo *MatchUpdateOne) SetTickRate(f float64) *MatchUpdateOne {
muo.mutation.ResetTickRate()
muo.mutation.SetTickRate(f)
return muo
}
// SetNillableTickRate sets the "tick_rate" field if the given value is not nil.
func (muo *MatchUpdateOne) SetNillableTickRate(f *float64) *MatchUpdateOne {
if f != nil {
muo.SetTickRate(*f)
}
return muo
}
// AddTickRate adds f to the "tick_rate" field.
func (muo *MatchUpdateOne) AddTickRate(f float64) *MatchUpdateOne {
muo.mutation.AddTickRate(f)
return muo
}
// ClearTickRate clears the value of the "tick_rate" field.
func (muo *MatchUpdateOne) ClearTickRate() *MatchUpdateOne {
muo.mutation.ClearTickRate()
return muo
}
// AddStatIDs adds the "stats" edge to the MatchPlayer entity by IDs.
func (muo *MatchUpdateOne) AddStatIDs(ids ...int) *MatchUpdateOne {
muo.mutation.AddStatIDs(ids...)
@@ -869,6 +807,12 @@ func (muo *MatchUpdateOne) RemovePlayers(p ...*Player) *MatchUpdateOne {
return muo.RemovePlayerIDs(ids...)
}
// Where appends a list predicates to the MatchUpdate builder.
func (muo *MatchUpdateOne) Where(ps ...predicate.Match) *MatchUpdateOne {
muo.mutation.Where(ps...)
return muo
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (muo *MatchUpdateOne) Select(field string, fields ...string) *MatchUpdateOne {
@@ -878,34 +822,7 @@ func (muo *MatchUpdateOne) Select(field string, fields ...string) *MatchUpdateOn
// Save executes the query and returns the updated Match entity.
func (muo *MatchUpdateOne) Save(ctx context.Context) (*Match, error) {
var (
err error
node *Match
)
if len(muo.hooks) == 0 {
node, err = muo.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*MatchMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
muo.mutation = mutation
node, err = muo.sqlSave(ctx)
mutation.done = true
return node, err
})
for i := len(muo.hooks) - 1; i >= 0; i-- {
if muo.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = muo.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, muo.mutation); err != nil {
return nil, err
}
}
return node, err
return withHooks(ctx, muo.sqlSave, muo.mutation, muo.hooks)
}
// SaveX is like Save, but panics if an error occurs.
@@ -930,17 +847,14 @@ func (muo *MatchUpdateOne) ExecX(ctx context.Context) {
}
}
func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error) {
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: match.Table,
Columns: match.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUint64,
Column: match.FieldID,
},
},
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (muo *MatchUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *MatchUpdateOne {
muo.modifiers = append(muo.modifiers, modifiers...)
return muo
}
func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error) {
_spec := sqlgraph.NewUpdateSpec(match.Table, match.Columns, sqlgraph.NewFieldSpec(match.FieldID, field.TypeUint64))
id, ok := muo.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Match.id" for update`)}
@@ -966,148 +880,76 @@ func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error
}
}
if value, ok := muo.mutation.ShareCode(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: match.FieldShareCode,
})
_spec.SetField(match.FieldShareCode, field.TypeString, value)
}
if value, ok := muo.mutation.Map(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: match.FieldMap,
})
_spec.SetField(match.FieldMap, field.TypeString, value)
}
if muo.mutation.MapCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeString,
Column: match.FieldMap,
})
_spec.ClearField(match.FieldMap, field.TypeString)
}
if value, ok := muo.mutation.Date(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeTime,
Value: value,
Column: match.FieldDate,
})
_spec.SetField(match.FieldDate, field.TypeTime, value)
}
if value, ok := muo.mutation.ScoreTeamA(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: match.FieldScoreTeamA,
})
_spec.SetField(match.FieldScoreTeamA, field.TypeInt, value)
}
if value, ok := muo.mutation.AddedScoreTeamA(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: match.FieldScoreTeamA,
})
_spec.AddField(match.FieldScoreTeamA, field.TypeInt, value)
}
if value, ok := muo.mutation.ScoreTeamB(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: match.FieldScoreTeamB,
})
_spec.SetField(match.FieldScoreTeamB, field.TypeInt, value)
}
if value, ok := muo.mutation.AddedScoreTeamB(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: match.FieldScoreTeamB,
})
_spec.AddField(match.FieldScoreTeamB, field.TypeInt, value)
}
if value, ok := muo.mutation.ReplayURL(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: match.FieldReplayURL,
})
_spec.SetField(match.FieldReplayURL, field.TypeString, value)
}
if muo.mutation.ReplayURLCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeString,
Column: match.FieldReplayURL,
})
_spec.ClearField(match.FieldReplayURL, field.TypeString)
}
if value, ok := muo.mutation.Duration(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: match.FieldDuration,
})
_spec.SetField(match.FieldDuration, field.TypeInt, value)
}
if value, ok := muo.mutation.AddedDuration(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: match.FieldDuration,
})
_spec.AddField(match.FieldDuration, field.TypeInt, value)
}
if value, ok := muo.mutation.MatchResult(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: match.FieldMatchResult,
})
_spec.SetField(match.FieldMatchResult, field.TypeInt, value)
}
if value, ok := muo.mutation.AddedMatchResult(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: match.FieldMatchResult,
})
_spec.AddField(match.FieldMatchResult, field.TypeInt, value)
}
if value, ok := muo.mutation.MaxRounds(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: match.FieldMaxRounds,
})
_spec.SetField(match.FieldMaxRounds, field.TypeInt, value)
}
if value, ok := muo.mutation.AddedMaxRounds(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: match.FieldMaxRounds,
})
_spec.AddField(match.FieldMaxRounds, field.TypeInt, value)
}
if value, ok := muo.mutation.DemoParsed(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeBool,
Value: value,
Column: match.FieldDemoParsed,
})
_spec.SetField(match.FieldDemoParsed, field.TypeBool, value)
}
if value, ok := muo.mutation.VacPresent(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeBool,
Value: value,
Column: match.FieldVacPresent,
})
_spec.SetField(match.FieldVacPresent, field.TypeBool, value)
}
if value, ok := muo.mutation.GamebanPresent(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeBool,
Value: value,
Column: match.FieldGamebanPresent,
})
_spec.SetField(match.FieldGamebanPresent, field.TypeBool, value)
}
if value, ok := muo.mutation.DecryptionKey(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeBytes,
Value: value,
Column: match.FieldDecryptionKey,
})
_spec.SetField(match.FieldDecryptionKey, field.TypeBytes, value)
}
if muo.mutation.DecryptionKeyCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeBytes,
Column: match.FieldDecryptionKey,
})
_spec.ClearField(match.FieldDecryptionKey, field.TypeBytes)
}
if value, ok := muo.mutation.TickRate(); ok {
_spec.SetField(match.FieldTickRate, field.TypeFloat64, value)
}
if value, ok := muo.mutation.AddedTickRate(); ok {
_spec.AddField(match.FieldTickRate, field.TypeFloat64, value)
}
if muo.mutation.TickRateCleared() {
_spec.ClearField(match.FieldTickRate, field.TypeFloat64)
}
if muo.mutation.StatsCleared() {
edge := &sqlgraph.EdgeSpec{
@@ -1117,10 +959,7 @@ func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error
Columns: []string{match.StatsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
@@ -1133,10 +972,7 @@ func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error
Columns: []string{match.StatsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
@@ -1152,10 +988,7 @@ func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error
Columns: []string{match.StatsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
@@ -1171,10 +1004,7 @@ func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error
Columns: match.PlayersPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeUint64,
Column: player.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(player.FieldID, field.TypeUint64),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
@@ -1187,10 +1017,7 @@ func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error
Columns: match.PlayersPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeUint64,
Column: player.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(player.FieldID, field.TypeUint64),
},
}
for _, k := range nodes {
@@ -1206,10 +1033,7 @@ func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error
Columns: match.PlayersPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeUint64,
Column: player.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(player.FieldID, field.TypeUint64),
},
}
for _, k := range nodes {
@@ -1217,6 +1041,7 @@ func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_spec.AddModifiers(muo.modifiers...)
_node = &Match{config: muo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
@@ -1224,9 +1049,10 @@ func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{match.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
muo.mutation.done = true
return _node, nil
}

View File

@@ -1,15 +1,16 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"csgowtfd/ent/match"
"csgowtfd/ent/matchplayer"
"csgowtfd/ent/player"
"fmt"
"strings"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"somegit.dev/csgowtf/csgowtfd/ent/match"
"somegit.dev/csgowtf/csgowtfd/ent/matchplayer"
"somegit.dev/csgowtf/csgowtfd/ent/player"
)
// MatchPlayer is the model entity for the MatchPlayer schema.
@@ -81,9 +82,12 @@ type MatchPlayer struct {
PlayerStats uint64 `json:"player_stats,omitempty"`
// FlashAssists holds the value of the "flash_assists" field.
FlashAssists int `json:"flash_assists,omitempty"`
// AvgPing holds the value of the "avg_ping" field.
AvgPing float64 `json:"avg_ping,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the MatchPlayerQuery when eager-loading is set.
Edges MatchPlayerEdges `json:"edges"`
selectValues sql.SelectValues
}
// MatchPlayerEdges holds the relations/edges for other nodes in the graph.
@@ -110,8 +114,7 @@ type MatchPlayerEdges struct {
func (e MatchPlayerEdges) MatchesOrErr() (*Match, error) {
if e.loadedTypes[0] {
if e.Matches == nil {
// The edge matches was loaded in eager-loading,
// but was not found.
// Edge was loaded but was not found.
return nil, &NotFoundError{label: match.Label}
}
return e.Matches, nil
@@ -124,8 +127,7 @@ func (e MatchPlayerEdges) MatchesOrErr() (*Match, error) {
func (e MatchPlayerEdges) PlayersOrErr() (*Player, error) {
if e.loadedTypes[1] {
if e.Players == nil {
// The edge players was loaded in eager-loading,
// but was not found.
// Edge was loaded but was not found.
return nil, &NotFoundError{label: player.Label}
}
return e.Players, nil
@@ -170,18 +172,18 @@ func (e MatchPlayerEdges) MessagesOrErr() ([]*Messages, error) {
}
// scanValues returns the types for scanning values from sql.Rows.
func (*MatchPlayer) scanValues(columns []string) ([]interface{}, error) {
values := make([]interface{}, len(columns))
func (*MatchPlayer) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case matchplayer.FieldFlashDurationSelf, matchplayer.FieldFlashDurationTeam, matchplayer.FieldFlashDurationEnemy:
case matchplayer.FieldFlashDurationSelf, matchplayer.FieldFlashDurationTeam, matchplayer.FieldFlashDurationEnemy, matchplayer.FieldAvgPing:
values[i] = new(sql.NullFloat64)
case matchplayer.FieldID, matchplayer.FieldTeamID, matchplayer.FieldKills, matchplayer.FieldDeaths, matchplayer.FieldAssists, matchplayer.FieldHeadshot, matchplayer.FieldMvp, matchplayer.FieldScore, matchplayer.FieldRankNew, matchplayer.FieldRankOld, matchplayer.FieldMk2, matchplayer.FieldMk3, matchplayer.FieldMk4, matchplayer.FieldMk5, matchplayer.FieldDmgEnemy, matchplayer.FieldDmgTeam, matchplayer.FieldUdHe, matchplayer.FieldUdFlames, matchplayer.FieldUdFlash, matchplayer.FieldUdDecoy, matchplayer.FieldUdSmoke, matchplayer.FieldKast, matchplayer.FieldFlashTotalSelf, matchplayer.FieldFlashTotalTeam, matchplayer.FieldFlashTotalEnemy, matchplayer.FieldMatchStats, matchplayer.FieldPlayerStats, matchplayer.FieldFlashAssists:
values[i] = new(sql.NullInt64)
case matchplayer.FieldCrosshair, matchplayer.FieldColor:
values[i] = new(sql.NullString)
default:
return nil, fmt.Errorf("unexpected column %q for type MatchPlayer", columns[i])
values[i] = new(sql.UnknownType)
}
}
return values, nil
@@ -189,7 +191,7 @@ func (*MatchPlayer) scanValues(columns []string) ([]interface{}, error) {
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the MatchPlayer fields.
func (mp *MatchPlayer) assignValues(columns []string, values []interface{}) error {
func (mp *MatchPlayer) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
@@ -393,56 +395,70 @@ func (mp *MatchPlayer) assignValues(columns []string, values []interface{}) erro
} else if value.Valid {
mp.FlashAssists = int(value.Int64)
}
case matchplayer.FieldAvgPing:
if value, ok := values[i].(*sql.NullFloat64); !ok {
return fmt.Errorf("unexpected type %T for field avg_ping", values[i])
} else if value.Valid {
mp.AvgPing = value.Float64
}
default:
mp.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the MatchPlayer.
// This includes values selected through modifiers, order, etc.
func (mp *MatchPlayer) Value(name string) (ent.Value, error) {
return mp.selectValues.Get(name)
}
// QueryMatches queries the "matches" edge of the MatchPlayer entity.
func (mp *MatchPlayer) QueryMatches() *MatchQuery {
return (&MatchPlayerClient{config: mp.config}).QueryMatches(mp)
return NewMatchPlayerClient(mp.config).QueryMatches(mp)
}
// QueryPlayers queries the "players" edge of the MatchPlayer entity.
func (mp *MatchPlayer) QueryPlayers() *PlayerQuery {
return (&MatchPlayerClient{config: mp.config}).QueryPlayers(mp)
return NewMatchPlayerClient(mp.config).QueryPlayers(mp)
}
// QueryWeaponStats queries the "weapon_stats" edge of the MatchPlayer entity.
func (mp *MatchPlayer) QueryWeaponStats() *WeaponQuery {
return (&MatchPlayerClient{config: mp.config}).QueryWeaponStats(mp)
return NewMatchPlayerClient(mp.config).QueryWeaponStats(mp)
}
// QueryRoundStats queries the "round_stats" edge of the MatchPlayer entity.
func (mp *MatchPlayer) QueryRoundStats() *RoundStatsQuery {
return (&MatchPlayerClient{config: mp.config}).QueryRoundStats(mp)
return NewMatchPlayerClient(mp.config).QueryRoundStats(mp)
}
// QuerySpray queries the "spray" edge of the MatchPlayer entity.
func (mp *MatchPlayer) QuerySpray() *SprayQuery {
return (&MatchPlayerClient{config: mp.config}).QuerySpray(mp)
return NewMatchPlayerClient(mp.config).QuerySpray(mp)
}
// QueryMessages queries the "messages" edge of the MatchPlayer entity.
func (mp *MatchPlayer) QueryMessages() *MessagesQuery {
return (&MatchPlayerClient{config: mp.config}).QueryMessages(mp)
return NewMatchPlayerClient(mp.config).QueryMessages(mp)
}
// Update returns a builder for updating this MatchPlayer.
// Note that you need to call MatchPlayer.Unwrap() before calling this method if this MatchPlayer
// was returned from a transaction, and the transaction was committed or rolled back.
func (mp *MatchPlayer) Update() *MatchPlayerUpdateOne {
return (&MatchPlayerClient{config: mp.config}).UpdateOne(mp)
return NewMatchPlayerClient(mp.config).UpdateOne(mp)
}
// Unwrap unwraps the MatchPlayer 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 (mp *MatchPlayer) Unwrap() *MatchPlayer {
tx, ok := mp.config.driver.(*txDriver)
_tx, ok := mp.config.driver.(*txDriver)
if !ok {
panic("ent: MatchPlayer is not a transactional entity")
}
mp.config.driver = tx.drv
mp.config.driver = _tx.drv
return mp
}
@@ -450,80 +466,108 @@ func (mp *MatchPlayer) Unwrap() *MatchPlayer {
func (mp *MatchPlayer) String() string {
var builder strings.Builder
builder.WriteString("MatchPlayer(")
builder.WriteString(fmt.Sprintf("id=%v", mp.ID))
builder.WriteString(", team_id=")
builder.WriteString(fmt.Sprintf("id=%v, ", mp.ID))
builder.WriteString("team_id=")
builder.WriteString(fmt.Sprintf("%v", mp.TeamID))
builder.WriteString(", kills=")
builder.WriteString(", ")
builder.WriteString("kills=")
builder.WriteString(fmt.Sprintf("%v", mp.Kills))
builder.WriteString(", deaths=")
builder.WriteString(", ")
builder.WriteString("deaths=")
builder.WriteString(fmt.Sprintf("%v", mp.Deaths))
builder.WriteString(", assists=")
builder.WriteString(", ")
builder.WriteString("assists=")
builder.WriteString(fmt.Sprintf("%v", mp.Assists))
builder.WriteString(", headshot=")
builder.WriteString(", ")
builder.WriteString("headshot=")
builder.WriteString(fmt.Sprintf("%v", mp.Headshot))
builder.WriteString(", mvp=")
builder.WriteString(", ")
builder.WriteString("mvp=")
builder.WriteString(fmt.Sprintf("%v", mp.Mvp))
builder.WriteString(", score=")
builder.WriteString(", ")
builder.WriteString("score=")
builder.WriteString(fmt.Sprintf("%v", mp.Score))
builder.WriteString(", rank_new=")
builder.WriteString(", ")
builder.WriteString("rank_new=")
builder.WriteString(fmt.Sprintf("%v", mp.RankNew))
builder.WriteString(", rank_old=")
builder.WriteString(", ")
builder.WriteString("rank_old=")
builder.WriteString(fmt.Sprintf("%v", mp.RankOld))
builder.WriteString(", mk_2=")
builder.WriteString(", ")
builder.WriteString("mk_2=")
builder.WriteString(fmt.Sprintf("%v", mp.Mk2))
builder.WriteString(", mk_3=")
builder.WriteString(", ")
builder.WriteString("mk_3=")
builder.WriteString(fmt.Sprintf("%v", mp.Mk3))
builder.WriteString(", mk_4=")
builder.WriteString(", ")
builder.WriteString("mk_4=")
builder.WriteString(fmt.Sprintf("%v", mp.Mk4))
builder.WriteString(", mk_5=")
builder.WriteString(", ")
builder.WriteString("mk_5=")
builder.WriteString(fmt.Sprintf("%v", mp.Mk5))
builder.WriteString(", dmg_enemy=")
builder.WriteString(", ")
builder.WriteString("dmg_enemy=")
builder.WriteString(fmt.Sprintf("%v", mp.DmgEnemy))
builder.WriteString(", dmg_team=")
builder.WriteString(", ")
builder.WriteString("dmg_team=")
builder.WriteString(fmt.Sprintf("%v", mp.DmgTeam))
builder.WriteString(", ud_he=")
builder.WriteString(", ")
builder.WriteString("ud_he=")
builder.WriteString(fmt.Sprintf("%v", mp.UdHe))
builder.WriteString(", ud_flames=")
builder.WriteString(", ")
builder.WriteString("ud_flames=")
builder.WriteString(fmt.Sprintf("%v", mp.UdFlames))
builder.WriteString(", ud_flash=")
builder.WriteString(", ")
builder.WriteString("ud_flash=")
builder.WriteString(fmt.Sprintf("%v", mp.UdFlash))
builder.WriteString(", ud_decoy=")
builder.WriteString(", ")
builder.WriteString("ud_decoy=")
builder.WriteString(fmt.Sprintf("%v", mp.UdDecoy))
builder.WriteString(", ud_smoke=")
builder.WriteString(", ")
builder.WriteString("ud_smoke=")
builder.WriteString(fmt.Sprintf("%v", mp.UdSmoke))
builder.WriteString(", crosshair=")
builder.WriteString(", ")
builder.WriteString("crosshair=")
builder.WriteString(mp.Crosshair)
builder.WriteString(", color=")
builder.WriteString(", ")
builder.WriteString("color=")
builder.WriteString(fmt.Sprintf("%v", mp.Color))
builder.WriteString(", kast=")
builder.WriteString(", ")
builder.WriteString("kast=")
builder.WriteString(fmt.Sprintf("%v", mp.Kast))
builder.WriteString(", flash_duration_self=")
builder.WriteString(", ")
builder.WriteString("flash_duration_self=")
builder.WriteString(fmt.Sprintf("%v", mp.FlashDurationSelf))
builder.WriteString(", flash_duration_team=")
builder.WriteString(", ")
builder.WriteString("flash_duration_team=")
builder.WriteString(fmt.Sprintf("%v", mp.FlashDurationTeam))
builder.WriteString(", flash_duration_enemy=")
builder.WriteString(", ")
builder.WriteString("flash_duration_enemy=")
builder.WriteString(fmt.Sprintf("%v", mp.FlashDurationEnemy))
builder.WriteString(", flash_total_self=")
builder.WriteString(", ")
builder.WriteString("flash_total_self=")
builder.WriteString(fmt.Sprintf("%v", mp.FlashTotalSelf))
builder.WriteString(", flash_total_team=")
builder.WriteString(", ")
builder.WriteString("flash_total_team=")
builder.WriteString(fmt.Sprintf("%v", mp.FlashTotalTeam))
builder.WriteString(", flash_total_enemy=")
builder.WriteString(", ")
builder.WriteString("flash_total_enemy=")
builder.WriteString(fmt.Sprintf("%v", mp.FlashTotalEnemy))
builder.WriteString(", match_stats=")
builder.WriteString(", ")
builder.WriteString("match_stats=")
builder.WriteString(fmt.Sprintf("%v", mp.MatchStats))
builder.WriteString(", player_stats=")
builder.WriteString(", ")
builder.WriteString("player_stats=")
builder.WriteString(fmt.Sprintf("%v", mp.PlayerStats))
builder.WriteString(", flash_assists=")
builder.WriteString(", ")
builder.WriteString("flash_assists=")
builder.WriteString(fmt.Sprintf("%v", mp.FlashAssists))
builder.WriteString(", ")
builder.WriteString("avg_ping=")
builder.WriteString(fmt.Sprintf("%v", mp.AvgPing))
builder.WriteByte(')')
return builder.String()
}
// MatchPlayers is a parsable slice of MatchPlayer.
type MatchPlayers []*MatchPlayer
func (mp MatchPlayers) config(cfg config) {
for _i := range mp {
mp[_i].config = cfg
}
}

View File

@@ -1,9 +1,12 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package matchplayer
import (
"fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
const (
@@ -75,6 +78,8 @@ const (
FieldPlayerStats = "player_stats"
// FieldFlashAssists holds the string denoting the flash_assists field in the database.
FieldFlashAssists = "flash_assists"
// FieldAvgPing holds the string denoting the avg_ping field in the database.
FieldAvgPing = "avg_ping"
// EdgeMatches holds the string denoting the matches edge name in mutations.
EdgeMatches = "matches"
// EdgePlayers holds the string denoting the players edge name in mutations.
@@ -168,6 +173,7 @@ var Columns = []string{
FieldMatchStats,
FieldPlayerStats,
FieldFlashAssists,
FieldAvgPing,
}
// ValidColumn reports if the column name is valid (part of the table columns).
@@ -206,3 +212,288 @@ func ColorValidator(c Color) error {
return fmt.Errorf("matchplayer: invalid enum value for color field: %q", c)
}
}
// OrderOption defines the ordering options for the MatchPlayer queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByTeamID orders the results by the team_id field.
func ByTeamID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTeamID, opts...).ToFunc()
}
// ByKills orders the results by the kills field.
func ByKills(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldKills, opts...).ToFunc()
}
// ByDeaths orders the results by the deaths field.
func ByDeaths(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDeaths, opts...).ToFunc()
}
// ByAssists orders the results by the assists field.
func ByAssists(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAssists, opts...).ToFunc()
}
// ByHeadshot orders the results by the headshot field.
func ByHeadshot(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldHeadshot, opts...).ToFunc()
}
// ByMvp orders the results by the mvp field.
func ByMvp(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMvp, opts...).ToFunc()
}
// ByScore orders the results by the score field.
func ByScore(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldScore, opts...).ToFunc()
}
// ByRankNew orders the results by the rank_new field.
func ByRankNew(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldRankNew, opts...).ToFunc()
}
// ByRankOld orders the results by the rank_old field.
func ByRankOld(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldRankOld, opts...).ToFunc()
}
// ByMk2 orders the results by the mk_2 field.
func ByMk2(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMk2, opts...).ToFunc()
}
// ByMk3 orders the results by the mk_3 field.
func ByMk3(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMk3, opts...).ToFunc()
}
// ByMk4 orders the results by the mk_4 field.
func ByMk4(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMk4, opts...).ToFunc()
}
// ByMk5 orders the results by the mk_5 field.
func ByMk5(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMk5, opts...).ToFunc()
}
// ByDmgEnemy orders the results by the dmg_enemy field.
func ByDmgEnemy(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDmgEnemy, opts...).ToFunc()
}
// ByDmgTeam orders the results by the dmg_team field.
func ByDmgTeam(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDmgTeam, opts...).ToFunc()
}
// ByUdHe orders the results by the ud_he field.
func ByUdHe(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUdHe, opts...).ToFunc()
}
// ByUdFlames orders the results by the ud_flames field.
func ByUdFlames(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUdFlames, opts...).ToFunc()
}
// ByUdFlash orders the results by the ud_flash field.
func ByUdFlash(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUdFlash, opts...).ToFunc()
}
// ByUdDecoy orders the results by the ud_decoy field.
func ByUdDecoy(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUdDecoy, opts...).ToFunc()
}
// ByUdSmoke orders the results by the ud_smoke field.
func ByUdSmoke(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUdSmoke, opts...).ToFunc()
}
// ByCrosshair orders the results by the crosshair field.
func ByCrosshair(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCrosshair, opts...).ToFunc()
}
// ByColor orders the results by the color field.
func ByColor(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldColor, opts...).ToFunc()
}
// ByKast orders the results by the kast field.
func ByKast(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldKast, opts...).ToFunc()
}
// ByFlashDurationSelf orders the results by the flash_duration_self field.
func ByFlashDurationSelf(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldFlashDurationSelf, opts...).ToFunc()
}
// ByFlashDurationTeam orders the results by the flash_duration_team field.
func ByFlashDurationTeam(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldFlashDurationTeam, opts...).ToFunc()
}
// ByFlashDurationEnemy orders the results by the flash_duration_enemy field.
func ByFlashDurationEnemy(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldFlashDurationEnemy, opts...).ToFunc()
}
// ByFlashTotalSelf orders the results by the flash_total_self field.
func ByFlashTotalSelf(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldFlashTotalSelf, opts...).ToFunc()
}
// ByFlashTotalTeam orders the results by the flash_total_team field.
func ByFlashTotalTeam(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldFlashTotalTeam, opts...).ToFunc()
}
// ByFlashTotalEnemy orders the results by the flash_total_enemy field.
func ByFlashTotalEnemy(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldFlashTotalEnemy, opts...).ToFunc()
}
// ByMatchStats orders the results by the match_stats field.
func ByMatchStats(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMatchStats, opts...).ToFunc()
}
// ByPlayerStats orders the results by the player_stats field.
func ByPlayerStats(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPlayerStats, opts...).ToFunc()
}
// ByFlashAssists orders the results by the flash_assists field.
func ByFlashAssists(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldFlashAssists, opts...).ToFunc()
}
// ByAvgPing orders the results by the avg_ping field.
func ByAvgPing(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAvgPing, opts...).ToFunc()
}
// ByMatchesField orders the results by matches field.
func ByMatchesField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newMatchesStep(), sql.OrderByField(field, opts...))
}
}
// ByPlayersField orders the results by players field.
func ByPlayersField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newPlayersStep(), sql.OrderByField(field, opts...))
}
}
// ByWeaponStatsCount orders the results by weapon_stats count.
func ByWeaponStatsCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newWeaponStatsStep(), opts...)
}
}
// ByWeaponStats orders the results by weapon_stats terms.
func ByWeaponStats(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newWeaponStatsStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// ByRoundStatsCount orders the results by round_stats count.
func ByRoundStatsCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newRoundStatsStep(), opts...)
}
}
// ByRoundStats orders the results by round_stats terms.
func ByRoundStats(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newRoundStatsStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// BySprayCount orders the results by spray count.
func BySprayCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newSprayStep(), opts...)
}
}
// BySpray orders the results by spray terms.
func BySpray(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newSprayStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// ByMessagesCount orders the results by messages count.
func ByMessagesCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newMessagesStep(), opts...)
}
}
// ByMessages orders the results by messages terms.
func ByMessages(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newMessagesStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
func newMatchesStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(MatchesInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, MatchesTable, MatchesColumn),
)
}
func newPlayersStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(PlayersInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, PlayersTable, PlayersColumn),
)
}
func newWeaponStatsStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(WeaponStatsInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, WeaponStatsTable, WeaponStatsColumn),
)
}
func newRoundStatsStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(RoundStatsInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, RoundStatsTable, RoundStatsColumn),
)
}
func newSprayStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(SprayInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, SprayTable, SprayColumn),
)
}
func newMessagesStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(MessagesInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, MessagesTable, MessagesColumn),
)
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,21 +1,21 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"csgowtfd/ent/match"
"csgowtfd/ent/matchplayer"
"csgowtfd/ent/messages"
"csgowtfd/ent/player"
"csgowtfd/ent/roundstats"
"csgowtfd/ent/spray"
"csgowtfd/ent/weapon"
"errors"
"fmt"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"somegit.dev/csgowtf/csgowtfd/ent/match"
"somegit.dev/csgowtf/csgowtfd/ent/matchplayer"
"somegit.dev/csgowtf/csgowtfd/ent/messages"
"somegit.dev/csgowtf/csgowtfd/ent/player"
"somegit.dev/csgowtf/csgowtfd/ent/roundstats"
"somegit.dev/csgowtf/csgowtfd/ent/spray"
"somegit.dev/csgowtf/csgowtfd/ent/weapon"
)
// MatchPlayerCreate is the builder for creating a MatchPlayer entity.
@@ -417,6 +417,20 @@ func (mpc *MatchPlayerCreate) SetNillableFlashAssists(i *int) *MatchPlayerCreate
return mpc
}
// SetAvgPing sets the "avg_ping" field.
func (mpc *MatchPlayerCreate) SetAvgPing(f float64) *MatchPlayerCreate {
mpc.mutation.SetAvgPing(f)
return mpc
}
// SetNillableAvgPing sets the "avg_ping" field if the given value is not nil.
func (mpc *MatchPlayerCreate) SetNillableAvgPing(f *float64) *MatchPlayerCreate {
if f != nil {
mpc.SetAvgPing(*f)
}
return mpc
}
// SetMatchesID sets the "matches" edge to the Match entity by ID.
func (mpc *MatchPlayerCreate) SetMatchesID(id uint64) *MatchPlayerCreate {
mpc.mutation.SetMatchesID(id)
@@ -522,43 +536,7 @@ func (mpc *MatchPlayerCreate) Mutation() *MatchPlayerMutation {
// Save creates the MatchPlayer in the database.
func (mpc *MatchPlayerCreate) Save(ctx context.Context) (*MatchPlayer, error) {
var (
err error
node *MatchPlayer
)
if len(mpc.hooks) == 0 {
if err = mpc.check(); err != nil {
return nil, err
}
node, err = mpc.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*MatchPlayerMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = mpc.check(); err != nil {
return nil, err
}
mpc.mutation = mutation
if node, err = mpc.sqlSave(ctx); err != nil {
return nil, err
}
mutation.id = &node.ID
mutation.done = true
return node, err
})
for i := len(mpc.hooks) - 1; i >= 0; i-- {
if mpc.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = mpc.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, mpc.mutation); err != nil {
return nil, err
}
}
return node, err
return withHooks(ctx, mpc.sqlSave, mpc.mutation, mpc.hooks)
}
// SaveX calls Save and panics if Save returns an error.
@@ -615,269 +593,152 @@ func (mpc *MatchPlayerCreate) check() error {
}
func (mpc *MatchPlayerCreate) sqlSave(ctx context.Context) (*MatchPlayer, error) {
if err := mpc.check(); err != nil {
return nil, err
}
_node, _spec := mpc.createSpec()
if err := sqlgraph.CreateNode(ctx, mpc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
id := _spec.ID.Value.(int64)
_node.ID = int(id)
mpc.mutation.id = &_node.ID
mpc.mutation.done = true
return _node, nil
}
func (mpc *MatchPlayerCreate) createSpec() (*MatchPlayer, *sqlgraph.CreateSpec) {
var (
_node = &MatchPlayer{config: mpc.config}
_spec = &sqlgraph.CreateSpec{
Table: matchplayer.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
}
_spec = sqlgraph.NewCreateSpec(matchplayer.Table, sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt))
)
if value, ok := mpc.mutation.TeamID(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: matchplayer.FieldTeamID,
})
_spec.SetField(matchplayer.FieldTeamID, field.TypeInt, value)
_node.TeamID = value
}
if value, ok := mpc.mutation.Kills(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: matchplayer.FieldKills,
})
_spec.SetField(matchplayer.FieldKills, field.TypeInt, value)
_node.Kills = value
}
if value, ok := mpc.mutation.Deaths(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: matchplayer.FieldDeaths,
})
_spec.SetField(matchplayer.FieldDeaths, field.TypeInt, value)
_node.Deaths = value
}
if value, ok := mpc.mutation.Assists(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: matchplayer.FieldAssists,
})
_spec.SetField(matchplayer.FieldAssists, field.TypeInt, value)
_node.Assists = value
}
if value, ok := mpc.mutation.Headshot(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: matchplayer.FieldHeadshot,
})
_spec.SetField(matchplayer.FieldHeadshot, field.TypeInt, value)
_node.Headshot = value
}
if value, ok := mpc.mutation.Mvp(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: matchplayer.FieldMvp,
})
_spec.SetField(matchplayer.FieldMvp, field.TypeUint, value)
_node.Mvp = value
}
if value, ok := mpc.mutation.Score(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: matchplayer.FieldScore,
})
_spec.SetField(matchplayer.FieldScore, field.TypeInt, value)
_node.Score = value
}
if value, ok := mpc.mutation.RankNew(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: matchplayer.FieldRankNew,
})
_spec.SetField(matchplayer.FieldRankNew, field.TypeInt, value)
_node.RankNew = value
}
if value, ok := mpc.mutation.RankOld(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: matchplayer.FieldRankOld,
})
_spec.SetField(matchplayer.FieldRankOld, field.TypeInt, value)
_node.RankOld = value
}
if value, ok := mpc.mutation.Mk2(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: matchplayer.FieldMk2,
})
_spec.SetField(matchplayer.FieldMk2, field.TypeUint, value)
_node.Mk2 = value
}
if value, ok := mpc.mutation.Mk3(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: matchplayer.FieldMk3,
})
_spec.SetField(matchplayer.FieldMk3, field.TypeUint, value)
_node.Mk3 = value
}
if value, ok := mpc.mutation.Mk4(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: matchplayer.FieldMk4,
})
_spec.SetField(matchplayer.FieldMk4, field.TypeUint, value)
_node.Mk4 = value
}
if value, ok := mpc.mutation.Mk5(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: matchplayer.FieldMk5,
})
_spec.SetField(matchplayer.FieldMk5, field.TypeUint, value)
_node.Mk5 = value
}
if value, ok := mpc.mutation.DmgEnemy(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: matchplayer.FieldDmgEnemy,
})
_spec.SetField(matchplayer.FieldDmgEnemy, field.TypeUint, value)
_node.DmgEnemy = value
}
if value, ok := mpc.mutation.DmgTeam(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: matchplayer.FieldDmgTeam,
})
_spec.SetField(matchplayer.FieldDmgTeam, field.TypeUint, value)
_node.DmgTeam = value
}
if value, ok := mpc.mutation.UdHe(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: matchplayer.FieldUdHe,
})
_spec.SetField(matchplayer.FieldUdHe, field.TypeUint, value)
_node.UdHe = value
}
if value, ok := mpc.mutation.UdFlames(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: matchplayer.FieldUdFlames,
})
_spec.SetField(matchplayer.FieldUdFlames, field.TypeUint, value)
_node.UdFlames = value
}
if value, ok := mpc.mutation.UdFlash(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: matchplayer.FieldUdFlash,
})
_spec.SetField(matchplayer.FieldUdFlash, field.TypeUint, value)
_node.UdFlash = value
}
if value, ok := mpc.mutation.UdDecoy(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: matchplayer.FieldUdDecoy,
})
_spec.SetField(matchplayer.FieldUdDecoy, field.TypeUint, value)
_node.UdDecoy = value
}
if value, ok := mpc.mutation.UdSmoke(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: matchplayer.FieldUdSmoke,
})
_spec.SetField(matchplayer.FieldUdSmoke, field.TypeUint, value)
_node.UdSmoke = value
}
if value, ok := mpc.mutation.Crosshair(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: matchplayer.FieldCrosshair,
})
_spec.SetField(matchplayer.FieldCrosshair, field.TypeString, value)
_node.Crosshair = value
}
if value, ok := mpc.mutation.Color(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeEnum,
Value: value,
Column: matchplayer.FieldColor,
})
_spec.SetField(matchplayer.FieldColor, field.TypeEnum, value)
_node.Color = value
}
if value, ok := mpc.mutation.Kast(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: matchplayer.FieldKast,
})
_spec.SetField(matchplayer.FieldKast, field.TypeInt, value)
_node.Kast = value
}
if value, ok := mpc.mutation.FlashDurationSelf(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeFloat32,
Value: value,
Column: matchplayer.FieldFlashDurationSelf,
})
_spec.SetField(matchplayer.FieldFlashDurationSelf, field.TypeFloat32, value)
_node.FlashDurationSelf = value
}
if value, ok := mpc.mutation.FlashDurationTeam(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeFloat32,
Value: value,
Column: matchplayer.FieldFlashDurationTeam,
})
_spec.SetField(matchplayer.FieldFlashDurationTeam, field.TypeFloat32, value)
_node.FlashDurationTeam = value
}
if value, ok := mpc.mutation.FlashDurationEnemy(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeFloat32,
Value: value,
Column: matchplayer.FieldFlashDurationEnemy,
})
_spec.SetField(matchplayer.FieldFlashDurationEnemy, field.TypeFloat32, value)
_node.FlashDurationEnemy = value
}
if value, ok := mpc.mutation.FlashTotalSelf(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: matchplayer.FieldFlashTotalSelf,
})
_spec.SetField(matchplayer.FieldFlashTotalSelf, field.TypeUint, value)
_node.FlashTotalSelf = value
}
if value, ok := mpc.mutation.FlashTotalTeam(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: matchplayer.FieldFlashTotalTeam,
})
_spec.SetField(matchplayer.FieldFlashTotalTeam, field.TypeUint, value)
_node.FlashTotalTeam = value
}
if value, ok := mpc.mutation.FlashTotalEnemy(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: matchplayer.FieldFlashTotalEnemy,
})
_spec.SetField(matchplayer.FieldFlashTotalEnemy, field.TypeUint, value)
_node.FlashTotalEnemy = value
}
if value, ok := mpc.mutation.FlashAssists(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: matchplayer.FieldFlashAssists,
})
_spec.SetField(matchplayer.FieldFlashAssists, field.TypeInt, value)
_node.FlashAssists = value
}
if value, ok := mpc.mutation.AvgPing(); ok {
_spec.SetField(matchplayer.FieldAvgPing, field.TypeFloat64, value)
_node.AvgPing = value
}
if nodes := mpc.mutation.MatchesIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
@@ -886,10 +747,7 @@ func (mpc *MatchPlayerCreate) createSpec() (*MatchPlayer, *sqlgraph.CreateSpec)
Columns: []string{matchplayer.MatchesColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeUint64,
Column: match.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(match.FieldID, field.TypeUint64),
},
}
for _, k := range nodes {
@@ -906,10 +764,7 @@ func (mpc *MatchPlayerCreate) createSpec() (*MatchPlayer, *sqlgraph.CreateSpec)
Columns: []string{matchplayer.PlayersColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeUint64,
Column: player.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(player.FieldID, field.TypeUint64),
},
}
for _, k := range nodes {
@@ -926,10 +781,7 @@ func (mpc *MatchPlayerCreate) createSpec() (*MatchPlayer, *sqlgraph.CreateSpec)
Columns: []string{matchplayer.WeaponStatsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: weapon.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(weapon.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
@@ -945,10 +797,7 @@ func (mpc *MatchPlayerCreate) createSpec() (*MatchPlayer, *sqlgraph.CreateSpec)
Columns: []string{matchplayer.RoundStatsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: roundstats.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(roundstats.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
@@ -964,10 +813,7 @@ func (mpc *MatchPlayerCreate) createSpec() (*MatchPlayer, *sqlgraph.CreateSpec)
Columns: []string{matchplayer.SprayColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: spray.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(spray.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
@@ -983,10 +829,7 @@ func (mpc *MatchPlayerCreate) createSpec() (*MatchPlayer, *sqlgraph.CreateSpec)
Columns: []string{matchplayer.MessagesColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: messages.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(messages.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
@@ -1020,8 +863,8 @@ func (mpcb *MatchPlayerCreateBulk) Save(ctx context.Context) ([]*MatchPlayer, er
return nil, err
}
builder.mutation = mutation
nodes[i], specs[i] = builder.createSpec()
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, mpcb.builders[i+1].mutation)
} else {
@@ -1029,7 +872,7 @@ func (mpcb *MatchPlayerCreateBulk) Save(ctx context.Context) ([]*MatchPlayer, er
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, mpcb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
@@ -1037,11 +880,11 @@ func (mpcb *MatchPlayerCreateBulk) Save(ctx context.Context) ([]*MatchPlayer, er
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)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -1,16 +1,15 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"csgowtfd/ent/matchplayer"
"csgowtfd/ent/predicate"
"fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"somegit.dev/csgowtf/csgowtfd/ent/matchplayer"
"somegit.dev/csgowtf/csgowtfd/ent/predicate"
)
// MatchPlayerDelete is the builder for deleting a MatchPlayer entity.
@@ -28,34 +27,7 @@ func (mpd *MatchPlayerDelete) Where(ps ...predicate.MatchPlayer) *MatchPlayerDel
// Exec executes the deletion query and returns how many vertices were deleted.
func (mpd *MatchPlayerDelete) Exec(ctx context.Context) (int, error) {
var (
err error
affected int
)
if len(mpd.hooks) == 0 {
affected, err = mpd.sqlExec(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*MatchPlayerMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
mpd.mutation = mutation
affected, err = mpd.sqlExec(ctx)
mutation.done = true
return affected, err
})
for i := len(mpd.hooks) - 1; i >= 0; i-- {
if mpd.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = mpd.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, mpd.mutation); err != nil {
return 0, err
}
}
return affected, err
return withHooks(ctx, mpd.sqlExec, mpd.mutation, mpd.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
@@ -68,15 +40,7 @@ func (mpd *MatchPlayerDelete) ExecX(ctx context.Context) int {
}
func (mpd *MatchPlayerDelete) sqlExec(ctx context.Context) (int, error) {
_spec := &sqlgraph.DeleteSpec{
Node: &sqlgraph.NodeSpec{
Table: matchplayer.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
},
}
_spec := sqlgraph.NewDeleteSpec(matchplayer.Table, sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt))
if ps := mpd.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
@@ -84,7 +48,12 @@ func (mpd *MatchPlayerDelete) sqlExec(ctx context.Context) (int, error) {
}
}
}
return sqlgraph.DeleteNodes(ctx, mpd.driver, _spec)
affected, err := sqlgraph.DeleteNodes(ctx, mpd.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
mpd.mutation.done = true
return affected, err
}
// MatchPlayerDeleteOne is the builder for deleting a single MatchPlayer entity.
@@ -92,6 +61,12 @@ type MatchPlayerDeleteOne struct {
mpd *MatchPlayerDelete
}
// Where appends a list predicates to the MatchPlayerDelete builder.
func (mpdo *MatchPlayerDeleteOne) Where(ps ...predicate.MatchPlayer) *MatchPlayerDeleteOne {
mpdo.mpd.mutation.Where(ps...)
return mpdo
}
// Exec executes the deletion query.
func (mpdo *MatchPlayerDeleteOne) Exec(ctx context.Context) error {
n, err := mpdo.mpd.Exec(ctx)
@@ -107,5 +82,7 @@ func (mpdo *MatchPlayerDeleteOne) Exec(ctx context.Context) error {
// ExecX is like Exec, but panics if an error occurs.
func (mpdo *MatchPlayerDeleteOne) ExecX(ctx context.Context) {
mpdo.mpd.ExecX(ctx)
if err := mpdo.Exec(ctx); err != nil {
panic(err)
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,14 +1,15 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"csgowtfd/ent/matchplayer"
"csgowtfd/ent/messages"
"fmt"
"strings"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"somegit.dev/csgowtf/csgowtfd/ent/matchplayer"
"somegit.dev/csgowtf/csgowtfd/ent/messages"
)
// Messages is the model entity for the Messages schema.
@@ -26,6 +27,7 @@ type Messages struct {
// The values are being populated by the MessagesQuery when eager-loading is set.
Edges MessagesEdges `json:"edges"`
match_player_messages *int
selectValues sql.SelectValues
}
// MessagesEdges holds the relations/edges for other nodes in the graph.
@@ -42,8 +44,7 @@ type MessagesEdges struct {
func (e MessagesEdges) MatchPlayerOrErr() (*MatchPlayer, error) {
if e.loadedTypes[0] {
if e.MatchPlayer == nil {
// The edge match_player was loaded in eager-loading,
// but was not found.
// Edge was loaded but was not found.
return nil, &NotFoundError{label: matchplayer.Label}
}
return e.MatchPlayer, nil
@@ -52,8 +53,8 @@ func (e MessagesEdges) MatchPlayerOrErr() (*MatchPlayer, error) {
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Messages) scanValues(columns []string) ([]interface{}, error) {
values := make([]interface{}, len(columns))
func (*Messages) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case messages.FieldAllChat:
@@ -65,7 +66,7 @@ func (*Messages) scanValues(columns []string) ([]interface{}, error) {
case messages.ForeignKeys[0]: // match_player_messages
values[i] = new(sql.NullInt64)
default:
return nil, fmt.Errorf("unexpected column %q for type Messages", columns[i])
values[i] = new(sql.UnknownType)
}
}
return values, nil
@@ -73,7 +74,7 @@ func (*Messages) scanValues(columns []string) ([]interface{}, error) {
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the Messages fields.
func (m *Messages) assignValues(columns []string, values []interface{}) error {
func (m *Messages) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
@@ -110,31 +111,39 @@ func (m *Messages) assignValues(columns []string, values []interface{}) error {
m.match_player_messages = new(int)
*m.match_player_messages = int(value.Int64)
}
default:
m.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the Messages.
// This includes values selected through modifiers, order, etc.
func (m *Messages) Value(name string) (ent.Value, error) {
return m.selectValues.Get(name)
}
// QueryMatchPlayer queries the "match_player" edge of the Messages entity.
func (m *Messages) QueryMatchPlayer() *MatchPlayerQuery {
return (&MessagesClient{config: m.config}).QueryMatchPlayer(m)
return NewMessagesClient(m.config).QueryMatchPlayer(m)
}
// Update returns a builder for updating this Messages.
// Note that you need to call Messages.Unwrap() before calling this method if this Messages
// was returned from a transaction, and the transaction was committed or rolled back.
func (m *Messages) Update() *MessagesUpdateOne {
return (&MessagesClient{config: m.config}).UpdateOne(m)
return NewMessagesClient(m.config).UpdateOne(m)
}
// Unwrap unwraps the Messages 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 (m *Messages) Unwrap() *Messages {
tx, ok := m.config.driver.(*txDriver)
_tx, ok := m.config.driver.(*txDriver)
if !ok {
panic("ent: Messages is not a transactional entity")
}
m.config.driver = tx.drv
m.config.driver = _tx.drv
return m
}
@@ -142,12 +151,14 @@ func (m *Messages) Unwrap() *Messages {
func (m *Messages) String() string {
var builder strings.Builder
builder.WriteString("Messages(")
builder.WriteString(fmt.Sprintf("id=%v", m.ID))
builder.WriteString(", message=")
builder.WriteString(fmt.Sprintf("id=%v, ", m.ID))
builder.WriteString("message=")
builder.WriteString(m.Message)
builder.WriteString(", all_chat=")
builder.WriteString(", ")
builder.WriteString("all_chat=")
builder.WriteString(fmt.Sprintf("%v", m.AllChat))
builder.WriteString(", tick=")
builder.WriteString(", ")
builder.WriteString("tick=")
builder.WriteString(fmt.Sprintf("%v", m.Tick))
builder.WriteByte(')')
return builder.String()
@@ -155,9 +166,3 @@ func (m *Messages) String() string {
// MessagesSlice is a parsable slice of Messages.
type MessagesSlice []*Messages
func (m MessagesSlice) config(cfg config) {
for _i := range m {
m[_i].config = cfg
}
}

View File

@@ -1,7 +1,12 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package messages
import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
const (
// Label holds the string label denoting the messages type in the database.
Label = "messages"
@@ -54,3 +59,40 @@ func ValidColumn(column string) bool {
}
return false
}
// OrderOption defines the ordering options for the Messages queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByMessage orders the results by the message field.
func ByMessage(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMessage, opts...).ToFunc()
}
// ByAllChat orders the results by the all_chat field.
func ByAllChat(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAllChat, opts...).ToFunc()
}
// ByTick orders the results by the tick field.
func ByTick(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTick, opts...).ToFunc()
}
// ByMatchPlayerField orders the results by match_player field.
func ByMatchPlayerField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newMatchPlayerStep(), sql.OrderByField(field, opts...))
}
}
func newMatchPlayerStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(MatchPlayerInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, MatchPlayerTable, MatchPlayerColumn),
)
}

View File

@@ -1,317 +1,186 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package messages
import (
"csgowtfd/ent/predicate"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"somegit.dev/csgowtf/csgowtfd/ent/predicate"
)
// ID filters vertices based on their ID field.
func ID(id int) predicate.Messages {
return predicate.Messages(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldID), id))
})
return predicate.Messages(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id int) predicate.Messages {
return predicate.Messages(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldID), id))
})
return predicate.Messages(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id int) predicate.Messages {
return predicate.Messages(func(s *sql.Selector) {
s.Where(sql.NEQ(s.C(FieldID), id))
})
return predicate.Messages(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int) predicate.Messages {
return predicate.Messages(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...))
})
return predicate.Messages(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int) predicate.Messages {
return predicate.Messages(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...))
})
return predicate.Messages(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id int) predicate.Messages {
return predicate.Messages(func(s *sql.Selector) {
s.Where(sql.GT(s.C(FieldID), id))
})
return predicate.Messages(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id int) predicate.Messages {
return predicate.Messages(func(s *sql.Selector) {
s.Where(sql.GTE(s.C(FieldID), id))
})
return predicate.Messages(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id int) predicate.Messages {
return predicate.Messages(func(s *sql.Selector) {
s.Where(sql.LT(s.C(FieldID), id))
})
return predicate.Messages(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id int) predicate.Messages {
return predicate.Messages(func(s *sql.Selector) {
s.Where(sql.LTE(s.C(FieldID), id))
})
return predicate.Messages(sql.FieldLTE(FieldID, id))
}
// Message applies equality check predicate on the "message" field. It's identical to MessageEQ.
func Message(v string) predicate.Messages {
return predicate.Messages(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldMessage), v))
})
return predicate.Messages(sql.FieldEQ(FieldMessage, v))
}
// AllChat applies equality check predicate on the "all_chat" field. It's identical to AllChatEQ.
func AllChat(v bool) predicate.Messages {
return predicate.Messages(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldAllChat), v))
})
return predicate.Messages(sql.FieldEQ(FieldAllChat, v))
}
// Tick applies equality check predicate on the "tick" field. It's identical to TickEQ.
func Tick(v int) predicate.Messages {
return predicate.Messages(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldTick), v))
})
return predicate.Messages(sql.FieldEQ(FieldTick, v))
}
// MessageEQ applies the EQ predicate on the "message" field.
func MessageEQ(v string) predicate.Messages {
return predicate.Messages(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldMessage), v))
})
return predicate.Messages(sql.FieldEQ(FieldMessage, v))
}
// MessageNEQ applies the NEQ predicate on the "message" field.
func MessageNEQ(v string) predicate.Messages {
return predicate.Messages(func(s *sql.Selector) {
s.Where(sql.NEQ(s.C(FieldMessage), v))
})
return predicate.Messages(sql.FieldNEQ(FieldMessage, v))
}
// MessageIn applies the In predicate on the "message" field.
func MessageIn(vs ...string) predicate.Messages {
v := make([]interface{}, len(vs))
for i := range v {
v[i] = vs[i]
}
return predicate.Messages(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(FieldMessage), v...))
})
return predicate.Messages(sql.FieldIn(FieldMessage, vs...))
}
// MessageNotIn applies the NotIn predicate on the "message" field.
func MessageNotIn(vs ...string) predicate.Messages {
v := make([]interface{}, len(vs))
for i := range v {
v[i] = vs[i]
}
return predicate.Messages(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(FieldMessage), v...))
})
return predicate.Messages(sql.FieldNotIn(FieldMessage, vs...))
}
// MessageGT applies the GT predicate on the "message" field.
func MessageGT(v string) predicate.Messages {
return predicate.Messages(func(s *sql.Selector) {
s.Where(sql.GT(s.C(FieldMessage), v))
})
return predicate.Messages(sql.FieldGT(FieldMessage, v))
}
// MessageGTE applies the GTE predicate on the "message" field.
func MessageGTE(v string) predicate.Messages {
return predicate.Messages(func(s *sql.Selector) {
s.Where(sql.GTE(s.C(FieldMessage), v))
})
return predicate.Messages(sql.FieldGTE(FieldMessage, v))
}
// MessageLT applies the LT predicate on the "message" field.
func MessageLT(v string) predicate.Messages {
return predicate.Messages(func(s *sql.Selector) {
s.Where(sql.LT(s.C(FieldMessage), v))
})
return predicate.Messages(sql.FieldLT(FieldMessage, v))
}
// MessageLTE applies the LTE predicate on the "message" field.
func MessageLTE(v string) predicate.Messages {
return predicate.Messages(func(s *sql.Selector) {
s.Where(sql.LTE(s.C(FieldMessage), v))
})
return predicate.Messages(sql.FieldLTE(FieldMessage, v))
}
// MessageContains applies the Contains predicate on the "message" field.
func MessageContains(v string) predicate.Messages {
return predicate.Messages(func(s *sql.Selector) {
s.Where(sql.Contains(s.C(FieldMessage), v))
})
return predicate.Messages(sql.FieldContains(FieldMessage, v))
}
// MessageHasPrefix applies the HasPrefix predicate on the "message" field.
func MessageHasPrefix(v string) predicate.Messages {
return predicate.Messages(func(s *sql.Selector) {
s.Where(sql.HasPrefix(s.C(FieldMessage), v))
})
return predicate.Messages(sql.FieldHasPrefix(FieldMessage, v))
}
// MessageHasSuffix applies the HasSuffix predicate on the "message" field.
func MessageHasSuffix(v string) predicate.Messages {
return predicate.Messages(func(s *sql.Selector) {
s.Where(sql.HasSuffix(s.C(FieldMessage), v))
})
return predicate.Messages(sql.FieldHasSuffix(FieldMessage, v))
}
// MessageEqualFold applies the EqualFold predicate on the "message" field.
func MessageEqualFold(v string) predicate.Messages {
return predicate.Messages(func(s *sql.Selector) {
s.Where(sql.EqualFold(s.C(FieldMessage), v))
})
return predicate.Messages(sql.FieldEqualFold(FieldMessage, v))
}
// MessageContainsFold applies the ContainsFold predicate on the "message" field.
func MessageContainsFold(v string) predicate.Messages {
return predicate.Messages(func(s *sql.Selector) {
s.Where(sql.ContainsFold(s.C(FieldMessage), v))
})
return predicate.Messages(sql.FieldContainsFold(FieldMessage, v))
}
// AllChatEQ applies the EQ predicate on the "all_chat" field.
func AllChatEQ(v bool) predicate.Messages {
return predicate.Messages(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldAllChat), v))
})
return predicate.Messages(sql.FieldEQ(FieldAllChat, v))
}
// AllChatNEQ applies the NEQ predicate on the "all_chat" field.
func AllChatNEQ(v bool) predicate.Messages {
return predicate.Messages(func(s *sql.Selector) {
s.Where(sql.NEQ(s.C(FieldAllChat), v))
})
return predicate.Messages(sql.FieldNEQ(FieldAllChat, v))
}
// TickEQ applies the EQ predicate on the "tick" field.
func TickEQ(v int) predicate.Messages {
return predicate.Messages(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldTick), v))
})
return predicate.Messages(sql.FieldEQ(FieldTick, v))
}
// TickNEQ applies the NEQ predicate on the "tick" field.
func TickNEQ(v int) predicate.Messages {
return predicate.Messages(func(s *sql.Selector) {
s.Where(sql.NEQ(s.C(FieldTick), v))
})
return predicate.Messages(sql.FieldNEQ(FieldTick, v))
}
// TickIn applies the In predicate on the "tick" field.
func TickIn(vs ...int) predicate.Messages {
v := make([]interface{}, len(vs))
for i := range v {
v[i] = vs[i]
}
return predicate.Messages(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(FieldTick), v...))
})
return predicate.Messages(sql.FieldIn(FieldTick, vs...))
}
// TickNotIn applies the NotIn predicate on the "tick" field.
func TickNotIn(vs ...int) predicate.Messages {
v := make([]interface{}, len(vs))
for i := range v {
v[i] = vs[i]
}
return predicate.Messages(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(FieldTick), v...))
})
return predicate.Messages(sql.FieldNotIn(FieldTick, vs...))
}
// TickGT applies the GT predicate on the "tick" field.
func TickGT(v int) predicate.Messages {
return predicate.Messages(func(s *sql.Selector) {
s.Where(sql.GT(s.C(FieldTick), v))
})
return predicate.Messages(sql.FieldGT(FieldTick, v))
}
// TickGTE applies the GTE predicate on the "tick" field.
func TickGTE(v int) predicate.Messages {
return predicate.Messages(func(s *sql.Selector) {
s.Where(sql.GTE(s.C(FieldTick), v))
})
return predicate.Messages(sql.FieldGTE(FieldTick, v))
}
// TickLT applies the LT predicate on the "tick" field.
func TickLT(v int) predicate.Messages {
return predicate.Messages(func(s *sql.Selector) {
s.Where(sql.LT(s.C(FieldTick), v))
})
return predicate.Messages(sql.FieldLT(FieldTick, v))
}
// TickLTE applies the LTE predicate on the "tick" field.
func TickLTE(v int) predicate.Messages {
return predicate.Messages(func(s *sql.Selector) {
s.Where(sql.LTE(s.C(FieldTick), v))
})
return predicate.Messages(sql.FieldLTE(FieldTick, v))
}
// HasMatchPlayer applies the HasEdge predicate on the "match_player" edge.
@@ -319,7 +188,6 @@ func HasMatchPlayer() predicate.Messages {
return predicate.Messages(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(MatchPlayerTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, MatchPlayerTable, MatchPlayerColumn),
)
sqlgraph.HasNeighbors(s, step)
@@ -329,11 +197,7 @@ func HasMatchPlayer() predicate.Messages {
// HasMatchPlayerWith applies the HasEdge predicate on the "match_player" edge with a given conditions (other predicates).
func HasMatchPlayerWith(preds ...predicate.MatchPlayer) predicate.Messages {
return predicate.Messages(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(MatchPlayerInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, MatchPlayerTable, MatchPlayerColumn),
)
step := newMatchPlayerStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)

View File

@@ -1,16 +1,16 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"csgowtfd/ent/matchplayer"
"csgowtfd/ent/messages"
"errors"
"fmt"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"somegit.dev/csgowtf/csgowtfd/ent/matchplayer"
"somegit.dev/csgowtf/csgowtfd/ent/messages"
)
// MessagesCreate is the builder for creating a Messages entity.
@@ -64,43 +64,7 @@ func (mc *MessagesCreate) Mutation() *MessagesMutation {
// Save creates the Messages in the database.
func (mc *MessagesCreate) Save(ctx context.Context) (*Messages, error) {
var (
err error
node *Messages
)
if len(mc.hooks) == 0 {
if err = mc.check(); err != nil {
return nil, err
}
node, err = mc.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*MessagesMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = mc.check(); err != nil {
return nil, err
}
mc.mutation = mutation
if node, err = mc.sqlSave(ctx); err != nil {
return nil, err
}
mutation.id = &node.ID
mutation.done = true
return node, err
})
for i := len(mc.hooks) - 1; i >= 0; i-- {
if mc.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = mc.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, mc.mutation); err != nil {
return nil, err
}
}
return node, err
return withHooks(ctx, mc.sqlSave, mc.mutation, mc.hooks)
}
// SaveX calls Save and panics if Save returns an error.
@@ -140,51 +104,38 @@ func (mc *MessagesCreate) check() error {
}
func (mc *MessagesCreate) sqlSave(ctx context.Context) (*Messages, error) {
if err := mc.check(); err != nil {
return nil, err
}
_node, _spec := mc.createSpec()
if err := sqlgraph.CreateNode(ctx, mc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
id := _spec.ID.Value.(int64)
_node.ID = int(id)
mc.mutation.id = &_node.ID
mc.mutation.done = true
return _node, nil
}
func (mc *MessagesCreate) createSpec() (*Messages, *sqlgraph.CreateSpec) {
var (
_node = &Messages{config: mc.config}
_spec = &sqlgraph.CreateSpec{
Table: messages.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: messages.FieldID,
},
}
_spec = sqlgraph.NewCreateSpec(messages.Table, sqlgraph.NewFieldSpec(messages.FieldID, field.TypeInt))
)
if value, ok := mc.mutation.Message(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: messages.FieldMessage,
})
_spec.SetField(messages.FieldMessage, field.TypeString, value)
_node.Message = value
}
if value, ok := mc.mutation.AllChat(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeBool,
Value: value,
Column: messages.FieldAllChat,
})
_spec.SetField(messages.FieldAllChat, field.TypeBool, value)
_node.AllChat = value
}
if value, ok := mc.mutation.Tick(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: messages.FieldTick,
})
_spec.SetField(messages.FieldTick, field.TypeInt, value)
_node.Tick = value
}
if nodes := mc.mutation.MatchPlayerIDs(); len(nodes) > 0 {
@@ -195,10 +146,7 @@ func (mc *MessagesCreate) createSpec() (*Messages, *sqlgraph.CreateSpec) {
Columns: []string{messages.MatchPlayerColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
@@ -233,8 +181,8 @@ func (mcb *MessagesCreateBulk) Save(ctx context.Context) ([]*Messages, error) {
return nil, err
}
builder.mutation = mutation
nodes[i], specs[i] = builder.createSpec()
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, mcb.builders[i+1].mutation)
} else {
@@ -242,7 +190,7 @@ func (mcb *MessagesCreateBulk) Save(ctx context.Context) ([]*Messages, error) {
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, mcb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
@@ -250,11 +198,11 @@ func (mcb *MessagesCreateBulk) Save(ctx context.Context) ([]*Messages, error) {
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)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -1,16 +1,15 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"csgowtfd/ent/messages"
"csgowtfd/ent/predicate"
"fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"somegit.dev/csgowtf/csgowtfd/ent/messages"
"somegit.dev/csgowtf/csgowtfd/ent/predicate"
)
// MessagesDelete is the builder for deleting a Messages entity.
@@ -28,34 +27,7 @@ func (md *MessagesDelete) Where(ps ...predicate.Messages) *MessagesDelete {
// Exec executes the deletion query and returns how many vertices were deleted.
func (md *MessagesDelete) Exec(ctx context.Context) (int, error) {
var (
err error
affected int
)
if len(md.hooks) == 0 {
affected, err = md.sqlExec(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*MessagesMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
md.mutation = mutation
affected, err = md.sqlExec(ctx)
mutation.done = true
return affected, err
})
for i := len(md.hooks) - 1; i >= 0; i-- {
if md.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = md.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, md.mutation); err != nil {
return 0, err
}
}
return affected, err
return withHooks(ctx, md.sqlExec, md.mutation, md.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
@@ -68,15 +40,7 @@ func (md *MessagesDelete) ExecX(ctx context.Context) int {
}
func (md *MessagesDelete) sqlExec(ctx context.Context) (int, error) {
_spec := &sqlgraph.DeleteSpec{
Node: &sqlgraph.NodeSpec{
Table: messages.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: messages.FieldID,
},
},
}
_spec := sqlgraph.NewDeleteSpec(messages.Table, sqlgraph.NewFieldSpec(messages.FieldID, field.TypeInt))
if ps := md.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
@@ -84,7 +48,12 @@ func (md *MessagesDelete) sqlExec(ctx context.Context) (int, error) {
}
}
}
return sqlgraph.DeleteNodes(ctx, md.driver, _spec)
affected, err := sqlgraph.DeleteNodes(ctx, md.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
md.mutation.done = true
return affected, err
}
// MessagesDeleteOne is the builder for deleting a single Messages entity.
@@ -92,6 +61,12 @@ type MessagesDeleteOne struct {
md *MessagesDelete
}
// Where appends a list predicates to the MessagesDelete builder.
func (mdo *MessagesDeleteOne) Where(ps ...predicate.Messages) *MessagesDeleteOne {
mdo.md.mutation.Where(ps...)
return mdo
}
// Exec executes the deletion query.
func (mdo *MessagesDeleteOne) Exec(ctx context.Context) error {
n, err := mdo.md.Exec(ctx)
@@ -107,5 +82,7 @@ func (mdo *MessagesDeleteOne) Exec(ctx context.Context) error {
// ExecX is like Exec, but panics if an error occurs.
func (mdo *MessagesDeleteOne) ExecX(ctx context.Context) {
mdo.md.ExecX(ctx)
if err := mdo.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -1,34 +1,30 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"csgowtfd/ent/matchplayer"
"csgowtfd/ent/messages"
"csgowtfd/ent/predicate"
"errors"
"fmt"
"math"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"somegit.dev/csgowtf/csgowtfd/ent/matchplayer"
"somegit.dev/csgowtf/csgowtfd/ent/messages"
"somegit.dev/csgowtf/csgowtfd/ent/predicate"
)
// MessagesQuery is the builder for querying Messages entities.
type MessagesQuery struct {
config
limit *int
offset *int
unique *bool
order []OrderFunc
fields []string
ctx *QueryContext
order []messages.OrderOption
inters []Interceptor
predicates []predicate.Messages
// eager-loading edges.
withMatchPlayer *MatchPlayerQuery
withFKs bool
modifiers []func(s *sql.Selector)
modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -40,34 +36,34 @@ func (mq *MessagesQuery) Where(ps ...predicate.Messages) *MessagesQuery {
return mq
}
// Limit adds a limit step to the query.
// Limit the number of records to be returned by this query.
func (mq *MessagesQuery) Limit(limit int) *MessagesQuery {
mq.limit = &limit
mq.ctx.Limit = &limit
return mq
}
// Offset adds an offset step to the query.
// Offset to start from.
func (mq *MessagesQuery) Offset(offset int) *MessagesQuery {
mq.offset = &offset
mq.ctx.Offset = &offset
return mq
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (mq *MessagesQuery) Unique(unique bool) *MessagesQuery {
mq.unique = &unique
mq.ctx.Unique = &unique
return mq
}
// Order adds an order step to the query.
func (mq *MessagesQuery) Order(o ...OrderFunc) *MessagesQuery {
// Order specifies how the records should be ordered.
func (mq *MessagesQuery) Order(o ...messages.OrderOption) *MessagesQuery {
mq.order = append(mq.order, o...)
return mq
}
// QueryMatchPlayer chains the current query on the "match_player" edge.
func (mq *MessagesQuery) QueryMatchPlayer() *MatchPlayerQuery {
query := &MatchPlayerQuery{config: mq.config}
query := (&MatchPlayerClient{config: mq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := mq.prepareQuery(ctx); err != nil {
return nil, err
@@ -90,7 +86,7 @@ func (mq *MessagesQuery) QueryMatchPlayer() *MatchPlayerQuery {
// First returns the first Messages entity from the query.
// Returns a *NotFoundError when no Messages was found.
func (mq *MessagesQuery) First(ctx context.Context) (*Messages, error) {
nodes, err := mq.Limit(1).All(ctx)
nodes, err := mq.Limit(1).All(setContextOp(ctx, mq.ctx, "First"))
if err != nil {
return nil, err
}
@@ -113,7 +109,7 @@ func (mq *MessagesQuery) FirstX(ctx context.Context) *Messages {
// Returns a *NotFoundError when no Messages ID was found.
func (mq *MessagesQuery) FirstID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = mq.Limit(1).IDs(ctx); err != nil {
if ids, err = mq.Limit(1).IDs(setContextOp(ctx, mq.ctx, "FirstID")); err != nil {
return
}
if len(ids) == 0 {
@@ -133,10 +129,10 @@ func (mq *MessagesQuery) FirstIDX(ctx context.Context) int {
}
// Only returns a single Messages entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when exactly one Messages entity is not found.
// Returns a *NotSingularError when more than one Messages entity is found.
// Returns a *NotFoundError when no Messages entities are found.
func (mq *MessagesQuery) Only(ctx context.Context) (*Messages, error) {
nodes, err := mq.Limit(2).All(ctx)
nodes, err := mq.Limit(2).All(setContextOp(ctx, mq.ctx, "Only"))
if err != nil {
return nil, err
}
@@ -160,11 +156,11 @@ func (mq *MessagesQuery) OnlyX(ctx context.Context) *Messages {
}
// OnlyID is like Only, but returns the only Messages ID in the query.
// Returns a *NotSingularError when exactly one Messages ID is not found.
// Returns a *NotSingularError when more than one Messages ID is found.
// Returns a *NotFoundError when no entities are found.
func (mq *MessagesQuery) OnlyID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = mq.Limit(2).IDs(ctx); err != nil {
if ids, err = mq.Limit(2).IDs(setContextOp(ctx, mq.ctx, "OnlyID")); err != nil {
return
}
switch len(ids) {
@@ -189,10 +185,12 @@ func (mq *MessagesQuery) OnlyIDX(ctx context.Context) int {
// All executes the query and returns a list of MessagesSlice.
func (mq *MessagesQuery) All(ctx context.Context) ([]*Messages, error) {
ctx = setContextOp(ctx, mq.ctx, "All")
if err := mq.prepareQuery(ctx); err != nil {
return nil, err
}
return mq.sqlAll(ctx)
qr := querierAll[[]*Messages, *MessagesQuery]()
return withInterceptors[[]*Messages](ctx, mq, qr, mq.inters)
}
// AllX is like All, but panics if an error occurs.
@@ -205,9 +203,12 @@ func (mq *MessagesQuery) AllX(ctx context.Context) []*Messages {
}
// IDs executes the query and returns a list of Messages IDs.
func (mq *MessagesQuery) IDs(ctx context.Context) ([]int, error) {
var ids []int
if err := mq.Select(messages.FieldID).Scan(ctx, &ids); err != nil {
func (mq *MessagesQuery) IDs(ctx context.Context) (ids []int, err error) {
if mq.ctx.Unique == nil && mq.path != nil {
mq.Unique(true)
}
ctx = setContextOp(ctx, mq.ctx, "IDs")
if err = mq.Select(messages.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
@@ -224,10 +225,11 @@ func (mq *MessagesQuery) IDsX(ctx context.Context) []int {
// Count returns the count of the given query.
func (mq *MessagesQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, mq.ctx, "Count")
if err := mq.prepareQuery(ctx); err != nil {
return 0, err
}
return mq.sqlCount(ctx)
return withInterceptors[int](ctx, mq, querierCount[*MessagesQuery](), mq.inters)
}
// CountX is like Count, but panics if an error occurs.
@@ -241,10 +243,15 @@ func (mq *MessagesQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph.
func (mq *MessagesQuery) Exist(ctx context.Context) (bool, error) {
if err := mq.prepareQuery(ctx); err != nil {
return false, err
ctx = setContextOp(ctx, mq.ctx, "Exist")
switch _, err := mq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
return mq.sqlExist(ctx)
}
// ExistX is like Exist, but panics if an error occurs.
@@ -264,9 +271,9 @@ func (mq *MessagesQuery) Clone() *MessagesQuery {
}
return &MessagesQuery{
config: mq.config,
limit: mq.limit,
offset: mq.offset,
order: append([]OrderFunc{}, mq.order...),
ctx: mq.ctx.Clone(),
order: append([]messages.OrderOption{}, mq.order...),
inters: append([]Interceptor{}, mq.inters...),
predicates: append([]predicate.Messages{}, mq.predicates...),
withMatchPlayer: mq.withMatchPlayer.Clone(),
// clone intermediate query.
@@ -278,7 +285,7 @@ func (mq *MessagesQuery) Clone() *MessagesQuery {
// WithMatchPlayer tells the query-builder to eager-load the nodes that are connected to
// the "match_player" edge. The optional arguments are used to configure the query builder of the edge.
func (mq *MessagesQuery) WithMatchPlayer(opts ...func(*MatchPlayerQuery)) *MessagesQuery {
query := &MatchPlayerQuery{config: mq.config}
query := (&MatchPlayerClient{config: mq.config}).Query()
for _, opt := range opts {
opt(query)
}
@@ -300,17 +307,13 @@ func (mq *MessagesQuery) WithMatchPlayer(opts ...func(*MatchPlayerQuery)) *Messa
// GroupBy(messages.FieldMessage).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
//
func (mq *MessagesQuery) GroupBy(field string, fields ...string) *MessagesGroupBy {
group := &MessagesGroupBy{config: mq.config}
group.fields = append([]string{field}, fields...)
group.path = func(ctx context.Context) (prev *sql.Selector, err error) {
if err := mq.prepareQuery(ctx); err != nil {
return nil, err
}
return mq.sqlQuery(ctx), nil
}
return group
mq.ctx.Fields = append([]string{field}, fields...)
grbuild := &MessagesGroupBy{build: mq}
grbuild.flds = &mq.ctx.Fields
grbuild.label = messages.Label
grbuild.scan = grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
@@ -325,14 +328,31 @@ func (mq *MessagesQuery) GroupBy(field string, fields ...string) *MessagesGroupB
// client.Messages.Query().
// Select(messages.FieldMessage).
// Scan(ctx, &v)
//
func (mq *MessagesQuery) Select(fields ...string) *MessagesSelect {
mq.fields = append(mq.fields, fields...)
return &MessagesSelect{MessagesQuery: mq}
mq.ctx.Fields = append(mq.ctx.Fields, fields...)
sbuild := &MessagesSelect{MessagesQuery: mq}
sbuild.label = messages.Label
sbuild.flds, sbuild.scan = &mq.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a MessagesSelect configured with the given aggregations.
func (mq *MessagesQuery) Aggregate(fns ...AggregateFunc) *MessagesSelect {
return mq.Select().Aggregate(fns...)
}
func (mq *MessagesQuery) prepareQuery(ctx context.Context) error {
for _, f := range mq.fields {
for _, inter := range mq.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, mq); err != nil {
return err
}
}
}
for _, f := range mq.ctx.Fields {
if !messages.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
@@ -347,7 +367,7 @@ func (mq *MessagesQuery) prepareQuery(ctx context.Context) error {
return nil
}
func (mq *MessagesQuery) sqlAll(ctx context.Context) ([]*Messages, error) {
func (mq *MessagesQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Messages, error) {
var (
nodes = []*Messages{}
withFKs = mq.withFKs
@@ -362,30 +382,37 @@ func (mq *MessagesQuery) sqlAll(ctx context.Context) ([]*Messages, error) {
if withFKs {
_spec.Node.Columns = append(_spec.Node.Columns, messages.ForeignKeys...)
}
_spec.ScanValues = func(columns []string) ([]interface{}, error) {
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*Messages).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []any) error {
node := &Messages{config: mq.config}
nodes = append(nodes, node)
return node.scanValues(columns)
}
_spec.Assign = func(columns []string, values []interface{}) error {
if len(nodes) == 0 {
return fmt.Errorf("ent: Assign called without calling ScanValues")
}
node := nodes[len(nodes)-1]
node.Edges.loadedTypes = loadedTypes
return node.assignValues(columns, values)
}
if len(mq.modifiers) > 0 {
_spec.Modifiers = mq.modifiers
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, mq.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
if query := mq.withMatchPlayer; query != nil {
if err := mq.loadMatchPlayer(ctx, query, nodes, nil,
func(n *Messages, e *MatchPlayer) { n.Edges.MatchPlayer = e }); err != nil {
return nil, err
}
}
return nodes, nil
}
func (mq *MessagesQuery) loadMatchPlayer(ctx context.Context, query *MatchPlayerQuery, nodes []*Messages, init func(*Messages), assign func(*Messages, *MatchPlayer)) error {
ids := make([]int, 0, len(nodes))
nodeids := make(map[int][]*Messages)
for i := range nodes {
@@ -398,23 +425,24 @@ func (mq *MessagesQuery) sqlAll(ctx context.Context) ([]*Messages, error) {
}
nodeids[fk] = append(nodeids[fk], nodes[i])
}
if len(ids) == 0 {
return nil
}
query.Where(matchplayer.IDIn(ids...))
neighbors, err := query.All(ctx)
if err != nil {
return nil, err
return err
}
for _, n := range neighbors {
nodes, ok := nodeids[n.ID]
if !ok {
return nil, fmt.Errorf(`unexpected foreign-key "match_player_messages" returned %v`, n.ID)
return fmt.Errorf(`unexpected foreign-key "match_player_messages" returned %v`, n.ID)
}
for i := range nodes {
nodes[i].Edges.MatchPlayer = n
assign(nodes[i], n)
}
}
}
return nodes, nil
return nil
}
func (mq *MessagesQuery) sqlCount(ctx context.Context) (int, error) {
@@ -422,38 +450,22 @@ func (mq *MessagesQuery) sqlCount(ctx context.Context) (int, error) {
if len(mq.modifiers) > 0 {
_spec.Modifiers = mq.modifiers
}
_spec.Node.Columns = mq.fields
if len(mq.fields) > 0 {
_spec.Unique = mq.unique != nil && *mq.unique
_spec.Node.Columns = mq.ctx.Fields
if len(mq.ctx.Fields) > 0 {
_spec.Unique = mq.ctx.Unique != nil && *mq.ctx.Unique
}
return sqlgraph.CountNodes(ctx, mq.driver, _spec)
}
func (mq *MessagesQuery) sqlExist(ctx context.Context) (bool, error) {
n, err := mq.sqlCount(ctx)
if err != nil {
return false, fmt.Errorf("ent: check existence: %w", err)
}
return n > 0, nil
}
func (mq *MessagesQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{
Node: &sqlgraph.NodeSpec{
Table: messages.Table,
Columns: messages.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: messages.FieldID,
},
},
From: mq.sql,
Unique: true,
}
if unique := mq.unique; unique != nil {
_spec := sqlgraph.NewQuerySpec(messages.Table, messages.Columns, sqlgraph.NewFieldSpec(messages.FieldID, field.TypeInt))
_spec.From = mq.sql
if unique := mq.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if mq.path != nil {
_spec.Unique = true
}
if fields := mq.fields; len(fields) > 0 {
if fields := mq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, messages.FieldID)
for i := range fields {
@@ -469,10 +481,10 @@ func (mq *MessagesQuery) querySpec() *sqlgraph.QuerySpec {
}
}
}
if limit := mq.limit; limit != nil {
if limit := mq.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := mq.offset; offset != nil {
if offset := mq.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := mq.order; len(ps) > 0 {
@@ -488,7 +500,7 @@ func (mq *MessagesQuery) querySpec() *sqlgraph.QuerySpec {
func (mq *MessagesQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(mq.driver.Dialect())
t1 := builder.Table(messages.Table)
columns := mq.fields
columns := mq.ctx.Fields
if len(columns) == 0 {
columns = messages.Columns
}
@@ -497,7 +509,7 @@ func (mq *MessagesQuery) sqlQuery(ctx context.Context) *sql.Selector {
selector = mq.sql
selector.Select(selector.Columns(columns...)...)
}
if mq.unique != nil && *mq.unique {
if mq.ctx.Unique != nil && *mq.ctx.Unique {
selector.Distinct()
}
for _, m := range mq.modifiers {
@@ -509,12 +521,12 @@ func (mq *MessagesQuery) sqlQuery(ctx context.Context) *sql.Selector {
for _, p := range mq.order {
p(selector)
}
if offset := mq.offset; offset != nil {
if offset := mq.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := mq.limit; limit != nil {
if limit := mq.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
@@ -528,12 +540,8 @@ func (mq *MessagesQuery) Modify(modifiers ...func(s *sql.Selector)) *MessagesSel
// MessagesGroupBy is the group-by builder for Messages entities.
type MessagesGroupBy struct {
config
fields []string
fns []AggregateFunc
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
selector
build *MessagesQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
@@ -542,471 +550,77 @@ func (mgb *MessagesGroupBy) Aggregate(fns ...AggregateFunc) *MessagesGroupBy {
return mgb
}
// Scan applies the group-by query and scans the result into the given value.
func (mgb *MessagesGroupBy) Scan(ctx context.Context, v interface{}) error {
query, err := mgb.path(ctx)
if err != nil {
// Scan applies the selector query and scans the result into the given value.
func (mgb *MessagesGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, mgb.build.ctx, "GroupBy")
if err := mgb.build.prepareQuery(ctx); err != nil {
return err
}
mgb.sql = query
return mgb.sqlScan(ctx, v)
return scanWithInterceptors[*MessagesQuery, *MessagesGroupBy](ctx, mgb.build, mgb, mgb.build.inters, v)
}
// ScanX is like Scan, but panics if an error occurs.
func (mgb *MessagesGroupBy) ScanX(ctx context.Context, v interface{}) {
if err := mgb.Scan(ctx, v); err != nil {
panic(err)
func (mgb *MessagesGroupBy) sqlScan(ctx context.Context, root *MessagesQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(mgb.fns))
for _, fn := range mgb.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*mgb.flds)+len(mgb.fns))
for _, f := range *mgb.flds {
columns = append(columns, selector.C(f))
}
// Strings returns list of strings from group-by.
// It is only allowed when executing a group-by query with one field.
func (mgb *MessagesGroupBy) Strings(ctx context.Context) ([]string, error) {
if len(mgb.fields) > 1 {
return nil, errors.New("ent: MessagesGroupBy.Strings is not achievable when grouping more than 1 field")
columns = append(columns, aggregation...)
selector.Select(columns...)
}
var v []string
if err := mgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// StringsX is like Strings, but panics if an error occurs.
func (mgb *MessagesGroupBy) StringsX(ctx context.Context) []string {
v, err := mgb.Strings(ctx)
if err != nil {
panic(err)
}
return v
}
// String returns a single string from a group-by query.
// It is only allowed when executing a group-by query with one field.
func (mgb *MessagesGroupBy) String(ctx context.Context) (_ string, err error) {
var v []string
if v, err = mgb.Strings(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{messages.Label}
default:
err = fmt.Errorf("ent: MessagesGroupBy.Strings returned %d results when one was expected", len(v))
}
return
}
// StringX is like String, but panics if an error occurs.
func (mgb *MessagesGroupBy) StringX(ctx context.Context) string {
v, err := mgb.String(ctx)
if err != nil {
panic(err)
}
return v
}
// Ints returns list of ints from group-by.
// It is only allowed when executing a group-by query with one field.
func (mgb *MessagesGroupBy) Ints(ctx context.Context) ([]int, error) {
if len(mgb.fields) > 1 {
return nil, errors.New("ent: MessagesGroupBy.Ints is not achievable when grouping more than 1 field")
}
var v []int
if err := mgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// IntsX is like Ints, but panics if an error occurs.
func (mgb *MessagesGroupBy) IntsX(ctx context.Context) []int {
v, err := mgb.Ints(ctx)
if err != nil {
panic(err)
}
return v
}
// Int returns a single int from a group-by query.
// It is only allowed when executing a group-by query with one field.
func (mgb *MessagesGroupBy) Int(ctx context.Context) (_ int, err error) {
var v []int
if v, err = mgb.Ints(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{messages.Label}
default:
err = fmt.Errorf("ent: MessagesGroupBy.Ints returned %d results when one was expected", len(v))
}
return
}
// IntX is like Int, but panics if an error occurs.
func (mgb *MessagesGroupBy) IntX(ctx context.Context) int {
v, err := mgb.Int(ctx)
if err != nil {
panic(err)
}
return v
}
// Float64s returns list of float64s from group-by.
// It is only allowed when executing a group-by query with one field.
func (mgb *MessagesGroupBy) Float64s(ctx context.Context) ([]float64, error) {
if len(mgb.fields) > 1 {
return nil, errors.New("ent: MessagesGroupBy.Float64s is not achievable when grouping more than 1 field")
}
var v []float64
if err := mgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// Float64sX is like Float64s, but panics if an error occurs.
func (mgb *MessagesGroupBy) Float64sX(ctx context.Context) []float64 {
v, err := mgb.Float64s(ctx)
if err != nil {
panic(err)
}
return v
}
// Float64 returns a single float64 from a group-by query.
// It is only allowed when executing a group-by query with one field.
func (mgb *MessagesGroupBy) Float64(ctx context.Context) (_ float64, err error) {
var v []float64
if v, err = mgb.Float64s(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{messages.Label}
default:
err = fmt.Errorf("ent: MessagesGroupBy.Float64s returned %d results when one was expected", len(v))
}
return
}
// Float64X is like Float64, but panics if an error occurs.
func (mgb *MessagesGroupBy) Float64X(ctx context.Context) float64 {
v, err := mgb.Float64(ctx)
if err != nil {
panic(err)
}
return v
}
// Bools returns list of bools from group-by.
// It is only allowed when executing a group-by query with one field.
func (mgb *MessagesGroupBy) Bools(ctx context.Context) ([]bool, error) {
if len(mgb.fields) > 1 {
return nil, errors.New("ent: MessagesGroupBy.Bools is not achievable when grouping more than 1 field")
}
var v []bool
if err := mgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// BoolsX is like Bools, but panics if an error occurs.
func (mgb *MessagesGroupBy) BoolsX(ctx context.Context) []bool {
v, err := mgb.Bools(ctx)
if err != nil {
panic(err)
}
return v
}
// Bool returns a single bool from a group-by query.
// It is only allowed when executing a group-by query with one field.
func (mgb *MessagesGroupBy) Bool(ctx context.Context) (_ bool, err error) {
var v []bool
if v, err = mgb.Bools(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{messages.Label}
default:
err = fmt.Errorf("ent: MessagesGroupBy.Bools returned %d results when one was expected", len(v))
}
return
}
// BoolX is like Bool, but panics if an error occurs.
func (mgb *MessagesGroupBy) BoolX(ctx context.Context) bool {
v, err := mgb.Bool(ctx)
if err != nil {
panic(err)
}
return v
}
func (mgb *MessagesGroupBy) sqlScan(ctx context.Context, v interface{}) error {
for _, f := range mgb.fields {
if !messages.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)}
}
}
selector := mgb.sqlQuery()
selector.GroupBy(selector.Columns(*mgb.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := mgb.driver.Query(ctx, query, args, rows); err != nil {
if err := mgb.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
func (mgb *MessagesGroupBy) sqlQuery() *sql.Selector {
selector := mgb.sql.Select()
aggregation := make([]string, 0, len(mgb.fns))
for _, fn := range mgb.fns {
aggregation = append(aggregation, fn(selector))
}
// If no columns were selected in a custom aggregation function, the default
// selection is the fields used for "group-by", and the aggregation functions.
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(mgb.fields)+len(mgb.fns))
for _, f := range mgb.fields {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
return selector.GroupBy(selector.Columns(mgb.fields...)...)
}
// MessagesSelect is the builder for selecting fields of Messages entities.
type MessagesSelect struct {
*MessagesQuery
// intermediate query (i.e. traversal path).
sql *sql.Selector
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (ms *MessagesSelect) Aggregate(fns ...AggregateFunc) *MessagesSelect {
ms.fns = append(ms.fns, fns...)
return ms
}
// Scan applies the selector query and scans the result into the given value.
func (ms *MessagesSelect) Scan(ctx context.Context, v interface{}) error {
func (ms *MessagesSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, ms.ctx, "Select")
if err := ms.prepareQuery(ctx); err != nil {
return err
}
ms.sql = ms.MessagesQuery.sqlQuery(ctx)
return ms.sqlScan(ctx, v)
return scanWithInterceptors[*MessagesQuery, *MessagesSelect](ctx, ms.MessagesQuery, ms, ms.inters, v)
}
// ScanX is like Scan, but panics if an error occurs.
func (ms *MessagesSelect) ScanX(ctx context.Context, v interface{}) {
if err := ms.Scan(ctx, v); err != nil {
panic(err)
func (ms *MessagesSelect) sqlScan(ctx context.Context, root *MessagesQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(ms.fns))
for _, fn := range ms.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*ms.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
// Strings returns list of strings from a selector. It is only allowed when selecting one field.
func (ms *MessagesSelect) Strings(ctx context.Context) ([]string, error) {
if len(ms.fields) > 1 {
return nil, errors.New("ent: MessagesSelect.Strings is not achievable when selecting more than 1 field")
}
var v []string
if err := ms.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// StringsX is like Strings, but panics if an error occurs.
func (ms *MessagesSelect) StringsX(ctx context.Context) []string {
v, err := ms.Strings(ctx)
if err != nil {
panic(err)
}
return v
}
// String returns a single string from a selector. It is only allowed when selecting one field.
func (ms *MessagesSelect) String(ctx context.Context) (_ string, err error) {
var v []string
if v, err = ms.Strings(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{messages.Label}
default:
err = fmt.Errorf("ent: MessagesSelect.Strings returned %d results when one was expected", len(v))
}
return
}
// StringX is like String, but panics if an error occurs.
func (ms *MessagesSelect) StringX(ctx context.Context) string {
v, err := ms.String(ctx)
if err != nil {
panic(err)
}
return v
}
// Ints returns list of ints from a selector. It is only allowed when selecting one field.
func (ms *MessagesSelect) Ints(ctx context.Context) ([]int, error) {
if len(ms.fields) > 1 {
return nil, errors.New("ent: MessagesSelect.Ints is not achievable when selecting more than 1 field")
}
var v []int
if err := ms.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// IntsX is like Ints, but panics if an error occurs.
func (ms *MessagesSelect) IntsX(ctx context.Context) []int {
v, err := ms.Ints(ctx)
if err != nil {
panic(err)
}
return v
}
// Int returns a single int from a selector. It is only allowed when selecting one field.
func (ms *MessagesSelect) Int(ctx context.Context) (_ int, err error) {
var v []int
if v, err = ms.Ints(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{messages.Label}
default:
err = fmt.Errorf("ent: MessagesSelect.Ints returned %d results when one was expected", len(v))
}
return
}
// IntX is like Int, but panics if an error occurs.
func (ms *MessagesSelect) IntX(ctx context.Context) int {
v, err := ms.Int(ctx)
if err != nil {
panic(err)
}
return v
}
// Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
func (ms *MessagesSelect) Float64s(ctx context.Context) ([]float64, error) {
if len(ms.fields) > 1 {
return nil, errors.New("ent: MessagesSelect.Float64s is not achievable when selecting more than 1 field")
}
var v []float64
if err := ms.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// Float64sX is like Float64s, but panics if an error occurs.
func (ms *MessagesSelect) Float64sX(ctx context.Context) []float64 {
v, err := ms.Float64s(ctx)
if err != nil {
panic(err)
}
return v
}
// Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
func (ms *MessagesSelect) Float64(ctx context.Context) (_ float64, err error) {
var v []float64
if v, err = ms.Float64s(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{messages.Label}
default:
err = fmt.Errorf("ent: MessagesSelect.Float64s returned %d results when one was expected", len(v))
}
return
}
// Float64X is like Float64, but panics if an error occurs.
func (ms *MessagesSelect) Float64X(ctx context.Context) float64 {
v, err := ms.Float64(ctx)
if err != nil {
panic(err)
}
return v
}
// Bools returns list of bools from a selector. It is only allowed when selecting one field.
func (ms *MessagesSelect) Bools(ctx context.Context) ([]bool, error) {
if len(ms.fields) > 1 {
return nil, errors.New("ent: MessagesSelect.Bools is not achievable when selecting more than 1 field")
}
var v []bool
if err := ms.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// BoolsX is like Bools, but panics if an error occurs.
func (ms *MessagesSelect) BoolsX(ctx context.Context) []bool {
v, err := ms.Bools(ctx)
if err != nil {
panic(err)
}
return v
}
// Bool returns a single bool from a selector. It is only allowed when selecting one field.
func (ms *MessagesSelect) Bool(ctx context.Context) (_ bool, err error) {
var v []bool
if v, err = ms.Bools(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{messages.Label}
default:
err = fmt.Errorf("ent: MessagesSelect.Bools returned %d results when one was expected", len(v))
}
return
}
// BoolX is like Bool, but panics if an error occurs.
func (ms *MessagesSelect) BoolX(ctx context.Context) bool {
v, err := ms.Bool(ctx)
if err != nil {
panic(err)
}
return v
}
func (ms *MessagesSelect) sqlScan(ctx context.Context, v interface{}) error {
rows := &sql.Rows{}
query, args := ms.sql.Query()
query, args := selector.Query()
if err := ms.driver.Query(ctx, query, args, rows); err != nil {
return err
}

View File

@@ -1,18 +1,18 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"csgowtfd/ent/matchplayer"
"csgowtfd/ent/messages"
"csgowtfd/ent/predicate"
"errors"
"fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"somegit.dev/csgowtf/csgowtfd/ent/matchplayer"
"somegit.dev/csgowtf/csgowtfd/ent/messages"
"somegit.dev/csgowtf/csgowtfd/ent/predicate"
)
// MessagesUpdate is the builder for updating Messages entities.
@@ -20,6 +20,7 @@ type MessagesUpdate struct {
config
hooks []Hook
mutation *MessagesMutation
modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the MessagesUpdate builder.
@@ -85,34 +86,7 @@ func (mu *MessagesUpdate) ClearMatchPlayer() *MessagesUpdate {
// Save executes the query and returns the number of nodes affected by the update operation.
func (mu *MessagesUpdate) Save(ctx context.Context) (int, error) {
var (
err error
affected int
)
if len(mu.hooks) == 0 {
affected, err = mu.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*MessagesMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
mu.mutation = mutation
affected, err = mu.sqlSave(ctx)
mutation.done = true
return affected, err
})
for i := len(mu.hooks) - 1; i >= 0; i-- {
if mu.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = mu.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, mu.mutation); err != nil {
return 0, err
}
}
return affected, err
return withHooks(ctx, mu.sqlSave, mu.mutation, mu.hooks)
}
// SaveX is like Save, but panics if an error occurs.
@@ -137,17 +111,14 @@ func (mu *MessagesUpdate) ExecX(ctx context.Context) {
}
}
func (mu *MessagesUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: messages.Table,
Columns: messages.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: messages.FieldID,
},
},
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (mu *MessagesUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *MessagesUpdate {
mu.modifiers = append(mu.modifiers, modifiers...)
return mu
}
func (mu *MessagesUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := sqlgraph.NewUpdateSpec(messages.Table, messages.Columns, sqlgraph.NewFieldSpec(messages.FieldID, field.TypeInt))
if ps := mu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
@@ -156,32 +127,16 @@ func (mu *MessagesUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
}
if value, ok := mu.mutation.Message(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: messages.FieldMessage,
})
_spec.SetField(messages.FieldMessage, field.TypeString, value)
}
if value, ok := mu.mutation.AllChat(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeBool,
Value: value,
Column: messages.FieldAllChat,
})
_spec.SetField(messages.FieldAllChat, field.TypeBool, value)
}
if value, ok := mu.mutation.Tick(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: messages.FieldTick,
})
_spec.SetField(messages.FieldTick, field.TypeInt, value)
}
if value, ok := mu.mutation.AddedTick(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: messages.FieldTick,
})
_spec.AddField(messages.FieldTick, field.TypeInt, value)
}
if mu.mutation.MatchPlayerCleared() {
edge := &sqlgraph.EdgeSpec{
@@ -191,10 +146,7 @@ func (mu *MessagesUpdate) sqlSave(ctx context.Context) (n int, err error) {
Columns: []string{messages.MatchPlayerColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
@@ -207,10 +159,7 @@ func (mu *MessagesUpdate) sqlSave(ctx context.Context) (n int, err error) {
Columns: []string{messages.MatchPlayerColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
@@ -218,14 +167,16 @@ func (mu *MessagesUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_spec.AddModifiers(mu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, mu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{messages.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
mu.mutation.done = true
return n, nil
}
@@ -235,6 +186,7 @@ type MessagesUpdateOne struct {
fields []string
hooks []Hook
mutation *MessagesMutation
modifiers []func(*sql.UpdateBuilder)
}
// SetMessage sets the "message" field.
@@ -292,6 +244,12 @@ func (muo *MessagesUpdateOne) ClearMatchPlayer() *MessagesUpdateOne {
return muo
}
// Where appends a list predicates to the MessagesUpdate builder.
func (muo *MessagesUpdateOne) Where(ps ...predicate.Messages) *MessagesUpdateOne {
muo.mutation.Where(ps...)
return muo
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (muo *MessagesUpdateOne) Select(field string, fields ...string) *MessagesUpdateOne {
@@ -301,34 +259,7 @@ func (muo *MessagesUpdateOne) Select(field string, fields ...string) *MessagesUp
// Save executes the query and returns the updated Messages entity.
func (muo *MessagesUpdateOne) Save(ctx context.Context) (*Messages, error) {
var (
err error
node *Messages
)
if len(muo.hooks) == 0 {
node, err = muo.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*MessagesMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
muo.mutation = mutation
node, err = muo.sqlSave(ctx)
mutation.done = true
return node, err
})
for i := len(muo.hooks) - 1; i >= 0; i-- {
if muo.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = muo.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, muo.mutation); err != nil {
return nil, err
}
}
return node, err
return withHooks(ctx, muo.sqlSave, muo.mutation, muo.hooks)
}
// SaveX is like Save, but panics if an error occurs.
@@ -353,17 +284,14 @@ func (muo *MessagesUpdateOne) ExecX(ctx context.Context) {
}
}
func (muo *MessagesUpdateOne) sqlSave(ctx context.Context) (_node *Messages, err error) {
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: messages.Table,
Columns: messages.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: messages.FieldID,
},
},
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (muo *MessagesUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *MessagesUpdateOne {
muo.modifiers = append(muo.modifiers, modifiers...)
return muo
}
func (muo *MessagesUpdateOne) sqlSave(ctx context.Context) (_node *Messages, err error) {
_spec := sqlgraph.NewUpdateSpec(messages.Table, messages.Columns, sqlgraph.NewFieldSpec(messages.FieldID, field.TypeInt))
id, ok := muo.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Messages.id" for update`)}
@@ -389,32 +317,16 @@ func (muo *MessagesUpdateOne) sqlSave(ctx context.Context) (_node *Messages, err
}
}
if value, ok := muo.mutation.Message(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: messages.FieldMessage,
})
_spec.SetField(messages.FieldMessage, field.TypeString, value)
}
if value, ok := muo.mutation.AllChat(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeBool,
Value: value,
Column: messages.FieldAllChat,
})
_spec.SetField(messages.FieldAllChat, field.TypeBool, value)
}
if value, ok := muo.mutation.Tick(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: messages.FieldTick,
})
_spec.SetField(messages.FieldTick, field.TypeInt, value)
}
if value, ok := muo.mutation.AddedTick(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: messages.FieldTick,
})
_spec.AddField(messages.FieldTick, field.TypeInt, value)
}
if muo.mutation.MatchPlayerCleared() {
edge := &sqlgraph.EdgeSpec{
@@ -424,10 +336,7 @@ func (muo *MessagesUpdateOne) sqlSave(ctx context.Context) (_node *Messages, err
Columns: []string{messages.MatchPlayerColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
@@ -440,10 +349,7 @@ func (muo *MessagesUpdateOne) sqlSave(ctx context.Context) (_node *Messages, err
Columns: []string{messages.MatchPlayerColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
@@ -451,6 +357,7 @@ func (muo *MessagesUpdateOne) sqlSave(ctx context.Context) (_node *Messages, err
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_spec.AddModifiers(muo.modifiers...)
_node = &Messages{config: muo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
@@ -458,9 +365,10 @@ func (muo *MessagesUpdateOne) sqlSave(ctx context.Context) (_node *Messages, err
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{messages.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
muo.mutation.done = true
return _node, nil
}

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package migrate
@@ -28,9 +28,6 @@ var (
// and therefore, it's recommended to enable this option to get more
// flexibility in the schema changes.
WithDropIndex = schema.WithDropIndex
// WithFixture sets the foreign-key renaming option to the migration when upgrading
// ent from v0.1.0 (issue-#285). Defaults to false.
WithFixture = schema.WithFixture
// WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true.
WithForeignKeys = schema.WithForeignKeys
)
@@ -45,11 +42,16 @@ func NewSchema(drv dialect.Driver) *Schema { return &Schema{drv: drv} }
// Create creates all schema resources.
func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error {
return Create(ctx, s, Tables, opts...)
}
// Create creates all table resources using the given schema driver.
func Create(ctx context.Context, s *Schema, tables []*schema.Table, opts ...schema.MigrateOption) error {
migrate, err := schema.NewMigrate(s.drv, opts...)
if err != nil {
return fmt.Errorf("ent/migrate: %w", err)
}
return migrate.Create(ctx, Tables...)
return migrate.Create(ctx, tables...)
}
// WriteTo writes the schema changes to w instead of running them against the database.
@@ -57,15 +59,6 @@ func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error
// if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil {
// log.Fatal(err)
// }
//
func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error {
drv := &schema.WriteDriver{
Writer: w,
Driver: s.drv,
}
migrate, err := schema.NewMigrate(drv, opts...)
if err != nil {
return fmt.Errorf("ent/migrate: %w", err)
}
return migrate.Create(ctx, Tables...)
return Create(ctx, &Schema{drv: &schema.WriteDriver{Writer: w, Driver: s.drv}}, Tables, opts...)
}

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package migrate
@@ -24,6 +24,7 @@ var (
{Name: "vac_present", Type: field.TypeBool, Default: false},
{Name: "gameban_present", Type: field.TypeBool, Default: false},
{Name: "decryption_key", Type: field.TypeBytes, Nullable: true},
{Name: "tick_rate", Type: field.TypeFloat64, Nullable: true},
}
// MatchesTable holds the schema information for the "matches" table.
MatchesTable = &schema.Table{
@@ -64,6 +65,7 @@ var (
{Name: "flash_total_team", Type: field.TypeUint, Nullable: true},
{Name: "flash_total_enemy", Type: field.TypeUint, Nullable: true},
{Name: "flash_assists", Type: field.TypeInt, Nullable: true},
{Name: "avg_ping", Type: field.TypeFloat64, Nullable: true},
{Name: "match_stats", Type: field.TypeUint64, Nullable: true},
{Name: "player_stats", Type: field.TypeUint64, Nullable: true},
}
@@ -75,13 +77,13 @@ var (
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "match_players_matches_stats",
Columns: []*schema.Column{MatchPlayersColumns[31]},
Columns: []*schema.Column{MatchPlayersColumns[32]},
RefColumns: []*schema.Column{MatchesColumns[0]},
OnDelete: schema.SetNull,
},
{
Symbol: "match_players_players_stats",
Columns: []*schema.Column{MatchPlayersColumns[32]},
Columns: []*schema.Column{MatchPlayersColumns[33]},
RefColumns: []*schema.Column{PlayersColumns[0]},
OnDelete: schema.SetNull,
},

View File

@@ -1,23 +1,24 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"csgowtfd/ent/match"
"csgowtfd/ent/matchplayer"
"csgowtfd/ent/messages"
"csgowtfd/ent/player"
"csgowtfd/ent/predicate"
"csgowtfd/ent/roundstats"
"csgowtfd/ent/spray"
"csgowtfd/ent/weapon"
"errors"
"fmt"
"sync"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"somegit.dev/csgowtf/csgowtfd/ent/match"
"somegit.dev/csgowtf/csgowtfd/ent/matchplayer"
"somegit.dev/csgowtf/csgowtfd/ent/messages"
"somegit.dev/csgowtf/csgowtfd/ent/player"
"somegit.dev/csgowtf/csgowtfd/ent/predicate"
"somegit.dev/csgowtf/csgowtfd/ent/roundstats"
"somegit.dev/csgowtf/csgowtfd/ent/spray"
"somegit.dev/csgowtf/csgowtfd/ent/weapon"
)
const (
@@ -62,6 +63,8 @@ type MatchMutation struct {
vac_present *bool
gameban_present *bool
decryption_key *[]byte
tick_rate *float64
addtick_rate *float64
clearedFields map[string]struct{}
stats map[int]struct{}
removedstats map[int]struct{}
@@ -785,6 +788,76 @@ func (m *MatchMutation) ResetDecryptionKey() {
delete(m.clearedFields, match.FieldDecryptionKey)
}
// SetTickRate sets the "tick_rate" field.
func (m *MatchMutation) SetTickRate(f float64) {
m.tick_rate = &f
m.addtick_rate = nil
}
// TickRate returns the value of the "tick_rate" field in the mutation.
func (m *MatchMutation) TickRate() (r float64, exists bool) {
v := m.tick_rate
if v == nil {
return
}
return *v, true
}
// OldTickRate returns the old "tick_rate" field's value of the Match entity.
// If the Match object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *MatchMutation) OldTickRate(ctx context.Context) (v float64, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldTickRate is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldTickRate requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldTickRate: %w", err)
}
return oldValue.TickRate, nil
}
// AddTickRate adds f to the "tick_rate" field.
func (m *MatchMutation) AddTickRate(f float64) {
if m.addtick_rate != nil {
*m.addtick_rate += f
} else {
m.addtick_rate = &f
}
}
// AddedTickRate returns the value that was added to the "tick_rate" field in this mutation.
func (m *MatchMutation) AddedTickRate() (r float64, exists bool) {
v := m.addtick_rate
if v == nil {
return
}
return *v, true
}
// ClearTickRate clears the value of the "tick_rate" field.
func (m *MatchMutation) ClearTickRate() {
m.tick_rate = nil
m.addtick_rate = nil
m.clearedFields[match.FieldTickRate] = struct{}{}
}
// TickRateCleared returns if the "tick_rate" field was cleared in this mutation.
func (m *MatchMutation) TickRateCleared() bool {
_, ok := m.clearedFields[match.FieldTickRate]
return ok
}
// ResetTickRate resets all changes to the "tick_rate" field.
func (m *MatchMutation) ResetTickRate() {
m.tick_rate = nil
m.addtick_rate = nil
delete(m.clearedFields, match.FieldTickRate)
}
// AddStatIDs adds the "stats" edge to the MatchPlayer entity by ids.
func (m *MatchMutation) AddStatIDs(ids ...int) {
if m.stats == nil {
@@ -898,11 +971,26 @@ func (m *MatchMutation) Where(ps ...predicate.Match) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the MatchMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *MatchMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.Match, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *MatchMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *MatchMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (Match).
func (m *MatchMutation) Type() string {
return m.typ
@@ -912,7 +1000,7 @@ func (m *MatchMutation) Type() string {
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *MatchMutation) Fields() []string {
fields := make([]string, 0, 13)
fields := make([]string, 0, 14)
if m.share_code != nil {
fields = append(fields, match.FieldShareCode)
}
@@ -952,6 +1040,9 @@ func (m *MatchMutation) Fields() []string {
if m.decryption_key != nil {
fields = append(fields, match.FieldDecryptionKey)
}
if m.tick_rate != nil {
fields = append(fields, match.FieldTickRate)
}
return fields
}
@@ -986,6 +1077,8 @@ func (m *MatchMutation) Field(name string) (ent.Value, bool) {
return m.GamebanPresent()
case match.FieldDecryptionKey:
return m.DecryptionKey()
case match.FieldTickRate:
return m.TickRate()
}
return nil, false
}
@@ -1021,6 +1114,8 @@ func (m *MatchMutation) OldField(ctx context.Context, name string) (ent.Value, e
return m.OldGamebanPresent(ctx)
case match.FieldDecryptionKey:
return m.OldDecryptionKey(ctx)
case match.FieldTickRate:
return m.OldTickRate(ctx)
}
return nil, fmt.Errorf("unknown Match field %s", name)
}
@@ -1121,6 +1216,13 @@ func (m *MatchMutation) SetField(name string, value ent.Value) error {
}
m.SetDecryptionKey(v)
return nil
case match.FieldTickRate:
v, ok := value.(float64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetTickRate(v)
return nil
}
return fmt.Errorf("unknown Match field %s", name)
}
@@ -1144,6 +1246,9 @@ func (m *MatchMutation) AddedFields() []string {
if m.addmax_rounds != nil {
fields = append(fields, match.FieldMaxRounds)
}
if m.addtick_rate != nil {
fields = append(fields, match.FieldTickRate)
}
return fields
}
@@ -1162,6 +1267,8 @@ func (m *MatchMutation) AddedField(name string) (ent.Value, bool) {
return m.AddedMatchResult()
case match.FieldMaxRounds:
return m.AddedMaxRounds()
case match.FieldTickRate:
return m.AddedTickRate()
}
return nil, false
}
@@ -1206,6 +1313,13 @@ func (m *MatchMutation) AddField(name string, value ent.Value) error {
}
m.AddMaxRounds(v)
return nil
case match.FieldTickRate:
v, ok := value.(float64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddTickRate(v)
return nil
}
return fmt.Errorf("unknown Match numeric field %s", name)
}
@@ -1223,6 +1337,9 @@ func (m *MatchMutation) ClearedFields() []string {
if m.FieldCleared(match.FieldDecryptionKey) {
fields = append(fields, match.FieldDecryptionKey)
}
if m.FieldCleared(match.FieldTickRate) {
fields = append(fields, match.FieldTickRate)
}
return fields
}
@@ -1246,6 +1363,9 @@ func (m *MatchMutation) ClearField(name string) error {
case match.FieldDecryptionKey:
m.ClearDecryptionKey()
return nil
case match.FieldTickRate:
m.ClearTickRate()
return nil
}
return fmt.Errorf("unknown Match nullable field %s", name)
}
@@ -1293,6 +1413,9 @@ func (m *MatchMutation) ResetField(name string) error {
case match.FieldDecryptionKey:
m.ResetDecryptionKey()
return nil
case match.FieldTickRate:
m.ResetTickRate()
return nil
}
return fmt.Errorf("unknown Match field %s", name)
}
@@ -1471,6 +1594,8 @@ type MatchPlayerMutation struct {
addflash_total_enemy *int
flash_assists *int
addflash_assists *int
avg_ping *float64
addavg_ping *float64
clearedFields map[string]struct{}
matches *uint64
clearedmatches bool
@@ -3649,6 +3774,76 @@ func (m *MatchPlayerMutation) ResetFlashAssists() {
delete(m.clearedFields, matchplayer.FieldFlashAssists)
}
// SetAvgPing sets the "avg_ping" field.
func (m *MatchPlayerMutation) SetAvgPing(f float64) {
m.avg_ping = &f
m.addavg_ping = nil
}
// AvgPing returns the value of the "avg_ping" field in the mutation.
func (m *MatchPlayerMutation) AvgPing() (r float64, exists bool) {
v := m.avg_ping
if v == nil {
return
}
return *v, true
}
// OldAvgPing returns the old "avg_ping" field's value of the MatchPlayer entity.
// If the MatchPlayer object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *MatchPlayerMutation) OldAvgPing(ctx context.Context) (v float64, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldAvgPing is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldAvgPing requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldAvgPing: %w", err)
}
return oldValue.AvgPing, nil
}
// AddAvgPing adds f to the "avg_ping" field.
func (m *MatchPlayerMutation) AddAvgPing(f float64) {
if m.addavg_ping != nil {
*m.addavg_ping += f
} else {
m.addavg_ping = &f
}
}
// AddedAvgPing returns the value that was added to the "avg_ping" field in this mutation.
func (m *MatchPlayerMutation) AddedAvgPing() (r float64, exists bool) {
v := m.addavg_ping
if v == nil {
return
}
return *v, true
}
// ClearAvgPing clears the value of the "avg_ping" field.
func (m *MatchPlayerMutation) ClearAvgPing() {
m.avg_ping = nil
m.addavg_ping = nil
m.clearedFields[matchplayer.FieldAvgPing] = struct{}{}
}
// AvgPingCleared returns if the "avg_ping" field was cleared in this mutation.
func (m *MatchPlayerMutation) AvgPingCleared() bool {
_, ok := m.clearedFields[matchplayer.FieldAvgPing]
return ok
}
// ResetAvgPing resets all changes to the "avg_ping" field.
func (m *MatchPlayerMutation) ResetAvgPing() {
m.avg_ping = nil
m.addavg_ping = nil
delete(m.clearedFields, matchplayer.FieldAvgPing)
}
// SetMatchesID sets the "matches" edge to the Match entity by id.
func (m *MatchPlayerMutation) SetMatchesID(id uint64) {
m.matches = &id
@@ -3948,11 +4143,26 @@ func (m *MatchPlayerMutation) Where(ps ...predicate.MatchPlayer) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the MatchPlayerMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *MatchPlayerMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.MatchPlayer, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *MatchPlayerMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *MatchPlayerMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (MatchPlayer).
func (m *MatchPlayerMutation) Type() string {
return m.typ
@@ -3962,7 +4172,7 @@ func (m *MatchPlayerMutation) Type() string {
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *MatchPlayerMutation) Fields() []string {
fields := make([]string, 0, 32)
fields := make([]string, 0, 33)
if m.team_id != nil {
fields = append(fields, matchplayer.FieldTeamID)
}
@@ -4059,6 +4269,9 @@ func (m *MatchPlayerMutation) Fields() []string {
if m.flash_assists != nil {
fields = append(fields, matchplayer.FieldFlashAssists)
}
if m.avg_ping != nil {
fields = append(fields, matchplayer.FieldAvgPing)
}
return fields
}
@@ -4131,6 +4344,8 @@ func (m *MatchPlayerMutation) Field(name string) (ent.Value, bool) {
return m.PlayerStats()
case matchplayer.FieldFlashAssists:
return m.FlashAssists()
case matchplayer.FieldAvgPing:
return m.AvgPing()
}
return nil, false
}
@@ -4204,6 +4419,8 @@ func (m *MatchPlayerMutation) OldField(ctx context.Context, name string) (ent.Va
return m.OldPlayerStats(ctx)
case matchplayer.FieldFlashAssists:
return m.OldFlashAssists(ctx)
case matchplayer.FieldAvgPing:
return m.OldAvgPing(ctx)
}
return nil, fmt.Errorf("unknown MatchPlayer field %s", name)
}
@@ -4437,6 +4654,13 @@ func (m *MatchPlayerMutation) SetField(name string, value ent.Value) error {
}
m.SetFlashAssists(v)
return nil
case matchplayer.FieldAvgPing:
v, ok := value.(float64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetAvgPing(v)
return nil
}
return fmt.Errorf("unknown MatchPlayer field %s", name)
}
@@ -4529,6 +4753,9 @@ func (m *MatchPlayerMutation) AddedFields() []string {
if m.addflash_assists != nil {
fields = append(fields, matchplayer.FieldFlashAssists)
}
if m.addavg_ping != nil {
fields = append(fields, matchplayer.FieldAvgPing)
}
return fields
}
@@ -4593,6 +4820,8 @@ func (m *MatchPlayerMutation) AddedField(name string) (ent.Value, bool) {
return m.AddedFlashTotalEnemy()
case matchplayer.FieldFlashAssists:
return m.AddedFlashAssists()
case matchplayer.FieldAvgPing:
return m.AddedAvgPing()
}
return nil, false
}
@@ -4798,6 +5027,13 @@ func (m *MatchPlayerMutation) AddField(name string, value ent.Value) error {
}
m.AddFlashAssists(v)
return nil
case matchplayer.FieldAvgPing:
v, ok := value.(float64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddAvgPing(v)
return nil
}
return fmt.Errorf("unknown MatchPlayer numeric field %s", name)
}
@@ -4881,6 +5117,9 @@ func (m *MatchPlayerMutation) ClearedFields() []string {
if m.FieldCleared(matchplayer.FieldFlashAssists) {
fields = append(fields, matchplayer.FieldFlashAssists)
}
if m.FieldCleared(matchplayer.FieldAvgPing) {
fields = append(fields, matchplayer.FieldAvgPing)
}
return fields
}
@@ -4970,6 +5209,9 @@ func (m *MatchPlayerMutation) ClearField(name string) error {
case matchplayer.FieldFlashAssists:
m.ClearFlashAssists()
return nil
case matchplayer.FieldAvgPing:
m.ClearAvgPing()
return nil
}
return fmt.Errorf("unknown MatchPlayer nullable field %s", name)
}
@@ -5074,6 +5316,9 @@ func (m *MatchPlayerMutation) ResetField(name string) error {
case matchplayer.FieldFlashAssists:
m.ResetFlashAssists()
return nil
case matchplayer.FieldAvgPing:
m.ResetAvgPing()
return nil
}
return fmt.Errorf("unknown MatchPlayer field %s", name)
}
@@ -5564,11 +5809,26 @@ func (m *MessagesMutation) Where(ps ...predicate.Messages) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the MessagesMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *MessagesMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.Messages, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *MessagesMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *MessagesMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (Messages).
func (m *MessagesMutation) Type() string {
return m.typ
@@ -5754,8 +6014,6 @@ func (m *MessagesMutation) RemovedEdges() []string {
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *MessagesMutation) RemovedIDs(name string) []ent.Value {
switch name {
}
return nil
}
@@ -6932,11 +7190,26 @@ func (m *PlayerMutation) Where(ps ...predicate.Player) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the PlayerMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *PlayerMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.Player, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *PlayerMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *PlayerMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (Player).
func (m *PlayerMutation) Type() string {
return m.typ
@@ -7952,11 +8225,26 @@ func (m *RoundStatsMutation) Where(ps ...predicate.RoundStats) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the RoundStatsMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *RoundStatsMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.RoundStats, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *RoundStatsMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *RoundStatsMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (RoundStats).
func (m *RoundStatsMutation) Type() string {
return m.typ
@@ -8195,8 +8483,6 @@ func (m *RoundStatsMutation) RemovedEdges() []string {
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *RoundStatsMutation) RemovedIDs(name string) []ent.Value {
switch name {
}
return nil
}
@@ -8492,11 +8778,26 @@ func (m *SprayMutation) Where(ps ...predicate.Spray) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the SprayMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *SprayMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.Spray, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *SprayMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *SprayMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (Spray).
func (m *SprayMutation) Type() string {
return m.typ
@@ -8665,8 +8966,6 @@ func (m *SprayMutation) RemovedEdges() []string {
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *SprayMutation) RemovedIDs(name string) []ent.Value {
switch name {
}
return nil
}
@@ -9099,11 +9398,26 @@ func (m *WeaponMutation) Where(ps ...predicate.Weapon) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the WeaponMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *WeaponMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.Weapon, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *WeaponMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *WeaponMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (Weapon).
func (m *WeaponMutation) Type() string {
return m.typ
@@ -9342,8 +9656,6 @@ func (m *WeaponMutation) RemovedEdges() []string {
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *WeaponMutation) RemovedIDs(name string) []ent.Value {
switch name {
}
return nil
}

View File

@@ -1,14 +1,15 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"csgowtfd/ent/player"
"fmt"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"somegit.dev/csgowtf/csgowtfd/ent/player"
)
// Player is the model entity for the Player schema.
@@ -51,6 +52,7 @@ type Player struct {
// 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"`
selectValues sql.SelectValues
}
// PlayerEdges holds the relations/edges for other nodes in the graph.
@@ -83,8 +85,8 @@ func (e PlayerEdges) MatchesOrErr() ([]*Match, error) {
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Player) scanValues(columns []string) ([]interface{}, error) {
values := make([]interface{}, len(columns))
func (*Player) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case player.FieldID, player.FieldVacCount, player.FieldGameBanCount, player.FieldWins, player.FieldLooses, player.FieldTies:
@@ -94,7 +96,7 @@ func (*Player) scanValues(columns []string) ([]interface{}, error) {
case player.FieldVacDate, player.FieldGameBanDate, player.FieldSteamUpdated, player.FieldSharecodeUpdated, player.FieldProfileCreated:
values[i] = new(sql.NullTime)
default:
return nil, fmt.Errorf("unexpected column %q for type Player", columns[i])
values[i] = new(sql.UnknownType)
}
}
return values, nil
@@ -102,7 +104,7 @@ func (*Player) scanValues(columns []string) ([]interface{}, error) {
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the Player fields.
func (pl *Player) assignValues(columns []string, values []interface{}) error {
func (pl *Player) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
@@ -210,36 +212,44 @@ func (pl *Player) assignValues(columns []string, values []interface{}) error {
} else if value.Valid {
pl.Ties = int(value.Int64)
}
default:
pl.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the Player.
// This includes values selected through modifiers, order, etc.
func (pl *Player) Value(name string) (ent.Value, error) {
return pl.selectValues.Get(name)
}
// QueryStats queries the "stats" edge of the Player entity.
func (pl *Player) QueryStats() *MatchPlayerQuery {
return (&PlayerClient{config: pl.config}).QueryStats(pl)
return NewPlayerClient(pl.config).QueryStats(pl)
}
// QueryMatches queries the "matches" edge of the Player entity.
func (pl *Player) QueryMatches() *MatchQuery {
return (&PlayerClient{config: pl.config}).QueryMatches(pl)
return NewPlayerClient(pl.config).QueryMatches(pl)
}
// Update returns a builder for updating this Player.
// Note that you need to call Player.Unwrap() before calling this method if this Player
// was returned from a transaction, and the transaction was committed or rolled back.
func (pl *Player) Update() *PlayerUpdateOne {
return (&PlayerClient{config: pl.config}).UpdateOne(pl)
return NewPlayerClient(pl.config).UpdateOne(pl)
}
// Unwrap unwraps the Player 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 (pl *Player) Unwrap() *Player {
tx, ok := pl.config.driver.(*txDriver)
_tx, ok := pl.config.driver.(*txDriver)
if !ok {
panic("ent: Player is not a transactional entity")
}
pl.config.driver = tx.drv
pl.config.driver = _tx.drv
return pl
}
@@ -247,37 +257,52 @@ func (pl *Player) Unwrap() *Player {
func (pl *Player) String() string {
var builder strings.Builder
builder.WriteString("Player(")
builder.WriteString(fmt.Sprintf("id=%v", pl.ID))
builder.WriteString(", name=")
builder.WriteString(fmt.Sprintf("id=%v, ", pl.ID))
builder.WriteString("name=")
builder.WriteString(pl.Name)
builder.WriteString(", avatar=")
builder.WriteString(", ")
builder.WriteString("avatar=")
builder.WriteString(pl.Avatar)
builder.WriteString(", vanity_url=")
builder.WriteString(", ")
builder.WriteString("vanity_url=")
builder.WriteString(pl.VanityURL)
builder.WriteString(", vanity_url_real=")
builder.WriteString(", ")
builder.WriteString("vanity_url_real=")
builder.WriteString(pl.VanityURLReal)
builder.WriteString(", vac_date=")
builder.WriteString(", ")
builder.WriteString("vac_date=")
builder.WriteString(pl.VacDate.Format(time.ANSIC))
builder.WriteString(", vac_count=")
builder.WriteString(", ")
builder.WriteString("vac_count=")
builder.WriteString(fmt.Sprintf("%v", pl.VacCount))
builder.WriteString(", game_ban_date=")
builder.WriteString(", ")
builder.WriteString("game_ban_date=")
builder.WriteString(pl.GameBanDate.Format(time.ANSIC))
builder.WriteString(", game_ban_count=")
builder.WriteString(", ")
builder.WriteString("game_ban_count=")
builder.WriteString(fmt.Sprintf("%v", pl.GameBanCount))
builder.WriteString(", steam_updated=")
builder.WriteString(", ")
builder.WriteString("steam_updated=")
builder.WriteString(pl.SteamUpdated.Format(time.ANSIC))
builder.WriteString(", sharecode_updated=")
builder.WriteString(", ")
builder.WriteString("sharecode_updated=")
builder.WriteString(pl.SharecodeUpdated.Format(time.ANSIC))
builder.WriteString(", auth_code=<sensitive>")
builder.WriteString(", profile_created=")
builder.WriteString(", ")
builder.WriteString("auth_code=<sensitive>")
builder.WriteString(", ")
builder.WriteString("profile_created=")
builder.WriteString(pl.ProfileCreated.Format(time.ANSIC))
builder.WriteString(", oldest_sharecode_seen=")
builder.WriteString(", ")
builder.WriteString("oldest_sharecode_seen=")
builder.WriteString(pl.OldestSharecodeSeen)
builder.WriteString(", wins=")
builder.WriteString(", ")
builder.WriteString("wins=")
builder.WriteString(fmt.Sprintf("%v", pl.Wins))
builder.WriteString(", looses=")
builder.WriteString(", ")
builder.WriteString("looses=")
builder.WriteString(fmt.Sprintf("%v", pl.Looses))
builder.WriteString(", ties=")
builder.WriteString(", ")
builder.WriteString("ties=")
builder.WriteString(fmt.Sprintf("%v", pl.Ties))
builder.WriteByte(')')
return builder.String()
@@ -285,9 +310,3 @@ func (pl *Player) String() string {
// Players is a parsable slice of Player.
type Players []*Player
func (pl Players) config(cfg config) {
for _i := range pl {
pl[_i].config = cfg
}
}

View File

@@ -1,9 +1,12 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package player
import (
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
const (
@@ -104,3 +107,133 @@ var (
// DefaultSteamUpdated holds the default value on creation for the "steam_updated" field.
DefaultSteamUpdated func() time.Time
)
// OrderOption defines the ordering options for the Player queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByName orders the results by the name field.
func ByName(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldName, opts...).ToFunc()
}
// ByAvatar orders the results by the avatar field.
func ByAvatar(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAvatar, opts...).ToFunc()
}
// ByVanityURL orders the results by the vanity_url field.
func ByVanityURL(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldVanityURL, opts...).ToFunc()
}
// ByVanityURLReal orders the results by the vanity_url_real field.
func ByVanityURLReal(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldVanityURLReal, opts...).ToFunc()
}
// ByVacDate orders the results by the vac_date field.
func ByVacDate(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldVacDate, opts...).ToFunc()
}
// ByVacCount orders the results by the vac_count field.
func ByVacCount(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldVacCount, opts...).ToFunc()
}
// ByGameBanDate orders the results by the game_ban_date field.
func ByGameBanDate(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldGameBanDate, opts...).ToFunc()
}
// ByGameBanCount orders the results by the game_ban_count field.
func ByGameBanCount(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldGameBanCount, opts...).ToFunc()
}
// BySteamUpdated orders the results by the steam_updated field.
func BySteamUpdated(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSteamUpdated, opts...).ToFunc()
}
// BySharecodeUpdated orders the results by the sharecode_updated field.
func BySharecodeUpdated(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSharecodeUpdated, opts...).ToFunc()
}
// ByAuthCode orders the results by the auth_code field.
func ByAuthCode(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAuthCode, opts...).ToFunc()
}
// ByProfileCreated orders the results by the profile_created field.
func ByProfileCreated(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldProfileCreated, opts...).ToFunc()
}
// ByOldestSharecodeSeen orders the results by the oldest_sharecode_seen field.
func ByOldestSharecodeSeen(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldOldestSharecodeSeen, opts...).ToFunc()
}
// ByWins orders the results by the wins field.
func ByWins(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldWins, opts...).ToFunc()
}
// ByLooses orders the results by the looses field.
func ByLooses(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLooses, opts...).ToFunc()
}
// ByTies orders the results by the ties field.
func ByTies(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTies, opts...).ToFunc()
}
// ByStatsCount orders the results by stats count.
func ByStatsCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newStatsStep(), opts...)
}
}
// ByStats orders the results by stats terms.
func ByStats(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newStatsStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// ByMatchesCount orders the results by matches count.
func ByMatchesCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newMatchesStep(), opts...)
}
}
// ByMatches orders the results by matches terms.
func ByMatches(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newMatchesStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
func newStatsStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(StatsInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, StatsTable, StatsColumn),
)
}
func newMatchesStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(MatchesInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2M, false, MatchesTable, MatchesPrimaryKey...),
)
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,18 +1,18 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"csgowtfd/ent/match"
"csgowtfd/ent/matchplayer"
"csgowtfd/ent/player"
"errors"
"fmt"
"time"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"somegit.dev/csgowtf/csgowtfd/ent/match"
"somegit.dev/csgowtf/csgowtfd/ent/matchplayer"
"somegit.dev/csgowtf/csgowtfd/ent/player"
)
// PlayerCreate is the builder for creating a Player entity.
@@ -289,44 +289,8 @@ func (pc *PlayerCreate) Mutation() *PlayerMutation {
// Save creates the Player in the database.
func (pc *PlayerCreate) Save(ctx context.Context) (*Player, error) {
var (
err error
node *Player
)
pc.defaults()
if len(pc.hooks) == 0 {
if err = pc.check(); err != nil {
return nil, err
}
node, err = pc.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*PlayerMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = pc.check(); err != nil {
return nil, err
}
pc.mutation = mutation
if node, err = pc.sqlSave(ctx); err != nil {
return nil, err
}
mutation.id = &node.ID
mutation.done = true
return node, err
})
for i := len(pc.hooks) - 1; i >= 0; i-- {
if pc.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = pc.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, pc.mutation); err != nil {
return nil, err
}
}
return node, err
return withHooks(ctx, pc.sqlSave, pc.mutation, pc.hooks)
}
// SaveX calls Save and panics if Save returns an error.
@@ -368,10 +332,13 @@ func (pc *PlayerCreate) check() error {
}
func (pc *PlayerCreate) sqlSave(ctx context.Context) (*Player, error) {
if err := pc.check(); err != nil {
return nil, err
}
_node, _spec := pc.createSpec()
if err := sqlgraph.CreateNode(ctx, pc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
@@ -379,150 +346,82 @@ func (pc *PlayerCreate) sqlSave(ctx context.Context) (*Player, error) {
id := _spec.ID.Value.(int64)
_node.ID = uint64(id)
}
pc.mutation.id = &_node.ID
pc.mutation.done = true
return _node, nil
}
func (pc *PlayerCreate) createSpec() (*Player, *sqlgraph.CreateSpec) {
var (
_node = &Player{config: pc.config}
_spec = &sqlgraph.CreateSpec{
Table: player.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUint64,
Column: player.FieldID,
},
}
_spec = sqlgraph.NewCreateSpec(player.Table, sqlgraph.NewFieldSpec(player.FieldID, field.TypeUint64))
)
if id, ok := pc.mutation.ID(); ok {
_node.ID = id
_spec.ID.Value = id
}
if value, ok := pc.mutation.Name(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: player.FieldName,
})
_spec.SetField(player.FieldName, field.TypeString, value)
_node.Name = value
}
if value, ok := pc.mutation.Avatar(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: player.FieldAvatar,
})
_spec.SetField(player.FieldAvatar, field.TypeString, value)
_node.Avatar = value
}
if value, ok := pc.mutation.VanityURL(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: player.FieldVanityURL,
})
_spec.SetField(player.FieldVanityURL, field.TypeString, value)
_node.VanityURL = value
}
if value, ok := pc.mutation.VanityURLReal(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: player.FieldVanityURLReal,
})
_spec.SetField(player.FieldVanityURLReal, field.TypeString, value)
_node.VanityURLReal = value
}
if value, ok := pc.mutation.VacDate(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeTime,
Value: value,
Column: player.FieldVacDate,
})
_spec.SetField(player.FieldVacDate, field.TypeTime, value)
_node.VacDate = value
}
if value, ok := pc.mutation.VacCount(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: player.FieldVacCount,
})
_spec.SetField(player.FieldVacCount, field.TypeInt, value)
_node.VacCount = value
}
if value, ok := pc.mutation.GameBanDate(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeTime,
Value: value,
Column: player.FieldGameBanDate,
})
_spec.SetField(player.FieldGameBanDate, field.TypeTime, value)
_node.GameBanDate = value
}
if value, ok := pc.mutation.GameBanCount(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: player.FieldGameBanCount,
})
_spec.SetField(player.FieldGameBanCount, field.TypeInt, value)
_node.GameBanCount = value
}
if value, ok := pc.mutation.SteamUpdated(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeTime,
Value: value,
Column: player.FieldSteamUpdated,
})
_spec.SetField(player.FieldSteamUpdated, field.TypeTime, value)
_node.SteamUpdated = value
}
if value, ok := pc.mutation.SharecodeUpdated(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeTime,
Value: value,
Column: player.FieldSharecodeUpdated,
})
_spec.SetField(player.FieldSharecodeUpdated, field.TypeTime, value)
_node.SharecodeUpdated = value
}
if value, ok := pc.mutation.AuthCode(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: player.FieldAuthCode,
})
_spec.SetField(player.FieldAuthCode, field.TypeString, value)
_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,
})
_spec.SetField(player.FieldProfileCreated, field.TypeTime, value)
_node.ProfileCreated = value
}
if value, ok := pc.mutation.OldestSharecodeSeen(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: player.FieldOldestSharecodeSeen,
})
_spec.SetField(player.FieldOldestSharecodeSeen, field.TypeString, value)
_node.OldestSharecodeSeen = value
}
if value, ok := pc.mutation.Wins(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: player.FieldWins,
})
_spec.SetField(player.FieldWins, field.TypeInt, value)
_node.Wins = value
}
if value, ok := pc.mutation.Looses(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: player.FieldLooses,
})
_spec.SetField(player.FieldLooses, field.TypeInt, value)
_node.Looses = value
}
if value, ok := pc.mutation.Ties(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: player.FieldTies,
})
_spec.SetField(player.FieldTies, field.TypeInt, value)
_node.Ties = value
}
if nodes := pc.mutation.StatsIDs(); len(nodes) > 0 {
@@ -533,10 +432,7 @@ func (pc *PlayerCreate) createSpec() (*Player, *sqlgraph.CreateSpec) {
Columns: []string{player.StatsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
@@ -552,10 +448,7 @@ func (pc *PlayerCreate) createSpec() (*Player, *sqlgraph.CreateSpec) {
Columns: player.MatchesPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeUint64,
Column: match.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(match.FieldID, field.TypeUint64),
},
}
for _, k := range nodes {
@@ -590,8 +483,8 @@ func (pcb *PlayerCreateBulk) Save(ctx context.Context) ([]*Player, error) {
return nil, err
}
builder.mutation = mutation
nodes[i], specs[i] = builder.createSpec()
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, pcb.builders[i+1].mutation)
} else {
@@ -599,7 +492,7 @@ func (pcb *PlayerCreateBulk) Save(ctx context.Context) ([]*Player, error) {
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, pcb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
@@ -607,11 +500,11 @@ func (pcb *PlayerCreateBulk) Save(ctx context.Context) ([]*Player, error) {
return nil, err
}
mutation.id = &nodes[i].ID
mutation.done = true
if specs[i].ID.Value != nil && nodes[i].ID == 0 {
id := specs[i].ID.Value.(int64)
nodes[i].ID = uint64(id)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -1,16 +1,15 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"csgowtfd/ent/player"
"csgowtfd/ent/predicate"
"fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"somegit.dev/csgowtf/csgowtfd/ent/player"
"somegit.dev/csgowtf/csgowtfd/ent/predicate"
)
// PlayerDelete is the builder for deleting a Player entity.
@@ -28,34 +27,7 @@ func (pd *PlayerDelete) Where(ps ...predicate.Player) *PlayerDelete {
// Exec executes the deletion query and returns how many vertices were deleted.
func (pd *PlayerDelete) Exec(ctx context.Context) (int, error) {
var (
err error
affected int
)
if len(pd.hooks) == 0 {
affected, err = pd.sqlExec(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*PlayerMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
pd.mutation = mutation
affected, err = pd.sqlExec(ctx)
mutation.done = true
return affected, err
})
for i := len(pd.hooks) - 1; i >= 0; i-- {
if pd.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = pd.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, pd.mutation); err != nil {
return 0, err
}
}
return affected, err
return withHooks(ctx, pd.sqlExec, pd.mutation, pd.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
@@ -68,15 +40,7 @@ func (pd *PlayerDelete) ExecX(ctx context.Context) int {
}
func (pd *PlayerDelete) sqlExec(ctx context.Context) (int, error) {
_spec := &sqlgraph.DeleteSpec{
Node: &sqlgraph.NodeSpec{
Table: player.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUint64,
Column: player.FieldID,
},
},
}
_spec := sqlgraph.NewDeleteSpec(player.Table, sqlgraph.NewFieldSpec(player.FieldID, field.TypeUint64))
if ps := pd.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
@@ -84,7 +48,12 @@ func (pd *PlayerDelete) sqlExec(ctx context.Context) (int, error) {
}
}
}
return sqlgraph.DeleteNodes(ctx, pd.driver, _spec)
affected, err := sqlgraph.DeleteNodes(ctx, pd.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
pd.mutation.done = true
return affected, err
}
// PlayerDeleteOne is the builder for deleting a single Player entity.
@@ -92,6 +61,12 @@ type PlayerDeleteOne struct {
pd *PlayerDelete
}
// Where appends a list predicates to the PlayerDelete builder.
func (pdo *PlayerDeleteOne) Where(ps ...predicate.Player) *PlayerDeleteOne {
pdo.pd.mutation.Where(ps...)
return pdo
}
// Exec executes the deletion query.
func (pdo *PlayerDeleteOne) Exec(ctx context.Context) error {
n, err := pdo.pd.Exec(ctx)
@@ -107,5 +82,7 @@ func (pdo *PlayerDeleteOne) Exec(ctx context.Context) error {
// ExecX is like Exec, but panics if an error occurs.
func (pdo *PlayerDeleteOne) ExecX(ctx context.Context) {
pdo.pd.ExecX(ctx)
if err := pdo.Exec(ctx); err != nil {
panic(err)
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +1,9 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"csgowtfd/ent/match"
"csgowtfd/ent/matchplayer"
"csgowtfd/ent/player"
"csgowtfd/ent/predicate"
"errors"
"fmt"
"time"
@@ -15,6 +11,10 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"somegit.dev/csgowtf/csgowtfd/ent/match"
"somegit.dev/csgowtf/csgowtfd/ent/matchplayer"
"somegit.dev/csgowtf/csgowtfd/ent/player"
"somegit.dev/csgowtf/csgowtfd/ent/predicate"
)
// PlayerUpdate is the builder for updating Player entities.
@@ -22,6 +22,7 @@ type PlayerUpdate struct {
config
hooks []Hook
mutation *PlayerMutation
modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the PlayerUpdate builder.
@@ -458,34 +459,7 @@ func (pu *PlayerUpdate) RemoveMatches(m ...*Match) *PlayerUpdate {
// Save executes the query and returns the number of nodes affected by the update operation.
func (pu *PlayerUpdate) Save(ctx context.Context) (int, error) {
var (
err error
affected int
)
if len(pu.hooks) == 0 {
affected, err = pu.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*PlayerMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
pu.mutation = mutation
affected, err = pu.sqlSave(ctx)
mutation.done = true
return affected, err
})
for i := len(pu.hooks) - 1; i >= 0; i-- {
if pu.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = pu.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, pu.mutation); err != nil {
return 0, err
}
}
return affected, err
return withHooks(ctx, pu.sqlSave, pu.mutation, pu.hooks)
}
// SaveX is like Save, but panics if an error occurs.
@@ -510,17 +484,14 @@ func (pu *PlayerUpdate) ExecX(ctx context.Context) {
}
}
func (pu *PlayerUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: player.Table,
Columns: player.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUint64,
Column: player.FieldID,
},
},
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (pu *PlayerUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PlayerUpdate {
pu.modifiers = append(pu.modifiers, modifiers...)
return pu
}
func (pu *PlayerUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := sqlgraph.NewUpdateSpec(player.Table, player.Columns, sqlgraph.NewFieldSpec(player.FieldID, field.TypeUint64))
if ps := pu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
@@ -529,241 +500,112 @@ func (pu *PlayerUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
}
if value, ok := pu.mutation.Name(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: player.FieldName,
})
_spec.SetField(player.FieldName, field.TypeString, value)
}
if pu.mutation.NameCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeString,
Column: player.FieldName,
})
_spec.ClearField(player.FieldName, field.TypeString)
}
if value, ok := pu.mutation.Avatar(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: player.FieldAvatar,
})
_spec.SetField(player.FieldAvatar, field.TypeString, value)
}
if pu.mutation.AvatarCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeString,
Column: player.FieldAvatar,
})
_spec.ClearField(player.FieldAvatar, field.TypeString)
}
if value, ok := pu.mutation.VanityURL(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: player.FieldVanityURL,
})
_spec.SetField(player.FieldVanityURL, field.TypeString, value)
}
if pu.mutation.VanityURLCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeString,
Column: player.FieldVanityURL,
})
_spec.ClearField(player.FieldVanityURL, field.TypeString)
}
if value, ok := pu.mutation.VanityURLReal(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: player.FieldVanityURLReal,
})
_spec.SetField(player.FieldVanityURLReal, field.TypeString, value)
}
if pu.mutation.VanityURLRealCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeString,
Column: player.FieldVanityURLReal,
})
_spec.ClearField(player.FieldVanityURLReal, field.TypeString)
}
if value, ok := pu.mutation.VacDate(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeTime,
Value: value,
Column: player.FieldVacDate,
})
_spec.SetField(player.FieldVacDate, field.TypeTime, value)
}
if pu.mutation.VacDateCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeTime,
Column: player.FieldVacDate,
})
_spec.ClearField(player.FieldVacDate, field.TypeTime)
}
if value, ok := pu.mutation.VacCount(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: player.FieldVacCount,
})
_spec.SetField(player.FieldVacCount, field.TypeInt, value)
}
if value, ok := pu.mutation.AddedVacCount(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: player.FieldVacCount,
})
_spec.AddField(player.FieldVacCount, field.TypeInt, value)
}
if pu.mutation.VacCountCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: player.FieldVacCount,
})
_spec.ClearField(player.FieldVacCount, field.TypeInt)
}
if value, ok := pu.mutation.GameBanDate(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeTime,
Value: value,
Column: player.FieldGameBanDate,
})
_spec.SetField(player.FieldGameBanDate, field.TypeTime, value)
}
if pu.mutation.GameBanDateCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeTime,
Column: player.FieldGameBanDate,
})
_spec.ClearField(player.FieldGameBanDate, field.TypeTime)
}
if value, ok := pu.mutation.GameBanCount(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: player.FieldGameBanCount,
})
_spec.SetField(player.FieldGameBanCount, field.TypeInt, value)
}
if value, ok := pu.mutation.AddedGameBanCount(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: player.FieldGameBanCount,
})
_spec.AddField(player.FieldGameBanCount, field.TypeInt, value)
}
if pu.mutation.GameBanCountCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: player.FieldGameBanCount,
})
_spec.ClearField(player.FieldGameBanCount, field.TypeInt)
}
if value, ok := pu.mutation.SteamUpdated(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeTime,
Value: value,
Column: player.FieldSteamUpdated,
})
_spec.SetField(player.FieldSteamUpdated, field.TypeTime, value)
}
if value, ok := pu.mutation.SharecodeUpdated(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeTime,
Value: value,
Column: player.FieldSharecodeUpdated,
})
_spec.SetField(player.FieldSharecodeUpdated, field.TypeTime, value)
}
if pu.mutation.SharecodeUpdatedCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeTime,
Column: player.FieldSharecodeUpdated,
})
_spec.ClearField(player.FieldSharecodeUpdated, field.TypeTime)
}
if value, ok := pu.mutation.AuthCode(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: player.FieldAuthCode,
})
_spec.SetField(player.FieldAuthCode, field.TypeString, value)
}
if pu.mutation.AuthCodeCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeString,
Column: player.FieldAuthCode,
})
_spec.ClearField(player.FieldAuthCode, field.TypeString)
}
if value, ok := pu.mutation.ProfileCreated(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeTime,
Value: value,
Column: player.FieldProfileCreated,
})
_spec.SetField(player.FieldProfileCreated, field.TypeTime, value)
}
if pu.mutation.ProfileCreatedCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeTime,
Column: player.FieldProfileCreated,
})
_spec.ClearField(player.FieldProfileCreated, field.TypeTime)
}
if value, ok := pu.mutation.OldestSharecodeSeen(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: player.FieldOldestSharecodeSeen,
})
_spec.SetField(player.FieldOldestSharecodeSeen, field.TypeString, value)
}
if pu.mutation.OldestSharecodeSeenCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeString,
Column: player.FieldOldestSharecodeSeen,
})
_spec.ClearField(player.FieldOldestSharecodeSeen, field.TypeString)
}
if value, ok := pu.mutation.Wins(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: player.FieldWins,
})
_spec.SetField(player.FieldWins, field.TypeInt, value)
}
if value, ok := pu.mutation.AddedWins(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: player.FieldWins,
})
_spec.AddField(player.FieldWins, field.TypeInt, value)
}
if pu.mutation.WinsCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: player.FieldWins,
})
_spec.ClearField(player.FieldWins, field.TypeInt)
}
if value, ok := pu.mutation.Looses(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: player.FieldLooses,
})
_spec.SetField(player.FieldLooses, field.TypeInt, value)
}
if value, ok := pu.mutation.AddedLooses(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: player.FieldLooses,
})
_spec.AddField(player.FieldLooses, field.TypeInt, value)
}
if pu.mutation.LoosesCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: player.FieldLooses,
})
_spec.ClearField(player.FieldLooses, field.TypeInt)
}
if value, ok := pu.mutation.Ties(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: player.FieldTies,
})
_spec.SetField(player.FieldTies, field.TypeInt, value)
}
if value, ok := pu.mutation.AddedTies(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: player.FieldTies,
})
_spec.AddField(player.FieldTies, field.TypeInt, value)
}
if pu.mutation.TiesCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: player.FieldTies,
})
_spec.ClearField(player.FieldTies, field.TypeInt)
}
if pu.mutation.StatsCleared() {
edge := &sqlgraph.EdgeSpec{
@@ -773,10 +615,7 @@ func (pu *PlayerUpdate) sqlSave(ctx context.Context) (n int, err error) {
Columns: []string{player.StatsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
@@ -789,10 +628,7 @@ func (pu *PlayerUpdate) sqlSave(ctx context.Context) (n int, err error) {
Columns: []string{player.StatsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
@@ -808,10 +644,7 @@ func (pu *PlayerUpdate) sqlSave(ctx context.Context) (n int, err error) {
Columns: []string{player.StatsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
@@ -827,10 +660,7 @@ func (pu *PlayerUpdate) sqlSave(ctx context.Context) (n int, err error) {
Columns: player.MatchesPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeUint64,
Column: match.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(match.FieldID, field.TypeUint64),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
@@ -843,10 +673,7 @@ func (pu *PlayerUpdate) sqlSave(ctx context.Context) (n int, err error) {
Columns: player.MatchesPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeUint64,
Column: match.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(match.FieldID, field.TypeUint64),
},
}
for _, k := range nodes {
@@ -862,10 +689,7 @@ func (pu *PlayerUpdate) sqlSave(ctx context.Context) (n int, err error) {
Columns: player.MatchesPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeUint64,
Column: match.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(match.FieldID, field.TypeUint64),
},
}
for _, k := range nodes {
@@ -873,14 +697,16 @@ func (pu *PlayerUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_spec.AddModifiers(pu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, pu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{player.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
pu.mutation.done = true
return n, nil
}
@@ -890,6 +716,7 @@ type PlayerUpdateOne struct {
fields []string
hooks []Hook
mutation *PlayerMutation
modifiers []func(*sql.UpdateBuilder)
}
// SetName sets the "name" field.
@@ -1318,6 +1145,12 @@ func (puo *PlayerUpdateOne) RemoveMatches(m ...*Match) *PlayerUpdateOne {
return puo.RemoveMatchIDs(ids...)
}
// Where appends a list predicates to the PlayerUpdate builder.
func (puo *PlayerUpdateOne) Where(ps ...predicate.Player) *PlayerUpdateOne {
puo.mutation.Where(ps...)
return puo
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (puo *PlayerUpdateOne) Select(field string, fields ...string) *PlayerUpdateOne {
@@ -1327,34 +1160,7 @@ func (puo *PlayerUpdateOne) Select(field string, fields ...string) *PlayerUpdate
// Save executes the query and returns the updated Player entity.
func (puo *PlayerUpdateOne) Save(ctx context.Context) (*Player, error) {
var (
err error
node *Player
)
if len(puo.hooks) == 0 {
node, err = puo.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*PlayerMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
puo.mutation = mutation
node, err = puo.sqlSave(ctx)
mutation.done = true
return node, err
})
for i := len(puo.hooks) - 1; i >= 0; i-- {
if puo.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = puo.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, puo.mutation); err != nil {
return nil, err
}
}
return node, err
return withHooks(ctx, puo.sqlSave, puo.mutation, puo.hooks)
}
// SaveX is like Save, but panics if an error occurs.
@@ -1379,17 +1185,14 @@ func (puo *PlayerUpdateOne) ExecX(ctx context.Context) {
}
}
func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err error) {
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: player.Table,
Columns: player.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUint64,
Column: player.FieldID,
},
},
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (puo *PlayerUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PlayerUpdateOne {
puo.modifiers = append(puo.modifiers, modifiers...)
return puo
}
func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err error) {
_spec := sqlgraph.NewUpdateSpec(player.Table, player.Columns, sqlgraph.NewFieldSpec(player.FieldID, field.TypeUint64))
id, ok := puo.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Player.id" for update`)}
@@ -1415,241 +1218,112 @@ func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err err
}
}
if value, ok := puo.mutation.Name(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: player.FieldName,
})
_spec.SetField(player.FieldName, field.TypeString, value)
}
if puo.mutation.NameCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeString,
Column: player.FieldName,
})
_spec.ClearField(player.FieldName, field.TypeString)
}
if value, ok := puo.mutation.Avatar(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: player.FieldAvatar,
})
_spec.SetField(player.FieldAvatar, field.TypeString, value)
}
if puo.mutation.AvatarCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeString,
Column: player.FieldAvatar,
})
_spec.ClearField(player.FieldAvatar, field.TypeString)
}
if value, ok := puo.mutation.VanityURL(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: player.FieldVanityURL,
})
_spec.SetField(player.FieldVanityURL, field.TypeString, value)
}
if puo.mutation.VanityURLCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeString,
Column: player.FieldVanityURL,
})
_spec.ClearField(player.FieldVanityURL, field.TypeString)
}
if value, ok := puo.mutation.VanityURLReal(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: player.FieldVanityURLReal,
})
_spec.SetField(player.FieldVanityURLReal, field.TypeString, value)
}
if puo.mutation.VanityURLRealCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeString,
Column: player.FieldVanityURLReal,
})
_spec.ClearField(player.FieldVanityURLReal, field.TypeString)
}
if value, ok := puo.mutation.VacDate(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeTime,
Value: value,
Column: player.FieldVacDate,
})
_spec.SetField(player.FieldVacDate, field.TypeTime, value)
}
if puo.mutation.VacDateCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeTime,
Column: player.FieldVacDate,
})
_spec.ClearField(player.FieldVacDate, field.TypeTime)
}
if value, ok := puo.mutation.VacCount(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: player.FieldVacCount,
})
_spec.SetField(player.FieldVacCount, field.TypeInt, value)
}
if value, ok := puo.mutation.AddedVacCount(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: player.FieldVacCount,
})
_spec.AddField(player.FieldVacCount, field.TypeInt, value)
}
if puo.mutation.VacCountCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: player.FieldVacCount,
})
_spec.ClearField(player.FieldVacCount, field.TypeInt)
}
if value, ok := puo.mutation.GameBanDate(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeTime,
Value: value,
Column: player.FieldGameBanDate,
})
_spec.SetField(player.FieldGameBanDate, field.TypeTime, value)
}
if puo.mutation.GameBanDateCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeTime,
Column: player.FieldGameBanDate,
})
_spec.ClearField(player.FieldGameBanDate, field.TypeTime)
}
if value, ok := puo.mutation.GameBanCount(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: player.FieldGameBanCount,
})
_spec.SetField(player.FieldGameBanCount, field.TypeInt, value)
}
if value, ok := puo.mutation.AddedGameBanCount(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: player.FieldGameBanCount,
})
_spec.AddField(player.FieldGameBanCount, field.TypeInt, value)
}
if puo.mutation.GameBanCountCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: player.FieldGameBanCount,
})
_spec.ClearField(player.FieldGameBanCount, field.TypeInt)
}
if value, ok := puo.mutation.SteamUpdated(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeTime,
Value: value,
Column: player.FieldSteamUpdated,
})
_spec.SetField(player.FieldSteamUpdated, field.TypeTime, value)
}
if value, ok := puo.mutation.SharecodeUpdated(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeTime,
Value: value,
Column: player.FieldSharecodeUpdated,
})
_spec.SetField(player.FieldSharecodeUpdated, field.TypeTime, value)
}
if puo.mutation.SharecodeUpdatedCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeTime,
Column: player.FieldSharecodeUpdated,
})
_spec.ClearField(player.FieldSharecodeUpdated, field.TypeTime)
}
if value, ok := puo.mutation.AuthCode(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: player.FieldAuthCode,
})
_spec.SetField(player.FieldAuthCode, field.TypeString, value)
}
if puo.mutation.AuthCodeCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeString,
Column: player.FieldAuthCode,
})
_spec.ClearField(player.FieldAuthCode, field.TypeString)
}
if value, ok := puo.mutation.ProfileCreated(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeTime,
Value: value,
Column: player.FieldProfileCreated,
})
_spec.SetField(player.FieldProfileCreated, field.TypeTime, value)
}
if puo.mutation.ProfileCreatedCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeTime,
Column: player.FieldProfileCreated,
})
_spec.ClearField(player.FieldProfileCreated, field.TypeTime)
}
if value, ok := puo.mutation.OldestSharecodeSeen(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: player.FieldOldestSharecodeSeen,
})
_spec.SetField(player.FieldOldestSharecodeSeen, field.TypeString, value)
}
if puo.mutation.OldestSharecodeSeenCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeString,
Column: player.FieldOldestSharecodeSeen,
})
_spec.ClearField(player.FieldOldestSharecodeSeen, field.TypeString)
}
if value, ok := puo.mutation.Wins(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: player.FieldWins,
})
_spec.SetField(player.FieldWins, field.TypeInt, value)
}
if value, ok := puo.mutation.AddedWins(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: player.FieldWins,
})
_spec.AddField(player.FieldWins, field.TypeInt, value)
}
if puo.mutation.WinsCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: player.FieldWins,
})
_spec.ClearField(player.FieldWins, field.TypeInt)
}
if value, ok := puo.mutation.Looses(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: player.FieldLooses,
})
_spec.SetField(player.FieldLooses, field.TypeInt, value)
}
if value, ok := puo.mutation.AddedLooses(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: player.FieldLooses,
})
_spec.AddField(player.FieldLooses, field.TypeInt, value)
}
if puo.mutation.LoosesCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: player.FieldLooses,
})
_spec.ClearField(player.FieldLooses, field.TypeInt)
}
if value, ok := puo.mutation.Ties(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: player.FieldTies,
})
_spec.SetField(player.FieldTies, field.TypeInt, value)
}
if value, ok := puo.mutation.AddedTies(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: player.FieldTies,
})
_spec.AddField(player.FieldTies, field.TypeInt, value)
}
if puo.mutation.TiesCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: player.FieldTies,
})
_spec.ClearField(player.FieldTies, field.TypeInt)
}
if puo.mutation.StatsCleared() {
edge := &sqlgraph.EdgeSpec{
@@ -1659,10 +1333,7 @@ func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err err
Columns: []string{player.StatsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
@@ -1675,10 +1346,7 @@ func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err err
Columns: []string{player.StatsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
@@ -1694,10 +1362,7 @@ func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err err
Columns: []string{player.StatsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
@@ -1713,10 +1378,7 @@ func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err err
Columns: player.MatchesPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeUint64,
Column: match.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(match.FieldID, field.TypeUint64),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
@@ -1729,10 +1391,7 @@ func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err err
Columns: player.MatchesPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeUint64,
Column: match.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(match.FieldID, field.TypeUint64),
},
}
for _, k := range nodes {
@@ -1748,10 +1407,7 @@ func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err err
Columns: player.MatchesPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeUint64,
Column: match.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(match.FieldID, field.TypeUint64),
},
}
for _, k := range nodes {
@@ -1759,6 +1415,7 @@ func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err err
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_spec.AddModifiers(puo.modifiers...)
_node = &Player{config: puo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
@@ -1766,9 +1423,10 @@ func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err err
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{player.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
puo.mutation.done = true
return _node, nil
}

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package predicate

View File

@@ -1,14 +1,15 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"csgowtfd/ent/matchplayer"
"csgowtfd/ent/roundstats"
"fmt"
"strings"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"somegit.dev/csgowtf/csgowtfd/ent/matchplayer"
"somegit.dev/csgowtf/csgowtfd/ent/roundstats"
)
// RoundStats is the model entity for the RoundStats schema.
@@ -28,6 +29,7 @@ type RoundStats struct {
// The values are being populated by the RoundStatsQuery when eager-loading is set.
Edges RoundStatsEdges `json:"edges"`
match_player_round_stats *int
selectValues sql.SelectValues
}
// RoundStatsEdges holds the relations/edges for other nodes in the graph.
@@ -44,8 +46,7 @@ type RoundStatsEdges struct {
func (e RoundStatsEdges) MatchPlayerOrErr() (*MatchPlayer, error) {
if e.loadedTypes[0] {
if e.MatchPlayer == nil {
// The edge match_player was loaded in eager-loading,
// but was not found.
// Edge was loaded but was not found.
return nil, &NotFoundError{label: matchplayer.Label}
}
return e.MatchPlayer, nil
@@ -54,8 +55,8 @@ func (e RoundStatsEdges) MatchPlayerOrErr() (*MatchPlayer, error) {
}
// scanValues returns the types for scanning values from sql.Rows.
func (*RoundStats) scanValues(columns []string) ([]interface{}, error) {
values := make([]interface{}, len(columns))
func (*RoundStats) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case roundstats.FieldID, roundstats.FieldRound, roundstats.FieldBank, roundstats.FieldEquipment, roundstats.FieldSpent:
@@ -63,7 +64,7 @@ func (*RoundStats) scanValues(columns []string) ([]interface{}, error) {
case roundstats.ForeignKeys[0]: // match_player_round_stats
values[i] = new(sql.NullInt64)
default:
return nil, fmt.Errorf("unexpected column %q for type RoundStats", columns[i])
values[i] = new(sql.UnknownType)
}
}
return values, nil
@@ -71,7 +72,7 @@ func (*RoundStats) scanValues(columns []string) ([]interface{}, error) {
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the RoundStats fields.
func (rs *RoundStats) assignValues(columns []string, values []interface{}) error {
func (rs *RoundStats) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
@@ -114,31 +115,39 @@ func (rs *RoundStats) assignValues(columns []string, values []interface{}) error
rs.match_player_round_stats = new(int)
*rs.match_player_round_stats = int(value.Int64)
}
default:
rs.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the RoundStats.
// This includes values selected through modifiers, order, etc.
func (rs *RoundStats) Value(name string) (ent.Value, error) {
return rs.selectValues.Get(name)
}
// QueryMatchPlayer queries the "match_player" edge of the RoundStats entity.
func (rs *RoundStats) QueryMatchPlayer() *MatchPlayerQuery {
return (&RoundStatsClient{config: rs.config}).QueryMatchPlayer(rs)
return NewRoundStatsClient(rs.config).QueryMatchPlayer(rs)
}
// Update returns a builder for updating this RoundStats.
// Note that you need to call RoundStats.Unwrap() before calling this method if this RoundStats
// was returned from a transaction, and the transaction was committed or rolled back.
func (rs *RoundStats) Update() *RoundStatsUpdateOne {
return (&RoundStatsClient{config: rs.config}).UpdateOne(rs)
return NewRoundStatsClient(rs.config).UpdateOne(rs)
}
// Unwrap unwraps the RoundStats entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (rs *RoundStats) Unwrap() *RoundStats {
tx, ok := rs.config.driver.(*txDriver)
_tx, ok := rs.config.driver.(*txDriver)
if !ok {
panic("ent: RoundStats is not a transactional entity")
}
rs.config.driver = tx.drv
rs.config.driver = _tx.drv
return rs
}
@@ -146,14 +155,17 @@ func (rs *RoundStats) Unwrap() *RoundStats {
func (rs *RoundStats) String() string {
var builder strings.Builder
builder.WriteString("RoundStats(")
builder.WriteString(fmt.Sprintf("id=%v", rs.ID))
builder.WriteString(", round=")
builder.WriteString(fmt.Sprintf("id=%v, ", rs.ID))
builder.WriteString("round=")
builder.WriteString(fmt.Sprintf("%v", rs.Round))
builder.WriteString(", bank=")
builder.WriteString(", ")
builder.WriteString("bank=")
builder.WriteString(fmt.Sprintf("%v", rs.Bank))
builder.WriteString(", equipment=")
builder.WriteString(", ")
builder.WriteString("equipment=")
builder.WriteString(fmt.Sprintf("%v", rs.Equipment))
builder.WriteString(", spent=")
builder.WriteString(", ")
builder.WriteString("spent=")
builder.WriteString(fmt.Sprintf("%v", rs.Spent))
builder.WriteByte(')')
return builder.String()
@@ -161,9 +173,3 @@ func (rs *RoundStats) String() string {
// RoundStatsSlice is a parsable slice of RoundStats.
type RoundStatsSlice []*RoundStats
func (rs RoundStatsSlice) config(cfg config) {
for _i := range rs {
rs[_i].config = cfg
}
}

View File

@@ -1,7 +1,12 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package roundstats
import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
const (
// Label holds the string label denoting the roundstats type in the database.
Label = "round_stats"
@@ -57,3 +62,45 @@ func ValidColumn(column string) bool {
}
return false
}
// OrderOption defines the ordering options for the RoundStats queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByRound orders the results by the round field.
func ByRound(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldRound, opts...).ToFunc()
}
// ByBank orders the results by the bank field.
func ByBank(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldBank, opts...).ToFunc()
}
// ByEquipment orders the results by the equipment field.
func ByEquipment(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldEquipment, opts...).ToFunc()
}
// BySpent orders the results by the spent field.
func BySpent(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSpent, opts...).ToFunc()
}
// ByMatchPlayerField orders the results by match_player field.
func ByMatchPlayerField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newMatchPlayerStep(), sql.OrderByField(field, opts...))
}
}
func newMatchPlayerStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(MatchPlayerInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, MatchPlayerTable, MatchPlayerColumn),
)
}

View File

@@ -1,427 +1,236 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package roundstats
import (
"csgowtfd/ent/predicate"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"somegit.dev/csgowtf/csgowtfd/ent/predicate"
)
// ID filters vertices based on their ID field.
func ID(id int) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldID), id))
})
return predicate.RoundStats(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id int) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldID), id))
})
return predicate.RoundStats(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id int) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.NEQ(s.C(FieldID), id))
})
return predicate.RoundStats(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(ids) == 0 {
s.Where(sql.False())
return
}
v := make([]interface{}, len(ids))
for i := range v {
v[i] = ids[i]
}
s.Where(sql.In(s.C(FieldID), v...))
})
return predicate.RoundStats(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(ids) == 0 {
s.Where(sql.False())
return
}
v := make([]interface{}, len(ids))
for i := range v {
v[i] = ids[i]
}
s.Where(sql.NotIn(s.C(FieldID), v...))
})
return predicate.RoundStats(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id int) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.GT(s.C(FieldID), id))
})
return predicate.RoundStats(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id int) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.GTE(s.C(FieldID), id))
})
return predicate.RoundStats(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id int) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.LT(s.C(FieldID), id))
})
return predicate.RoundStats(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id int) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.LTE(s.C(FieldID), id))
})
return predicate.RoundStats(sql.FieldLTE(FieldID, id))
}
// Round applies equality check predicate on the "round" field. It's identical to RoundEQ.
func Round(v uint) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldRound), v))
})
return predicate.RoundStats(sql.FieldEQ(FieldRound, v))
}
// Bank applies equality check predicate on the "bank" field. It's identical to BankEQ.
func Bank(v uint) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldBank), v))
})
return predicate.RoundStats(sql.FieldEQ(FieldBank, v))
}
// Equipment applies equality check predicate on the "equipment" field. It's identical to EquipmentEQ.
func Equipment(v uint) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldEquipment), v))
})
return predicate.RoundStats(sql.FieldEQ(FieldEquipment, v))
}
// Spent applies equality check predicate on the "spent" field. It's identical to SpentEQ.
func Spent(v uint) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldSpent), v))
})
return predicate.RoundStats(sql.FieldEQ(FieldSpent, v))
}
// RoundEQ applies the EQ predicate on the "round" field.
func RoundEQ(v uint) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldRound), v))
})
return predicate.RoundStats(sql.FieldEQ(FieldRound, v))
}
// RoundNEQ applies the NEQ predicate on the "round" field.
func RoundNEQ(v uint) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.NEQ(s.C(FieldRound), v))
})
return predicate.RoundStats(sql.FieldNEQ(FieldRound, v))
}
// RoundIn applies the In predicate on the "round" field.
func RoundIn(vs ...uint) predicate.RoundStats {
v := make([]interface{}, len(vs))
for i := range v {
v[i] = vs[i]
}
return predicate.RoundStats(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldRound), v...))
})
return predicate.RoundStats(sql.FieldIn(FieldRound, vs...))
}
// RoundNotIn applies the NotIn predicate on the "round" field.
func RoundNotIn(vs ...uint) predicate.RoundStats {
v := make([]interface{}, len(vs))
for i := range v {
v[i] = vs[i]
}
return predicate.RoundStats(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldRound), v...))
})
return predicate.RoundStats(sql.FieldNotIn(FieldRound, vs...))
}
// RoundGT applies the GT predicate on the "round" field.
func RoundGT(v uint) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.GT(s.C(FieldRound), v))
})
return predicate.RoundStats(sql.FieldGT(FieldRound, v))
}
// RoundGTE applies the GTE predicate on the "round" field.
func RoundGTE(v uint) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.GTE(s.C(FieldRound), v))
})
return predicate.RoundStats(sql.FieldGTE(FieldRound, v))
}
// RoundLT applies the LT predicate on the "round" field.
func RoundLT(v uint) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.LT(s.C(FieldRound), v))
})
return predicate.RoundStats(sql.FieldLT(FieldRound, v))
}
// RoundLTE applies the LTE predicate on the "round" field.
func RoundLTE(v uint) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.LTE(s.C(FieldRound), v))
})
return predicate.RoundStats(sql.FieldLTE(FieldRound, v))
}
// BankEQ applies the EQ predicate on the "bank" field.
func BankEQ(v uint) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldBank), v))
})
return predicate.RoundStats(sql.FieldEQ(FieldBank, v))
}
// BankNEQ applies the NEQ predicate on the "bank" field.
func BankNEQ(v uint) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.NEQ(s.C(FieldBank), v))
})
return predicate.RoundStats(sql.FieldNEQ(FieldBank, v))
}
// BankIn applies the In predicate on the "bank" field.
func BankIn(vs ...uint) predicate.RoundStats {
v := make([]interface{}, len(vs))
for i := range v {
v[i] = vs[i]
}
return predicate.RoundStats(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldBank), v...))
})
return predicate.RoundStats(sql.FieldIn(FieldBank, vs...))
}
// BankNotIn applies the NotIn predicate on the "bank" field.
func BankNotIn(vs ...uint) predicate.RoundStats {
v := make([]interface{}, len(vs))
for i := range v {
v[i] = vs[i]
}
return predicate.RoundStats(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldBank), v...))
})
return predicate.RoundStats(sql.FieldNotIn(FieldBank, vs...))
}
// BankGT applies the GT predicate on the "bank" field.
func BankGT(v uint) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.GT(s.C(FieldBank), v))
})
return predicate.RoundStats(sql.FieldGT(FieldBank, v))
}
// BankGTE applies the GTE predicate on the "bank" field.
func BankGTE(v uint) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.GTE(s.C(FieldBank), v))
})
return predicate.RoundStats(sql.FieldGTE(FieldBank, v))
}
// BankLT applies the LT predicate on the "bank" field.
func BankLT(v uint) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.LT(s.C(FieldBank), v))
})
return predicate.RoundStats(sql.FieldLT(FieldBank, v))
}
// BankLTE applies the LTE predicate on the "bank" field.
func BankLTE(v uint) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.LTE(s.C(FieldBank), v))
})
return predicate.RoundStats(sql.FieldLTE(FieldBank, v))
}
// EquipmentEQ applies the EQ predicate on the "equipment" field.
func EquipmentEQ(v uint) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldEquipment), v))
})
return predicate.RoundStats(sql.FieldEQ(FieldEquipment, v))
}
// EquipmentNEQ applies the NEQ predicate on the "equipment" field.
func EquipmentNEQ(v uint) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.NEQ(s.C(FieldEquipment), v))
})
return predicate.RoundStats(sql.FieldNEQ(FieldEquipment, v))
}
// EquipmentIn applies the In predicate on the "equipment" field.
func EquipmentIn(vs ...uint) predicate.RoundStats {
v := make([]interface{}, len(vs))
for i := range v {
v[i] = vs[i]
}
return predicate.RoundStats(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldEquipment), v...))
})
return predicate.RoundStats(sql.FieldIn(FieldEquipment, vs...))
}
// EquipmentNotIn applies the NotIn predicate on the "equipment" field.
func EquipmentNotIn(vs ...uint) predicate.RoundStats {
v := make([]interface{}, len(vs))
for i := range v {
v[i] = vs[i]
}
return predicate.RoundStats(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldEquipment), v...))
})
return predicate.RoundStats(sql.FieldNotIn(FieldEquipment, vs...))
}
// EquipmentGT applies the GT predicate on the "equipment" field.
func EquipmentGT(v uint) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.GT(s.C(FieldEquipment), v))
})
return predicate.RoundStats(sql.FieldGT(FieldEquipment, v))
}
// EquipmentGTE applies the GTE predicate on the "equipment" field.
func EquipmentGTE(v uint) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.GTE(s.C(FieldEquipment), v))
})
return predicate.RoundStats(sql.FieldGTE(FieldEquipment, v))
}
// EquipmentLT applies the LT predicate on the "equipment" field.
func EquipmentLT(v uint) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.LT(s.C(FieldEquipment), v))
})
return predicate.RoundStats(sql.FieldLT(FieldEquipment, v))
}
// EquipmentLTE applies the LTE predicate on the "equipment" field.
func EquipmentLTE(v uint) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.LTE(s.C(FieldEquipment), v))
})
return predicate.RoundStats(sql.FieldLTE(FieldEquipment, v))
}
// SpentEQ applies the EQ predicate on the "spent" field.
func SpentEQ(v uint) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldSpent), v))
})
return predicate.RoundStats(sql.FieldEQ(FieldSpent, v))
}
// SpentNEQ applies the NEQ predicate on the "spent" field.
func SpentNEQ(v uint) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.NEQ(s.C(FieldSpent), v))
})
return predicate.RoundStats(sql.FieldNEQ(FieldSpent, v))
}
// SpentIn applies the In predicate on the "spent" field.
func SpentIn(vs ...uint) predicate.RoundStats {
v := make([]interface{}, len(vs))
for i := range v {
v[i] = vs[i]
}
return predicate.RoundStats(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldSpent), v...))
})
return predicate.RoundStats(sql.FieldIn(FieldSpent, vs...))
}
// SpentNotIn applies the NotIn predicate on the "spent" field.
func SpentNotIn(vs ...uint) predicate.RoundStats {
v := make([]interface{}, len(vs))
for i := range v {
v[i] = vs[i]
}
return predicate.RoundStats(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldSpent), v...))
})
return predicate.RoundStats(sql.FieldNotIn(FieldSpent, vs...))
}
// SpentGT applies the GT predicate on the "spent" field.
func SpentGT(v uint) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.GT(s.C(FieldSpent), v))
})
return predicate.RoundStats(sql.FieldGT(FieldSpent, v))
}
// SpentGTE applies the GTE predicate on the "spent" field.
func SpentGTE(v uint) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.GTE(s.C(FieldSpent), v))
})
return predicate.RoundStats(sql.FieldGTE(FieldSpent, v))
}
// SpentLT applies the LT predicate on the "spent" field.
func SpentLT(v uint) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.LT(s.C(FieldSpent), v))
})
return predicate.RoundStats(sql.FieldLT(FieldSpent, v))
}
// SpentLTE applies the LTE predicate on the "spent" field.
func SpentLTE(v uint) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.LTE(s.C(FieldSpent), v))
})
return predicate.RoundStats(sql.FieldLTE(FieldSpent, v))
}
// HasMatchPlayer applies the HasEdge predicate on the "match_player" edge.
@@ -429,7 +238,6 @@ func HasMatchPlayer() predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(MatchPlayerTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, MatchPlayerTable, MatchPlayerColumn),
)
sqlgraph.HasNeighbors(s, step)
@@ -439,11 +247,7 @@ func HasMatchPlayer() predicate.RoundStats {
// HasMatchPlayerWith applies the HasEdge predicate on the "match_player" edge with a given conditions (other predicates).
func HasMatchPlayerWith(preds ...predicate.MatchPlayer) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(MatchPlayerInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, MatchPlayerTable, MatchPlayerColumn),
)
step := newMatchPlayerStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)

View File

@@ -1,16 +1,16 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"csgowtfd/ent/matchplayer"
"csgowtfd/ent/roundstats"
"errors"
"fmt"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"somegit.dev/csgowtf/csgowtfd/ent/matchplayer"
"somegit.dev/csgowtf/csgowtfd/ent/roundstats"
)
// RoundStatsCreate is the builder for creating a RoundStats entity.
@@ -70,43 +70,7 @@ func (rsc *RoundStatsCreate) Mutation() *RoundStatsMutation {
// Save creates the RoundStats in the database.
func (rsc *RoundStatsCreate) Save(ctx context.Context) (*RoundStats, error) {
var (
err error
node *RoundStats
)
if len(rsc.hooks) == 0 {
if err = rsc.check(); err != nil {
return nil, err
}
node, err = rsc.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*RoundStatsMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = rsc.check(); err != nil {
return nil, err
}
rsc.mutation = mutation
if node, err = rsc.sqlSave(ctx); err != nil {
return nil, err
}
mutation.id = &node.ID
mutation.done = true
return node, err
})
for i := len(rsc.hooks) - 1; i >= 0; i-- {
if rsc.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = rsc.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, rsc.mutation); err != nil {
return nil, err
}
}
return node, err
return withHooks(ctx, rsc.sqlSave, rsc.mutation, rsc.hooks)
}
// SaveX calls Save and panics if Save returns an error.
@@ -149,59 +113,42 @@ func (rsc *RoundStatsCreate) check() error {
}
func (rsc *RoundStatsCreate) sqlSave(ctx context.Context) (*RoundStats, error) {
if err := rsc.check(); err != nil {
return nil, err
}
_node, _spec := rsc.createSpec()
if err := sqlgraph.CreateNode(ctx, rsc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
id := _spec.ID.Value.(int64)
_node.ID = int(id)
rsc.mutation.id = &_node.ID
rsc.mutation.done = true
return _node, nil
}
func (rsc *RoundStatsCreate) createSpec() (*RoundStats, *sqlgraph.CreateSpec) {
var (
_node = &RoundStats{config: rsc.config}
_spec = &sqlgraph.CreateSpec{
Table: roundstats.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: roundstats.FieldID,
},
}
_spec = sqlgraph.NewCreateSpec(roundstats.Table, sqlgraph.NewFieldSpec(roundstats.FieldID, field.TypeInt))
)
if value, ok := rsc.mutation.Round(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: roundstats.FieldRound,
})
_spec.SetField(roundstats.FieldRound, field.TypeUint, value)
_node.Round = value
}
if value, ok := rsc.mutation.Bank(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: roundstats.FieldBank,
})
_spec.SetField(roundstats.FieldBank, field.TypeUint, value)
_node.Bank = value
}
if value, ok := rsc.mutation.Equipment(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: roundstats.FieldEquipment,
})
_spec.SetField(roundstats.FieldEquipment, field.TypeUint, value)
_node.Equipment = value
}
if value, ok := rsc.mutation.Spent(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: roundstats.FieldSpent,
})
_spec.SetField(roundstats.FieldSpent, field.TypeUint, value)
_node.Spent = value
}
if nodes := rsc.mutation.MatchPlayerIDs(); len(nodes) > 0 {
@@ -212,10 +159,7 @@ func (rsc *RoundStatsCreate) createSpec() (*RoundStats, *sqlgraph.CreateSpec) {
Columns: []string{roundstats.MatchPlayerColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
@@ -250,8 +194,8 @@ func (rscb *RoundStatsCreateBulk) Save(ctx context.Context) ([]*RoundStats, erro
return nil, err
}
builder.mutation = mutation
nodes[i], specs[i] = builder.createSpec()
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, rscb.builders[i+1].mutation)
} else {
@@ -259,7 +203,7 @@ func (rscb *RoundStatsCreateBulk) Save(ctx context.Context) ([]*RoundStats, erro
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, rscb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
@@ -267,11 +211,11 @@ func (rscb *RoundStatsCreateBulk) Save(ctx context.Context) ([]*RoundStats, erro
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)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -1,16 +1,15 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"csgowtfd/ent/predicate"
"csgowtfd/ent/roundstats"
"fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"somegit.dev/csgowtf/csgowtfd/ent/predicate"
"somegit.dev/csgowtf/csgowtfd/ent/roundstats"
)
// RoundStatsDelete is the builder for deleting a RoundStats entity.
@@ -28,34 +27,7 @@ func (rsd *RoundStatsDelete) Where(ps ...predicate.RoundStats) *RoundStatsDelete
// Exec executes the deletion query and returns how many vertices were deleted.
func (rsd *RoundStatsDelete) Exec(ctx context.Context) (int, error) {
var (
err error
affected int
)
if len(rsd.hooks) == 0 {
affected, err = rsd.sqlExec(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*RoundStatsMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
rsd.mutation = mutation
affected, err = rsd.sqlExec(ctx)
mutation.done = true
return affected, err
})
for i := len(rsd.hooks) - 1; i >= 0; i-- {
if rsd.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = rsd.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, rsd.mutation); err != nil {
return 0, err
}
}
return affected, err
return withHooks(ctx, rsd.sqlExec, rsd.mutation, rsd.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
@@ -68,15 +40,7 @@ func (rsd *RoundStatsDelete) ExecX(ctx context.Context) int {
}
func (rsd *RoundStatsDelete) sqlExec(ctx context.Context) (int, error) {
_spec := &sqlgraph.DeleteSpec{
Node: &sqlgraph.NodeSpec{
Table: roundstats.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: roundstats.FieldID,
},
},
}
_spec := sqlgraph.NewDeleteSpec(roundstats.Table, sqlgraph.NewFieldSpec(roundstats.FieldID, field.TypeInt))
if ps := rsd.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
@@ -84,7 +48,12 @@ func (rsd *RoundStatsDelete) sqlExec(ctx context.Context) (int, error) {
}
}
}
return sqlgraph.DeleteNodes(ctx, rsd.driver, _spec)
affected, err := sqlgraph.DeleteNodes(ctx, rsd.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
rsd.mutation.done = true
return affected, err
}
// RoundStatsDeleteOne is the builder for deleting a single RoundStats entity.
@@ -92,6 +61,12 @@ type RoundStatsDeleteOne struct {
rsd *RoundStatsDelete
}
// Where appends a list predicates to the RoundStatsDelete builder.
func (rsdo *RoundStatsDeleteOne) Where(ps ...predicate.RoundStats) *RoundStatsDeleteOne {
rsdo.rsd.mutation.Where(ps...)
return rsdo
}
// Exec executes the deletion query.
func (rsdo *RoundStatsDeleteOne) Exec(ctx context.Context) error {
n, err := rsdo.rsd.Exec(ctx)
@@ -107,5 +82,7 @@ func (rsdo *RoundStatsDeleteOne) Exec(ctx context.Context) error {
// ExecX is like Exec, but panics if an error occurs.
func (rsdo *RoundStatsDeleteOne) ExecX(ctx context.Context) {
rsdo.rsd.ExecX(ctx)
if err := rsdo.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -1,34 +1,30 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"csgowtfd/ent/matchplayer"
"csgowtfd/ent/predicate"
"csgowtfd/ent/roundstats"
"errors"
"fmt"
"math"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"somegit.dev/csgowtf/csgowtfd/ent/matchplayer"
"somegit.dev/csgowtf/csgowtfd/ent/predicate"
"somegit.dev/csgowtf/csgowtfd/ent/roundstats"
)
// RoundStatsQuery is the builder for querying RoundStats entities.
type RoundStatsQuery struct {
config
limit *int
offset *int
unique *bool
order []OrderFunc
fields []string
ctx *QueryContext
order []roundstats.OrderOption
inters []Interceptor
predicates []predicate.RoundStats
// eager-loading edges.
withMatchPlayer *MatchPlayerQuery
withFKs bool
modifiers []func(s *sql.Selector)
modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -40,34 +36,34 @@ func (rsq *RoundStatsQuery) Where(ps ...predicate.RoundStats) *RoundStatsQuery {
return rsq
}
// Limit adds a limit step to the query.
// Limit the number of records to be returned by this query.
func (rsq *RoundStatsQuery) Limit(limit int) *RoundStatsQuery {
rsq.limit = &limit
rsq.ctx.Limit = &limit
return rsq
}
// Offset adds an offset step to the query.
// Offset to start from.
func (rsq *RoundStatsQuery) Offset(offset int) *RoundStatsQuery {
rsq.offset = &offset
rsq.ctx.Offset = &offset
return rsq
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (rsq *RoundStatsQuery) Unique(unique bool) *RoundStatsQuery {
rsq.unique = &unique
rsq.ctx.Unique = &unique
return rsq
}
// Order adds an order step to the query.
func (rsq *RoundStatsQuery) Order(o ...OrderFunc) *RoundStatsQuery {
// Order specifies how the records should be ordered.
func (rsq *RoundStatsQuery) Order(o ...roundstats.OrderOption) *RoundStatsQuery {
rsq.order = append(rsq.order, o...)
return rsq
}
// QueryMatchPlayer chains the current query on the "match_player" edge.
func (rsq *RoundStatsQuery) QueryMatchPlayer() *MatchPlayerQuery {
query := &MatchPlayerQuery{config: rsq.config}
query := (&MatchPlayerClient{config: rsq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := rsq.prepareQuery(ctx); err != nil {
return nil, err
@@ -90,7 +86,7 @@ func (rsq *RoundStatsQuery) QueryMatchPlayer() *MatchPlayerQuery {
// First returns the first RoundStats entity from the query.
// Returns a *NotFoundError when no RoundStats was found.
func (rsq *RoundStatsQuery) First(ctx context.Context) (*RoundStats, error) {
nodes, err := rsq.Limit(1).All(ctx)
nodes, err := rsq.Limit(1).All(setContextOp(ctx, rsq.ctx, "First"))
if err != nil {
return nil, err
}
@@ -113,7 +109,7 @@ func (rsq *RoundStatsQuery) FirstX(ctx context.Context) *RoundStats {
// Returns a *NotFoundError when no RoundStats ID was found.
func (rsq *RoundStatsQuery) FirstID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = rsq.Limit(1).IDs(ctx); err != nil {
if ids, err = rsq.Limit(1).IDs(setContextOp(ctx, rsq.ctx, "FirstID")); err != nil {
return
}
if len(ids) == 0 {
@@ -133,10 +129,10 @@ func (rsq *RoundStatsQuery) FirstIDX(ctx context.Context) int {
}
// Only returns a single RoundStats entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when exactly one RoundStats entity is not found.
// Returns a *NotSingularError when more than one RoundStats entity is found.
// Returns a *NotFoundError when no RoundStats entities are found.
func (rsq *RoundStatsQuery) Only(ctx context.Context) (*RoundStats, error) {
nodes, err := rsq.Limit(2).All(ctx)
nodes, err := rsq.Limit(2).All(setContextOp(ctx, rsq.ctx, "Only"))
if err != nil {
return nil, err
}
@@ -160,11 +156,11 @@ func (rsq *RoundStatsQuery) OnlyX(ctx context.Context) *RoundStats {
}
// OnlyID is like Only, but returns the only RoundStats ID in the query.
// Returns a *NotSingularError when exactly one RoundStats ID is not found.
// Returns a *NotSingularError when more than one RoundStats ID is found.
// Returns a *NotFoundError when no entities are found.
func (rsq *RoundStatsQuery) OnlyID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = rsq.Limit(2).IDs(ctx); err != nil {
if ids, err = rsq.Limit(2).IDs(setContextOp(ctx, rsq.ctx, "OnlyID")); err != nil {
return
}
switch len(ids) {
@@ -189,10 +185,12 @@ func (rsq *RoundStatsQuery) OnlyIDX(ctx context.Context) int {
// All executes the query and returns a list of RoundStatsSlice.
func (rsq *RoundStatsQuery) All(ctx context.Context) ([]*RoundStats, error) {
ctx = setContextOp(ctx, rsq.ctx, "All")
if err := rsq.prepareQuery(ctx); err != nil {
return nil, err
}
return rsq.sqlAll(ctx)
qr := querierAll[[]*RoundStats, *RoundStatsQuery]()
return withInterceptors[[]*RoundStats](ctx, rsq, qr, rsq.inters)
}
// AllX is like All, but panics if an error occurs.
@@ -205,9 +203,12 @@ func (rsq *RoundStatsQuery) AllX(ctx context.Context) []*RoundStats {
}
// IDs executes the query and returns a list of RoundStats IDs.
func (rsq *RoundStatsQuery) IDs(ctx context.Context) ([]int, error) {
var ids []int
if err := rsq.Select(roundstats.FieldID).Scan(ctx, &ids); err != nil {
func (rsq *RoundStatsQuery) IDs(ctx context.Context) (ids []int, err error) {
if rsq.ctx.Unique == nil && rsq.path != nil {
rsq.Unique(true)
}
ctx = setContextOp(ctx, rsq.ctx, "IDs")
if err = rsq.Select(roundstats.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
@@ -224,10 +225,11 @@ func (rsq *RoundStatsQuery) IDsX(ctx context.Context) []int {
// Count returns the count of the given query.
func (rsq *RoundStatsQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, rsq.ctx, "Count")
if err := rsq.prepareQuery(ctx); err != nil {
return 0, err
}
return rsq.sqlCount(ctx)
return withInterceptors[int](ctx, rsq, querierCount[*RoundStatsQuery](), rsq.inters)
}
// CountX is like Count, but panics if an error occurs.
@@ -241,10 +243,15 @@ func (rsq *RoundStatsQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph.
func (rsq *RoundStatsQuery) Exist(ctx context.Context) (bool, error) {
if err := rsq.prepareQuery(ctx); err != nil {
return false, err
ctx = setContextOp(ctx, rsq.ctx, "Exist")
switch _, err := rsq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
return rsq.sqlExist(ctx)
}
// ExistX is like Exist, but panics if an error occurs.
@@ -264,9 +271,9 @@ func (rsq *RoundStatsQuery) Clone() *RoundStatsQuery {
}
return &RoundStatsQuery{
config: rsq.config,
limit: rsq.limit,
offset: rsq.offset,
order: append([]OrderFunc{}, rsq.order...),
ctx: rsq.ctx.Clone(),
order: append([]roundstats.OrderOption{}, rsq.order...),
inters: append([]Interceptor{}, rsq.inters...),
predicates: append([]predicate.RoundStats{}, rsq.predicates...),
withMatchPlayer: rsq.withMatchPlayer.Clone(),
// clone intermediate query.
@@ -278,7 +285,7 @@ func (rsq *RoundStatsQuery) Clone() *RoundStatsQuery {
// WithMatchPlayer tells the query-builder to eager-load the nodes that are connected to
// the "match_player" edge. The optional arguments are used to configure the query builder of the edge.
func (rsq *RoundStatsQuery) WithMatchPlayer(opts ...func(*MatchPlayerQuery)) *RoundStatsQuery {
query := &MatchPlayerQuery{config: rsq.config}
query := (&MatchPlayerClient{config: rsq.config}).Query()
for _, opt := range opts {
opt(query)
}
@@ -300,17 +307,13 @@ func (rsq *RoundStatsQuery) WithMatchPlayer(opts ...func(*MatchPlayerQuery)) *Ro
// GroupBy(roundstats.FieldRound).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
//
func (rsq *RoundStatsQuery) GroupBy(field string, fields ...string) *RoundStatsGroupBy {
group := &RoundStatsGroupBy{config: rsq.config}
group.fields = append([]string{field}, fields...)
group.path = func(ctx context.Context) (prev *sql.Selector, err error) {
if err := rsq.prepareQuery(ctx); err != nil {
return nil, err
}
return rsq.sqlQuery(ctx), nil
}
return group
rsq.ctx.Fields = append([]string{field}, fields...)
grbuild := &RoundStatsGroupBy{build: rsq}
grbuild.flds = &rsq.ctx.Fields
grbuild.label = roundstats.Label
grbuild.scan = grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
@@ -325,14 +328,31 @@ func (rsq *RoundStatsQuery) GroupBy(field string, fields ...string) *RoundStatsG
// client.RoundStats.Query().
// Select(roundstats.FieldRound).
// Scan(ctx, &v)
//
func (rsq *RoundStatsQuery) Select(fields ...string) *RoundStatsSelect {
rsq.fields = append(rsq.fields, fields...)
return &RoundStatsSelect{RoundStatsQuery: rsq}
rsq.ctx.Fields = append(rsq.ctx.Fields, fields...)
sbuild := &RoundStatsSelect{RoundStatsQuery: rsq}
sbuild.label = roundstats.Label
sbuild.flds, sbuild.scan = &rsq.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a RoundStatsSelect configured with the given aggregations.
func (rsq *RoundStatsQuery) Aggregate(fns ...AggregateFunc) *RoundStatsSelect {
return rsq.Select().Aggregate(fns...)
}
func (rsq *RoundStatsQuery) prepareQuery(ctx context.Context) error {
for _, f := range rsq.fields {
for _, inter := range rsq.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, rsq); err != nil {
return err
}
}
}
for _, f := range rsq.ctx.Fields {
if !roundstats.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
@@ -347,7 +367,7 @@ func (rsq *RoundStatsQuery) prepareQuery(ctx context.Context) error {
return nil
}
func (rsq *RoundStatsQuery) sqlAll(ctx context.Context) ([]*RoundStats, error) {
func (rsq *RoundStatsQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*RoundStats, error) {
var (
nodes = []*RoundStats{}
withFKs = rsq.withFKs
@@ -362,30 +382,37 @@ func (rsq *RoundStatsQuery) sqlAll(ctx context.Context) ([]*RoundStats, error) {
if withFKs {
_spec.Node.Columns = append(_spec.Node.Columns, roundstats.ForeignKeys...)
}
_spec.ScanValues = func(columns []string) ([]interface{}, error) {
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*RoundStats).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []any) error {
node := &RoundStats{config: rsq.config}
nodes = append(nodes, node)
return node.scanValues(columns)
}
_spec.Assign = func(columns []string, values []interface{}) error {
if len(nodes) == 0 {
return fmt.Errorf("ent: Assign called without calling ScanValues")
}
node := nodes[len(nodes)-1]
node.Edges.loadedTypes = loadedTypes
return node.assignValues(columns, values)
}
if len(rsq.modifiers) > 0 {
_spec.Modifiers = rsq.modifiers
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, rsq.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
if query := rsq.withMatchPlayer; query != nil {
if err := rsq.loadMatchPlayer(ctx, query, nodes, nil,
func(n *RoundStats, e *MatchPlayer) { n.Edges.MatchPlayer = e }); err != nil {
return nil, err
}
}
return nodes, nil
}
func (rsq *RoundStatsQuery) loadMatchPlayer(ctx context.Context, query *MatchPlayerQuery, nodes []*RoundStats, init func(*RoundStats), assign func(*RoundStats, *MatchPlayer)) error {
ids := make([]int, 0, len(nodes))
nodeids := make(map[int][]*RoundStats)
for i := range nodes {
@@ -398,23 +425,24 @@ func (rsq *RoundStatsQuery) sqlAll(ctx context.Context) ([]*RoundStats, error) {
}
nodeids[fk] = append(nodeids[fk], nodes[i])
}
if len(ids) == 0 {
return nil
}
query.Where(matchplayer.IDIn(ids...))
neighbors, err := query.All(ctx)
if err != nil {
return nil, err
return err
}
for _, n := range neighbors {
nodes, ok := nodeids[n.ID]
if !ok {
return nil, fmt.Errorf(`unexpected foreign-key "match_player_round_stats" returned %v`, n.ID)
return fmt.Errorf(`unexpected foreign-key "match_player_round_stats" returned %v`, n.ID)
}
for i := range nodes {
nodes[i].Edges.MatchPlayer = n
assign(nodes[i], n)
}
}
}
return nodes, nil
return nil
}
func (rsq *RoundStatsQuery) sqlCount(ctx context.Context) (int, error) {
@@ -422,38 +450,22 @@ func (rsq *RoundStatsQuery) sqlCount(ctx context.Context) (int, error) {
if len(rsq.modifiers) > 0 {
_spec.Modifiers = rsq.modifiers
}
_spec.Node.Columns = rsq.fields
if len(rsq.fields) > 0 {
_spec.Unique = rsq.unique != nil && *rsq.unique
_spec.Node.Columns = rsq.ctx.Fields
if len(rsq.ctx.Fields) > 0 {
_spec.Unique = rsq.ctx.Unique != nil && *rsq.ctx.Unique
}
return sqlgraph.CountNodes(ctx, rsq.driver, _spec)
}
func (rsq *RoundStatsQuery) sqlExist(ctx context.Context) (bool, error) {
n, err := rsq.sqlCount(ctx)
if err != nil {
return false, fmt.Errorf("ent: check existence: %w", err)
}
return n > 0, nil
}
func (rsq *RoundStatsQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{
Node: &sqlgraph.NodeSpec{
Table: roundstats.Table,
Columns: roundstats.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: roundstats.FieldID,
},
},
From: rsq.sql,
Unique: true,
}
if unique := rsq.unique; unique != nil {
_spec := sqlgraph.NewQuerySpec(roundstats.Table, roundstats.Columns, sqlgraph.NewFieldSpec(roundstats.FieldID, field.TypeInt))
_spec.From = rsq.sql
if unique := rsq.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if rsq.path != nil {
_spec.Unique = true
}
if fields := rsq.fields; len(fields) > 0 {
if fields := rsq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, roundstats.FieldID)
for i := range fields {
@@ -469,10 +481,10 @@ func (rsq *RoundStatsQuery) querySpec() *sqlgraph.QuerySpec {
}
}
}
if limit := rsq.limit; limit != nil {
if limit := rsq.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := rsq.offset; offset != nil {
if offset := rsq.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := rsq.order; len(ps) > 0 {
@@ -488,7 +500,7 @@ func (rsq *RoundStatsQuery) querySpec() *sqlgraph.QuerySpec {
func (rsq *RoundStatsQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(rsq.driver.Dialect())
t1 := builder.Table(roundstats.Table)
columns := rsq.fields
columns := rsq.ctx.Fields
if len(columns) == 0 {
columns = roundstats.Columns
}
@@ -497,7 +509,7 @@ func (rsq *RoundStatsQuery) sqlQuery(ctx context.Context) *sql.Selector {
selector = rsq.sql
selector.Select(selector.Columns(columns...)...)
}
if rsq.unique != nil && *rsq.unique {
if rsq.ctx.Unique != nil && *rsq.ctx.Unique {
selector.Distinct()
}
for _, m := range rsq.modifiers {
@@ -509,12 +521,12 @@ func (rsq *RoundStatsQuery) sqlQuery(ctx context.Context) *sql.Selector {
for _, p := range rsq.order {
p(selector)
}
if offset := rsq.offset; offset != nil {
if offset := rsq.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := rsq.limit; limit != nil {
if limit := rsq.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
@@ -528,12 +540,8 @@ func (rsq *RoundStatsQuery) Modify(modifiers ...func(s *sql.Selector)) *RoundSta
// RoundStatsGroupBy is the group-by builder for RoundStats entities.
type RoundStatsGroupBy struct {
config
fields []string
fns []AggregateFunc
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
selector
build *RoundStatsQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
@@ -542,471 +550,77 @@ func (rsgb *RoundStatsGroupBy) Aggregate(fns ...AggregateFunc) *RoundStatsGroupB
return rsgb
}
// Scan applies the group-by query and scans the result into the given value.
func (rsgb *RoundStatsGroupBy) Scan(ctx context.Context, v interface{}) error {
query, err := rsgb.path(ctx)
if err != nil {
// Scan applies the selector query and scans the result into the given value.
func (rsgb *RoundStatsGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, rsgb.build.ctx, "GroupBy")
if err := rsgb.build.prepareQuery(ctx); err != nil {
return err
}
rsgb.sql = query
return rsgb.sqlScan(ctx, v)
return scanWithInterceptors[*RoundStatsQuery, *RoundStatsGroupBy](ctx, rsgb.build, rsgb, rsgb.build.inters, v)
}
// ScanX is like Scan, but panics if an error occurs.
func (rsgb *RoundStatsGroupBy) ScanX(ctx context.Context, v interface{}) {
if err := rsgb.Scan(ctx, v); err != nil {
panic(err)
func (rsgb *RoundStatsGroupBy) sqlScan(ctx context.Context, root *RoundStatsQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(rsgb.fns))
for _, fn := range rsgb.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*rsgb.flds)+len(rsgb.fns))
for _, f := range *rsgb.flds {
columns = append(columns, selector.C(f))
}
// Strings returns list of strings from group-by.
// It is only allowed when executing a group-by query with one field.
func (rsgb *RoundStatsGroupBy) Strings(ctx context.Context) ([]string, error) {
if len(rsgb.fields) > 1 {
return nil, errors.New("ent: RoundStatsGroupBy.Strings is not achievable when grouping more than 1 field")
columns = append(columns, aggregation...)
selector.Select(columns...)
}
var v []string
if err := rsgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// StringsX is like Strings, but panics if an error occurs.
func (rsgb *RoundStatsGroupBy) StringsX(ctx context.Context) []string {
v, err := rsgb.Strings(ctx)
if err != nil {
panic(err)
}
return v
}
// String returns a single string from a group-by query.
// It is only allowed when executing a group-by query with one field.
func (rsgb *RoundStatsGroupBy) String(ctx context.Context) (_ string, err error) {
var v []string
if v, err = rsgb.Strings(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{roundstats.Label}
default:
err = fmt.Errorf("ent: RoundStatsGroupBy.Strings returned %d results when one was expected", len(v))
}
return
}
// StringX is like String, but panics if an error occurs.
func (rsgb *RoundStatsGroupBy) StringX(ctx context.Context) string {
v, err := rsgb.String(ctx)
if err != nil {
panic(err)
}
return v
}
// Ints returns list of ints from group-by.
// It is only allowed when executing a group-by query with one field.
func (rsgb *RoundStatsGroupBy) Ints(ctx context.Context) ([]int, error) {
if len(rsgb.fields) > 1 {
return nil, errors.New("ent: RoundStatsGroupBy.Ints is not achievable when grouping more than 1 field")
}
var v []int
if err := rsgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// IntsX is like Ints, but panics if an error occurs.
func (rsgb *RoundStatsGroupBy) IntsX(ctx context.Context) []int {
v, err := rsgb.Ints(ctx)
if err != nil {
panic(err)
}
return v
}
// Int returns a single int from a group-by query.
// It is only allowed when executing a group-by query with one field.
func (rsgb *RoundStatsGroupBy) Int(ctx context.Context) (_ int, err error) {
var v []int
if v, err = rsgb.Ints(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{roundstats.Label}
default:
err = fmt.Errorf("ent: RoundStatsGroupBy.Ints returned %d results when one was expected", len(v))
}
return
}
// IntX is like Int, but panics if an error occurs.
func (rsgb *RoundStatsGroupBy) IntX(ctx context.Context) int {
v, err := rsgb.Int(ctx)
if err != nil {
panic(err)
}
return v
}
// Float64s returns list of float64s from group-by.
// It is only allowed when executing a group-by query with one field.
func (rsgb *RoundStatsGroupBy) Float64s(ctx context.Context) ([]float64, error) {
if len(rsgb.fields) > 1 {
return nil, errors.New("ent: RoundStatsGroupBy.Float64s is not achievable when grouping more than 1 field")
}
var v []float64
if err := rsgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// Float64sX is like Float64s, but panics if an error occurs.
func (rsgb *RoundStatsGroupBy) Float64sX(ctx context.Context) []float64 {
v, err := rsgb.Float64s(ctx)
if err != nil {
panic(err)
}
return v
}
// Float64 returns a single float64 from a group-by query.
// It is only allowed when executing a group-by query with one field.
func (rsgb *RoundStatsGroupBy) Float64(ctx context.Context) (_ float64, err error) {
var v []float64
if v, err = rsgb.Float64s(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{roundstats.Label}
default:
err = fmt.Errorf("ent: RoundStatsGroupBy.Float64s returned %d results when one was expected", len(v))
}
return
}
// Float64X is like Float64, but panics if an error occurs.
func (rsgb *RoundStatsGroupBy) Float64X(ctx context.Context) float64 {
v, err := rsgb.Float64(ctx)
if err != nil {
panic(err)
}
return v
}
// Bools returns list of bools from group-by.
// It is only allowed when executing a group-by query with one field.
func (rsgb *RoundStatsGroupBy) Bools(ctx context.Context) ([]bool, error) {
if len(rsgb.fields) > 1 {
return nil, errors.New("ent: RoundStatsGroupBy.Bools is not achievable when grouping more than 1 field")
}
var v []bool
if err := rsgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// BoolsX is like Bools, but panics if an error occurs.
func (rsgb *RoundStatsGroupBy) BoolsX(ctx context.Context) []bool {
v, err := rsgb.Bools(ctx)
if err != nil {
panic(err)
}
return v
}
// Bool returns a single bool from a group-by query.
// It is only allowed when executing a group-by query with one field.
func (rsgb *RoundStatsGroupBy) Bool(ctx context.Context) (_ bool, err error) {
var v []bool
if v, err = rsgb.Bools(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{roundstats.Label}
default:
err = fmt.Errorf("ent: RoundStatsGroupBy.Bools returned %d results when one was expected", len(v))
}
return
}
// BoolX is like Bool, but panics if an error occurs.
func (rsgb *RoundStatsGroupBy) BoolX(ctx context.Context) bool {
v, err := rsgb.Bool(ctx)
if err != nil {
panic(err)
}
return v
}
func (rsgb *RoundStatsGroupBy) sqlScan(ctx context.Context, v interface{}) error {
for _, f := range rsgb.fields {
if !roundstats.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)}
}
}
selector := rsgb.sqlQuery()
selector.GroupBy(selector.Columns(*rsgb.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := rsgb.driver.Query(ctx, query, args, rows); err != nil {
if err := rsgb.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
func (rsgb *RoundStatsGroupBy) sqlQuery() *sql.Selector {
selector := rsgb.sql.Select()
aggregation := make([]string, 0, len(rsgb.fns))
for _, fn := range rsgb.fns {
aggregation = append(aggregation, fn(selector))
}
// If no columns were selected in a custom aggregation function, the default
// selection is the fields used for "group-by", and the aggregation functions.
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(rsgb.fields)+len(rsgb.fns))
for _, f := range rsgb.fields {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
return selector.GroupBy(selector.Columns(rsgb.fields...)...)
}
// RoundStatsSelect is the builder for selecting fields of RoundStats entities.
type RoundStatsSelect struct {
*RoundStatsQuery
// intermediate query (i.e. traversal path).
sql *sql.Selector
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (rss *RoundStatsSelect) Aggregate(fns ...AggregateFunc) *RoundStatsSelect {
rss.fns = append(rss.fns, fns...)
return rss
}
// Scan applies the selector query and scans the result into the given value.
func (rss *RoundStatsSelect) Scan(ctx context.Context, v interface{}) error {
func (rss *RoundStatsSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, rss.ctx, "Select")
if err := rss.prepareQuery(ctx); err != nil {
return err
}
rss.sql = rss.RoundStatsQuery.sqlQuery(ctx)
return rss.sqlScan(ctx, v)
return scanWithInterceptors[*RoundStatsQuery, *RoundStatsSelect](ctx, rss.RoundStatsQuery, rss, rss.inters, v)
}
// ScanX is like Scan, but panics if an error occurs.
func (rss *RoundStatsSelect) ScanX(ctx context.Context, v interface{}) {
if err := rss.Scan(ctx, v); err != nil {
panic(err)
func (rss *RoundStatsSelect) sqlScan(ctx context.Context, root *RoundStatsQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(rss.fns))
for _, fn := range rss.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*rss.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
// Strings returns list of strings from a selector. It is only allowed when selecting one field.
func (rss *RoundStatsSelect) Strings(ctx context.Context) ([]string, error) {
if len(rss.fields) > 1 {
return nil, errors.New("ent: RoundStatsSelect.Strings is not achievable when selecting more than 1 field")
}
var v []string
if err := rss.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// StringsX is like Strings, but panics if an error occurs.
func (rss *RoundStatsSelect) StringsX(ctx context.Context) []string {
v, err := rss.Strings(ctx)
if err != nil {
panic(err)
}
return v
}
// String returns a single string from a selector. It is only allowed when selecting one field.
func (rss *RoundStatsSelect) String(ctx context.Context) (_ string, err error) {
var v []string
if v, err = rss.Strings(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{roundstats.Label}
default:
err = fmt.Errorf("ent: RoundStatsSelect.Strings returned %d results when one was expected", len(v))
}
return
}
// StringX is like String, but panics if an error occurs.
func (rss *RoundStatsSelect) StringX(ctx context.Context) string {
v, err := rss.String(ctx)
if err != nil {
panic(err)
}
return v
}
// Ints returns list of ints from a selector. It is only allowed when selecting one field.
func (rss *RoundStatsSelect) Ints(ctx context.Context) ([]int, error) {
if len(rss.fields) > 1 {
return nil, errors.New("ent: RoundStatsSelect.Ints is not achievable when selecting more than 1 field")
}
var v []int
if err := rss.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// IntsX is like Ints, but panics if an error occurs.
func (rss *RoundStatsSelect) IntsX(ctx context.Context) []int {
v, err := rss.Ints(ctx)
if err != nil {
panic(err)
}
return v
}
// Int returns a single int from a selector. It is only allowed when selecting one field.
func (rss *RoundStatsSelect) Int(ctx context.Context) (_ int, err error) {
var v []int
if v, err = rss.Ints(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{roundstats.Label}
default:
err = fmt.Errorf("ent: RoundStatsSelect.Ints returned %d results when one was expected", len(v))
}
return
}
// IntX is like Int, but panics if an error occurs.
func (rss *RoundStatsSelect) IntX(ctx context.Context) int {
v, err := rss.Int(ctx)
if err != nil {
panic(err)
}
return v
}
// Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
func (rss *RoundStatsSelect) Float64s(ctx context.Context) ([]float64, error) {
if len(rss.fields) > 1 {
return nil, errors.New("ent: RoundStatsSelect.Float64s is not achievable when selecting more than 1 field")
}
var v []float64
if err := rss.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// Float64sX is like Float64s, but panics if an error occurs.
func (rss *RoundStatsSelect) Float64sX(ctx context.Context) []float64 {
v, err := rss.Float64s(ctx)
if err != nil {
panic(err)
}
return v
}
// Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
func (rss *RoundStatsSelect) Float64(ctx context.Context) (_ float64, err error) {
var v []float64
if v, err = rss.Float64s(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{roundstats.Label}
default:
err = fmt.Errorf("ent: RoundStatsSelect.Float64s returned %d results when one was expected", len(v))
}
return
}
// Float64X is like Float64, but panics if an error occurs.
func (rss *RoundStatsSelect) Float64X(ctx context.Context) float64 {
v, err := rss.Float64(ctx)
if err != nil {
panic(err)
}
return v
}
// Bools returns list of bools from a selector. It is only allowed when selecting one field.
func (rss *RoundStatsSelect) Bools(ctx context.Context) ([]bool, error) {
if len(rss.fields) > 1 {
return nil, errors.New("ent: RoundStatsSelect.Bools is not achievable when selecting more than 1 field")
}
var v []bool
if err := rss.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// BoolsX is like Bools, but panics if an error occurs.
func (rss *RoundStatsSelect) BoolsX(ctx context.Context) []bool {
v, err := rss.Bools(ctx)
if err != nil {
panic(err)
}
return v
}
// Bool returns a single bool from a selector. It is only allowed when selecting one field.
func (rss *RoundStatsSelect) Bool(ctx context.Context) (_ bool, err error) {
var v []bool
if v, err = rss.Bools(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{roundstats.Label}
default:
err = fmt.Errorf("ent: RoundStatsSelect.Bools returned %d results when one was expected", len(v))
}
return
}
// BoolX is like Bool, but panics if an error occurs.
func (rss *RoundStatsSelect) BoolX(ctx context.Context) bool {
v, err := rss.Bool(ctx)
if err != nil {
panic(err)
}
return v
}
func (rss *RoundStatsSelect) sqlScan(ctx context.Context, v interface{}) error {
rows := &sql.Rows{}
query, args := rss.sql.Query()
query, args := selector.Query()
if err := rss.driver.Query(ctx, query, args, rows); err != nil {
return err
}

View File

@@ -1,18 +1,18 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"csgowtfd/ent/matchplayer"
"csgowtfd/ent/predicate"
"csgowtfd/ent/roundstats"
"errors"
"fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"somegit.dev/csgowtf/csgowtfd/ent/matchplayer"
"somegit.dev/csgowtf/csgowtfd/ent/predicate"
"somegit.dev/csgowtf/csgowtfd/ent/roundstats"
)
// RoundStatsUpdate is the builder for updating RoundStats entities.
@@ -20,6 +20,7 @@ type RoundStatsUpdate struct {
config
hooks []Hook
mutation *RoundStatsMutation
modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the RoundStatsUpdate builder.
@@ -112,34 +113,7 @@ func (rsu *RoundStatsUpdate) ClearMatchPlayer() *RoundStatsUpdate {
// Save executes the query and returns the number of nodes affected by the update operation.
func (rsu *RoundStatsUpdate) Save(ctx context.Context) (int, error) {
var (
err error
affected int
)
if len(rsu.hooks) == 0 {
affected, err = rsu.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*RoundStatsMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
rsu.mutation = mutation
affected, err = rsu.sqlSave(ctx)
mutation.done = true
return affected, err
})
for i := len(rsu.hooks) - 1; i >= 0; i-- {
if rsu.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = rsu.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, rsu.mutation); err != nil {
return 0, err
}
}
return affected, err
return withHooks(ctx, rsu.sqlSave, rsu.mutation, rsu.hooks)
}
// SaveX is like Save, but panics if an error occurs.
@@ -164,17 +138,14 @@ func (rsu *RoundStatsUpdate) ExecX(ctx context.Context) {
}
}
func (rsu *RoundStatsUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: roundstats.Table,
Columns: roundstats.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: roundstats.FieldID,
},
},
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (rsu *RoundStatsUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *RoundStatsUpdate {
rsu.modifiers = append(rsu.modifiers, modifiers...)
return rsu
}
func (rsu *RoundStatsUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := sqlgraph.NewUpdateSpec(roundstats.Table, roundstats.Columns, sqlgraph.NewFieldSpec(roundstats.FieldID, field.TypeInt))
if ps := rsu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
@@ -183,60 +154,28 @@ func (rsu *RoundStatsUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
}
if value, ok := rsu.mutation.Round(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: roundstats.FieldRound,
})
_spec.SetField(roundstats.FieldRound, field.TypeUint, value)
}
if value, ok := rsu.mutation.AddedRound(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: roundstats.FieldRound,
})
_spec.AddField(roundstats.FieldRound, field.TypeUint, value)
}
if value, ok := rsu.mutation.Bank(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: roundstats.FieldBank,
})
_spec.SetField(roundstats.FieldBank, field.TypeUint, value)
}
if value, ok := rsu.mutation.AddedBank(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: roundstats.FieldBank,
})
_spec.AddField(roundstats.FieldBank, field.TypeUint, value)
}
if value, ok := rsu.mutation.Equipment(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: roundstats.FieldEquipment,
})
_spec.SetField(roundstats.FieldEquipment, field.TypeUint, value)
}
if value, ok := rsu.mutation.AddedEquipment(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: roundstats.FieldEquipment,
})
_spec.AddField(roundstats.FieldEquipment, field.TypeUint, value)
}
if value, ok := rsu.mutation.Spent(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: roundstats.FieldSpent,
})
_spec.SetField(roundstats.FieldSpent, field.TypeUint, value)
}
if value, ok := rsu.mutation.AddedSpent(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: roundstats.FieldSpent,
})
_spec.AddField(roundstats.FieldSpent, field.TypeUint, value)
}
if rsu.mutation.MatchPlayerCleared() {
edge := &sqlgraph.EdgeSpec{
@@ -246,10 +185,7 @@ func (rsu *RoundStatsUpdate) sqlSave(ctx context.Context) (n int, err error) {
Columns: []string{roundstats.MatchPlayerColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
@@ -262,10 +198,7 @@ func (rsu *RoundStatsUpdate) sqlSave(ctx context.Context) (n int, err error) {
Columns: []string{roundstats.MatchPlayerColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
@@ -273,14 +206,16 @@ func (rsu *RoundStatsUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_spec.AddModifiers(rsu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, rsu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{roundstats.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
rsu.mutation.done = true
return n, nil
}
@@ -290,6 +225,7 @@ type RoundStatsUpdateOne struct {
fields []string
hooks []Hook
mutation *RoundStatsMutation
modifiers []func(*sql.UpdateBuilder)
}
// SetRound sets the "round" field.
@@ -374,6 +310,12 @@ func (rsuo *RoundStatsUpdateOne) ClearMatchPlayer() *RoundStatsUpdateOne {
return rsuo
}
// Where appends a list predicates to the RoundStatsUpdate builder.
func (rsuo *RoundStatsUpdateOne) Where(ps ...predicate.RoundStats) *RoundStatsUpdateOne {
rsuo.mutation.Where(ps...)
return rsuo
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (rsuo *RoundStatsUpdateOne) Select(field string, fields ...string) *RoundStatsUpdateOne {
@@ -383,34 +325,7 @@ func (rsuo *RoundStatsUpdateOne) Select(field string, fields ...string) *RoundSt
// Save executes the query and returns the updated RoundStats entity.
func (rsuo *RoundStatsUpdateOne) Save(ctx context.Context) (*RoundStats, error) {
var (
err error
node *RoundStats
)
if len(rsuo.hooks) == 0 {
node, err = rsuo.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*RoundStatsMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
rsuo.mutation = mutation
node, err = rsuo.sqlSave(ctx)
mutation.done = true
return node, err
})
for i := len(rsuo.hooks) - 1; i >= 0; i-- {
if rsuo.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = rsuo.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, rsuo.mutation); err != nil {
return nil, err
}
}
return node, err
return withHooks(ctx, rsuo.sqlSave, rsuo.mutation, rsuo.hooks)
}
// SaveX is like Save, but panics if an error occurs.
@@ -435,17 +350,14 @@ func (rsuo *RoundStatsUpdateOne) ExecX(ctx context.Context) {
}
}
func (rsuo *RoundStatsUpdateOne) sqlSave(ctx context.Context) (_node *RoundStats, err error) {
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: roundstats.Table,
Columns: roundstats.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: roundstats.FieldID,
},
},
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (rsuo *RoundStatsUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *RoundStatsUpdateOne {
rsuo.modifiers = append(rsuo.modifiers, modifiers...)
return rsuo
}
func (rsuo *RoundStatsUpdateOne) sqlSave(ctx context.Context) (_node *RoundStats, err error) {
_spec := sqlgraph.NewUpdateSpec(roundstats.Table, roundstats.Columns, sqlgraph.NewFieldSpec(roundstats.FieldID, field.TypeInt))
id, ok := rsuo.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "RoundStats.id" for update`)}
@@ -471,60 +383,28 @@ func (rsuo *RoundStatsUpdateOne) sqlSave(ctx context.Context) (_node *RoundStats
}
}
if value, ok := rsuo.mutation.Round(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: roundstats.FieldRound,
})
_spec.SetField(roundstats.FieldRound, field.TypeUint, value)
}
if value, ok := rsuo.mutation.AddedRound(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: roundstats.FieldRound,
})
_spec.AddField(roundstats.FieldRound, field.TypeUint, value)
}
if value, ok := rsuo.mutation.Bank(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: roundstats.FieldBank,
})
_spec.SetField(roundstats.FieldBank, field.TypeUint, value)
}
if value, ok := rsuo.mutation.AddedBank(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: roundstats.FieldBank,
})
_spec.AddField(roundstats.FieldBank, field.TypeUint, value)
}
if value, ok := rsuo.mutation.Equipment(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: roundstats.FieldEquipment,
})
_spec.SetField(roundstats.FieldEquipment, field.TypeUint, value)
}
if value, ok := rsuo.mutation.AddedEquipment(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: roundstats.FieldEquipment,
})
_spec.AddField(roundstats.FieldEquipment, field.TypeUint, value)
}
if value, ok := rsuo.mutation.Spent(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: roundstats.FieldSpent,
})
_spec.SetField(roundstats.FieldSpent, field.TypeUint, value)
}
if value, ok := rsuo.mutation.AddedSpent(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: roundstats.FieldSpent,
})
_spec.AddField(roundstats.FieldSpent, field.TypeUint, value)
}
if rsuo.mutation.MatchPlayerCleared() {
edge := &sqlgraph.EdgeSpec{
@@ -534,10 +414,7 @@ func (rsuo *RoundStatsUpdateOne) sqlSave(ctx context.Context) (_node *RoundStats
Columns: []string{roundstats.MatchPlayerColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
@@ -550,10 +427,7 @@ func (rsuo *RoundStatsUpdateOne) sqlSave(ctx context.Context) (_node *RoundStats
Columns: []string{roundstats.MatchPlayerColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
@@ -561,6 +435,7 @@ func (rsuo *RoundStatsUpdateOne) sqlSave(ctx context.Context) (_node *RoundStats
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_spec.AddModifiers(rsuo.modifiers...)
_node = &RoundStats{config: rsuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
@@ -568,9 +443,10 @@ func (rsuo *RoundStatsUpdateOne) sqlSave(ctx context.Context) (_node *RoundStats
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{roundstats.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
rsuo.mutation.done = true
return _node, nil
}

View File

@@ -1,12 +1,13 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"csgowtfd/ent/match"
"csgowtfd/ent/player"
"csgowtfd/ent/schema"
"time"
"somegit.dev/csgowtf/csgowtfd/ent/match"
"somegit.dev/csgowtf/csgowtfd/ent/player"
"somegit.dev/csgowtf/csgowtfd/ent/schema"
)
// The init function reads all schema descriptors with runtime code

View File

@@ -1,10 +1,10 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package runtime
// The schema-stitching logic is generated in csgowtfd/ent/runtime.go
// The schema-stitching logic is generated in somegit.dev/csgowtf/csgowtfd/ent/runtime.go
const (
Version = "v0.10.0" // Version of ent codegen.
Sum = "h1:9cBomE1fh+WX34DPYQL7tDNAIvhKa3tXvwxuLyhYCMo=" // Sum of ent codegen.
Version = "v0.12.3" // Version of ent codegen.
Sum = "h1:N5lO2EOrHpCH5HYfiMOCHYbo+oh5M8GjT0/cx5x6xkk=" // Sum of ent codegen.
)

View File

@@ -28,6 +28,7 @@ func (Match) Fields() []ent.Field {
field.Bool("vac_present").Default(false),
field.Bool("gameban_present").Default(false),
field.Bytes("decryption_key").Optional(),
field.Float("tick_rate").Optional(),
}
}

View File

@@ -46,6 +46,7 @@ func (MatchPlayer) Fields() []ent.Field {
field.Uint64("match_stats").Optional(),
field.Uint64("player_stats").Optional(),
field.Int("flash_assists").Optional(),
field.Float("avg_ping").Optional(),
}
}

View File

@@ -1,14 +1,15 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"csgowtfd/ent/matchplayer"
"csgowtfd/ent/spray"
"fmt"
"strings"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"somegit.dev/csgowtf/csgowtfd/ent/matchplayer"
"somegit.dev/csgowtf/csgowtfd/ent/spray"
)
// Spray is the model entity for the Spray schema.
@@ -24,6 +25,7 @@ type Spray struct {
// The values are being populated by the SprayQuery when eager-loading is set.
Edges SprayEdges `json:"edges"`
match_player_spray *int
selectValues sql.SelectValues
}
// SprayEdges holds the relations/edges for other nodes in the graph.
@@ -40,8 +42,7 @@ type SprayEdges struct {
func (e SprayEdges) MatchPlayersOrErr() (*MatchPlayer, error) {
if e.loadedTypes[0] {
if e.MatchPlayers == nil {
// The edge match_players was loaded in eager-loading,
// but was not found.
// Edge was loaded but was not found.
return nil, &NotFoundError{label: matchplayer.Label}
}
return e.MatchPlayers, nil
@@ -50,8 +51,8 @@ func (e SprayEdges) MatchPlayersOrErr() (*MatchPlayer, error) {
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Spray) scanValues(columns []string) ([]interface{}, error) {
values := make([]interface{}, len(columns))
func (*Spray) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case spray.FieldSpray:
@@ -61,7 +62,7 @@ func (*Spray) scanValues(columns []string) ([]interface{}, error) {
case spray.ForeignKeys[0]: // match_player_spray
values[i] = new(sql.NullInt64)
default:
return nil, fmt.Errorf("unexpected column %q for type Spray", columns[i])
values[i] = new(sql.UnknownType)
}
}
return values, nil
@@ -69,7 +70,7 @@ func (*Spray) scanValues(columns []string) ([]interface{}, error) {
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the Spray fields.
func (s *Spray) assignValues(columns []string, values []interface{}) error {
func (s *Spray) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
@@ -100,31 +101,39 @@ func (s *Spray) assignValues(columns []string, values []interface{}) error {
s.match_player_spray = new(int)
*s.match_player_spray = int(value.Int64)
}
default:
s.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the Spray.
// This includes values selected through modifiers, order, etc.
func (s *Spray) Value(name string) (ent.Value, error) {
return s.selectValues.Get(name)
}
// QueryMatchPlayers queries the "match_players" edge of the Spray entity.
func (s *Spray) QueryMatchPlayers() *MatchPlayerQuery {
return (&SprayClient{config: s.config}).QueryMatchPlayers(s)
return NewSprayClient(s.config).QueryMatchPlayers(s)
}
// Update returns a builder for updating this Spray.
// Note that you need to call Spray.Unwrap() before calling this method if this Spray
// was returned from a transaction, and the transaction was committed or rolled back.
func (s *Spray) Update() *SprayUpdateOne {
return (&SprayClient{config: s.config}).UpdateOne(s)
return NewSprayClient(s.config).UpdateOne(s)
}
// Unwrap unwraps the Spray 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 (s *Spray) Unwrap() *Spray {
tx, ok := s.config.driver.(*txDriver)
_tx, ok := s.config.driver.(*txDriver)
if !ok {
panic("ent: Spray is not a transactional entity")
}
s.config.driver = tx.drv
s.config.driver = _tx.drv
return s
}
@@ -132,10 +141,11 @@ func (s *Spray) Unwrap() *Spray {
func (s *Spray) String() string {
var builder strings.Builder
builder.WriteString("Spray(")
builder.WriteString(fmt.Sprintf("id=%v", s.ID))
builder.WriteString(", weapon=")
builder.WriteString(fmt.Sprintf("id=%v, ", s.ID))
builder.WriteString("weapon=")
builder.WriteString(fmt.Sprintf("%v", s.Weapon))
builder.WriteString(", spray=")
builder.WriteString(", ")
builder.WriteString("spray=")
builder.WriteString(fmt.Sprintf("%v", s.Spray))
builder.WriteByte(')')
return builder.String()
@@ -143,9 +153,3 @@ func (s *Spray) String() string {
// Sprays is a parsable slice of Spray.
type Sprays []*Spray
func (s Sprays) config(cfg config) {
for _i := range s {
s[_i].config = cfg
}
}

View File

@@ -1,7 +1,12 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package spray
import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
const (
// Label holds the string label denoting the spray type in the database.
Label = "spray"
@@ -51,3 +56,30 @@ func ValidColumn(column string) bool {
}
return false
}
// OrderOption defines the ordering options for the Spray queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByWeapon orders the results by the weapon field.
func ByWeapon(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldWeapon, opts...).ToFunc()
}
// ByMatchPlayersField orders the results by match_players field.
func ByMatchPlayersField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newMatchPlayersStep(), sql.OrderByField(field, opts...))
}
}
func newMatchPlayersStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(MatchPlayersInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, MatchPlayersTable, MatchPlayersColumn),
)
}

View File

@@ -1,261 +1,146 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package spray
import (
"csgowtfd/ent/predicate"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"somegit.dev/csgowtf/csgowtfd/ent/predicate"
)
// ID filters vertices based on their ID field.
func ID(id int) predicate.Spray {
return predicate.Spray(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldID), id))
})
return predicate.Spray(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id int) predicate.Spray {
return predicate.Spray(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldID), id))
})
return predicate.Spray(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id int) predicate.Spray {
return predicate.Spray(func(s *sql.Selector) {
s.Where(sql.NEQ(s.C(FieldID), id))
})
return predicate.Spray(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int) predicate.Spray {
return predicate.Spray(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...))
})
return predicate.Spray(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int) predicate.Spray {
return predicate.Spray(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...))
})
return predicate.Spray(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id int) predicate.Spray {
return predicate.Spray(func(s *sql.Selector) {
s.Where(sql.GT(s.C(FieldID), id))
})
return predicate.Spray(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id int) predicate.Spray {
return predicate.Spray(func(s *sql.Selector) {
s.Where(sql.GTE(s.C(FieldID), id))
})
return predicate.Spray(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id int) predicate.Spray {
return predicate.Spray(func(s *sql.Selector) {
s.Where(sql.LT(s.C(FieldID), id))
})
return predicate.Spray(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id int) predicate.Spray {
return predicate.Spray(func(s *sql.Selector) {
s.Where(sql.LTE(s.C(FieldID), id))
})
return predicate.Spray(sql.FieldLTE(FieldID, id))
}
// Weapon applies equality check predicate on the "weapon" field. It's identical to WeaponEQ.
func Weapon(v int) predicate.Spray {
return predicate.Spray(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldWeapon), v))
})
return predicate.Spray(sql.FieldEQ(FieldWeapon, v))
}
// Spray applies equality check predicate on the "spray" field. It's identical to SprayEQ.
func Spray(v []byte) predicate.Spray {
return predicate.Spray(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldSpray), v))
})
return predicate.Spray(sql.FieldEQ(FieldSpray, v))
}
// WeaponEQ applies the EQ predicate on the "weapon" field.
func WeaponEQ(v int) predicate.Spray {
return predicate.Spray(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldWeapon), v))
})
return predicate.Spray(sql.FieldEQ(FieldWeapon, v))
}
// WeaponNEQ applies the NEQ predicate on the "weapon" field.
func WeaponNEQ(v int) predicate.Spray {
return predicate.Spray(func(s *sql.Selector) {
s.Where(sql.NEQ(s.C(FieldWeapon), v))
})
return predicate.Spray(sql.FieldNEQ(FieldWeapon, v))
}
// WeaponIn applies the In predicate on the "weapon" field.
func WeaponIn(vs ...int) predicate.Spray {
v := make([]interface{}, len(vs))
for i := range v {
v[i] = vs[i]
}
return predicate.Spray(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(FieldWeapon), v...))
})
return predicate.Spray(sql.FieldIn(FieldWeapon, vs...))
}
// WeaponNotIn applies the NotIn predicate on the "weapon" field.
func WeaponNotIn(vs ...int) predicate.Spray {
v := make([]interface{}, len(vs))
for i := range v {
v[i] = vs[i]
}
return predicate.Spray(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(FieldWeapon), v...))
})
return predicate.Spray(sql.FieldNotIn(FieldWeapon, vs...))
}
// WeaponGT applies the GT predicate on the "weapon" field.
func WeaponGT(v int) predicate.Spray {
return predicate.Spray(func(s *sql.Selector) {
s.Where(sql.GT(s.C(FieldWeapon), v))
})
return predicate.Spray(sql.FieldGT(FieldWeapon, v))
}
// WeaponGTE applies the GTE predicate on the "weapon" field.
func WeaponGTE(v int) predicate.Spray {
return predicate.Spray(func(s *sql.Selector) {
s.Where(sql.GTE(s.C(FieldWeapon), v))
})
return predicate.Spray(sql.FieldGTE(FieldWeapon, v))
}
// WeaponLT applies the LT predicate on the "weapon" field.
func WeaponLT(v int) predicate.Spray {
return predicate.Spray(func(s *sql.Selector) {
s.Where(sql.LT(s.C(FieldWeapon), v))
})
return predicate.Spray(sql.FieldLT(FieldWeapon, v))
}
// WeaponLTE applies the LTE predicate on the "weapon" field.
func WeaponLTE(v int) predicate.Spray {
return predicate.Spray(func(s *sql.Selector) {
s.Where(sql.LTE(s.C(FieldWeapon), v))
})
return predicate.Spray(sql.FieldLTE(FieldWeapon, v))
}
// SprayEQ applies the EQ predicate on the "spray" field.
func SprayEQ(v []byte) predicate.Spray {
return predicate.Spray(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldSpray), v))
})
return predicate.Spray(sql.FieldEQ(FieldSpray, v))
}
// SprayNEQ applies the NEQ predicate on the "spray" field.
func SprayNEQ(v []byte) predicate.Spray {
return predicate.Spray(func(s *sql.Selector) {
s.Where(sql.NEQ(s.C(FieldSpray), v))
})
return predicate.Spray(sql.FieldNEQ(FieldSpray, v))
}
// SprayIn applies the In predicate on the "spray" field.
func SprayIn(vs ...[]byte) predicate.Spray {
v := make([]interface{}, len(vs))
for i := range v {
v[i] = vs[i]
}
return predicate.Spray(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(FieldSpray), v...))
})
return predicate.Spray(sql.FieldIn(FieldSpray, vs...))
}
// SprayNotIn applies the NotIn predicate on the "spray" field.
func SprayNotIn(vs ...[]byte) predicate.Spray {
v := make([]interface{}, len(vs))
for i := range v {
v[i] = vs[i]
}
return predicate.Spray(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(FieldSpray), v...))
})
return predicate.Spray(sql.FieldNotIn(FieldSpray, vs...))
}
// SprayGT applies the GT predicate on the "spray" field.
func SprayGT(v []byte) predicate.Spray {
return predicate.Spray(func(s *sql.Selector) {
s.Where(sql.GT(s.C(FieldSpray), v))
})
return predicate.Spray(sql.FieldGT(FieldSpray, v))
}
// SprayGTE applies the GTE predicate on the "spray" field.
func SprayGTE(v []byte) predicate.Spray {
return predicate.Spray(func(s *sql.Selector) {
s.Where(sql.GTE(s.C(FieldSpray), v))
})
return predicate.Spray(sql.FieldGTE(FieldSpray, v))
}
// SprayLT applies the LT predicate on the "spray" field.
func SprayLT(v []byte) predicate.Spray {
return predicate.Spray(func(s *sql.Selector) {
s.Where(sql.LT(s.C(FieldSpray), v))
})
return predicate.Spray(sql.FieldLT(FieldSpray, v))
}
// SprayLTE applies the LTE predicate on the "spray" field.
func SprayLTE(v []byte) predicate.Spray {
return predicate.Spray(func(s *sql.Selector) {
s.Where(sql.LTE(s.C(FieldSpray), v))
})
return predicate.Spray(sql.FieldLTE(FieldSpray, v))
}
// HasMatchPlayers applies the HasEdge predicate on the "match_players" edge.
@@ -263,7 +148,6 @@ func HasMatchPlayers() predicate.Spray {
return predicate.Spray(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(MatchPlayersTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, MatchPlayersTable, MatchPlayersColumn),
)
sqlgraph.HasNeighbors(s, step)
@@ -273,11 +157,7 @@ func HasMatchPlayers() predicate.Spray {
// HasMatchPlayersWith applies the HasEdge predicate on the "match_players" edge with a given conditions (other predicates).
func HasMatchPlayersWith(preds ...predicate.MatchPlayer) predicate.Spray {
return predicate.Spray(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(MatchPlayersInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, MatchPlayersTable, MatchPlayersColumn),
)
step := newMatchPlayersStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)

View File

@@ -1,16 +1,16 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"csgowtfd/ent/matchplayer"
"csgowtfd/ent/spray"
"errors"
"fmt"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"somegit.dev/csgowtf/csgowtfd/ent/matchplayer"
"somegit.dev/csgowtf/csgowtfd/ent/spray"
)
// SprayCreate is the builder for creating a Spray entity.
@@ -58,43 +58,7 @@ func (sc *SprayCreate) Mutation() *SprayMutation {
// Save creates the Spray in the database.
func (sc *SprayCreate) Save(ctx context.Context) (*Spray, error) {
var (
err error
node *Spray
)
if len(sc.hooks) == 0 {
if err = sc.check(); err != nil {
return nil, err
}
node, err = sc.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*SprayMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = sc.check(); err != nil {
return nil, err
}
sc.mutation = mutation
if node, err = sc.sqlSave(ctx); err != nil {
return nil, err
}
mutation.id = &node.ID
mutation.done = true
return node, err
})
for i := len(sc.hooks) - 1; i >= 0; i-- {
if sc.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = sc.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, sc.mutation); err != nil {
return nil, err
}
}
return node, err
return withHooks(ctx, sc.sqlSave, sc.mutation, sc.hooks)
}
// SaveX calls Save and panics if Save returns an error.
@@ -131,43 +95,34 @@ func (sc *SprayCreate) check() error {
}
func (sc *SprayCreate) sqlSave(ctx context.Context) (*Spray, error) {
if err := sc.check(); err != nil {
return nil, err
}
_node, _spec := sc.createSpec()
if err := sqlgraph.CreateNode(ctx, sc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
id := _spec.ID.Value.(int64)
_node.ID = int(id)
sc.mutation.id = &_node.ID
sc.mutation.done = true
return _node, nil
}
func (sc *SprayCreate) createSpec() (*Spray, *sqlgraph.CreateSpec) {
var (
_node = &Spray{config: sc.config}
_spec = &sqlgraph.CreateSpec{
Table: spray.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: spray.FieldID,
},
}
_spec = sqlgraph.NewCreateSpec(spray.Table, sqlgraph.NewFieldSpec(spray.FieldID, field.TypeInt))
)
if value, ok := sc.mutation.Weapon(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: spray.FieldWeapon,
})
_spec.SetField(spray.FieldWeapon, field.TypeInt, value)
_node.Weapon = value
}
if value, ok := sc.mutation.Spray(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeBytes,
Value: value,
Column: spray.FieldSpray,
})
_spec.SetField(spray.FieldSpray, field.TypeBytes, value)
_node.Spray = value
}
if nodes := sc.mutation.MatchPlayersIDs(); len(nodes) > 0 {
@@ -178,10 +133,7 @@ func (sc *SprayCreate) createSpec() (*Spray, *sqlgraph.CreateSpec) {
Columns: []string{spray.MatchPlayersColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
@@ -216,8 +168,8 @@ func (scb *SprayCreateBulk) Save(ctx context.Context) ([]*Spray, error) {
return nil, err
}
builder.mutation = mutation
nodes[i], specs[i] = builder.createSpec()
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, scb.builders[i+1].mutation)
} else {
@@ -225,7 +177,7 @@ func (scb *SprayCreateBulk) Save(ctx context.Context) ([]*Spray, error) {
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, scb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
@@ -233,11 +185,11 @@ func (scb *SprayCreateBulk) Save(ctx context.Context) ([]*Spray, error) {
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)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -1,16 +1,15 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"csgowtfd/ent/predicate"
"csgowtfd/ent/spray"
"fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"somegit.dev/csgowtf/csgowtfd/ent/predicate"
"somegit.dev/csgowtf/csgowtfd/ent/spray"
)
// SprayDelete is the builder for deleting a Spray entity.
@@ -28,34 +27,7 @@ func (sd *SprayDelete) Where(ps ...predicate.Spray) *SprayDelete {
// Exec executes the deletion query and returns how many vertices were deleted.
func (sd *SprayDelete) Exec(ctx context.Context) (int, error) {
var (
err error
affected int
)
if len(sd.hooks) == 0 {
affected, err = sd.sqlExec(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*SprayMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
sd.mutation = mutation
affected, err = sd.sqlExec(ctx)
mutation.done = true
return affected, err
})
for i := len(sd.hooks) - 1; i >= 0; i-- {
if sd.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = sd.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, sd.mutation); err != nil {
return 0, err
}
}
return affected, err
return withHooks(ctx, sd.sqlExec, sd.mutation, sd.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
@@ -68,15 +40,7 @@ func (sd *SprayDelete) ExecX(ctx context.Context) int {
}
func (sd *SprayDelete) sqlExec(ctx context.Context) (int, error) {
_spec := &sqlgraph.DeleteSpec{
Node: &sqlgraph.NodeSpec{
Table: spray.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: spray.FieldID,
},
},
}
_spec := sqlgraph.NewDeleteSpec(spray.Table, sqlgraph.NewFieldSpec(spray.FieldID, field.TypeInt))
if ps := sd.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
@@ -84,7 +48,12 @@ func (sd *SprayDelete) sqlExec(ctx context.Context) (int, error) {
}
}
}
return sqlgraph.DeleteNodes(ctx, sd.driver, _spec)
affected, err := sqlgraph.DeleteNodes(ctx, sd.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
sd.mutation.done = true
return affected, err
}
// SprayDeleteOne is the builder for deleting a single Spray entity.
@@ -92,6 +61,12 @@ type SprayDeleteOne struct {
sd *SprayDelete
}
// Where appends a list predicates to the SprayDelete builder.
func (sdo *SprayDeleteOne) Where(ps ...predicate.Spray) *SprayDeleteOne {
sdo.sd.mutation.Where(ps...)
return sdo
}
// Exec executes the deletion query.
func (sdo *SprayDeleteOne) Exec(ctx context.Context) error {
n, err := sdo.sd.Exec(ctx)
@@ -107,5 +82,7 @@ func (sdo *SprayDeleteOne) Exec(ctx context.Context) error {
// ExecX is like Exec, but panics if an error occurs.
func (sdo *SprayDeleteOne) ExecX(ctx context.Context) {
sdo.sd.ExecX(ctx)
if err := sdo.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -1,34 +1,30 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"csgowtfd/ent/matchplayer"
"csgowtfd/ent/predicate"
"csgowtfd/ent/spray"
"errors"
"fmt"
"math"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"somegit.dev/csgowtf/csgowtfd/ent/matchplayer"
"somegit.dev/csgowtf/csgowtfd/ent/predicate"
"somegit.dev/csgowtf/csgowtfd/ent/spray"
)
// SprayQuery is the builder for querying Spray entities.
type SprayQuery struct {
config
limit *int
offset *int
unique *bool
order []OrderFunc
fields []string
ctx *QueryContext
order []spray.OrderOption
inters []Interceptor
predicates []predicate.Spray
// eager-loading edges.
withMatchPlayers *MatchPlayerQuery
withFKs bool
modifiers []func(s *sql.Selector)
modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -40,34 +36,34 @@ func (sq *SprayQuery) Where(ps ...predicate.Spray) *SprayQuery {
return sq
}
// Limit adds a limit step to the query.
// Limit the number of records to be returned by this query.
func (sq *SprayQuery) Limit(limit int) *SprayQuery {
sq.limit = &limit
sq.ctx.Limit = &limit
return sq
}
// Offset adds an offset step to the query.
// Offset to start from.
func (sq *SprayQuery) Offset(offset int) *SprayQuery {
sq.offset = &offset
sq.ctx.Offset = &offset
return sq
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (sq *SprayQuery) Unique(unique bool) *SprayQuery {
sq.unique = &unique
sq.ctx.Unique = &unique
return sq
}
// Order adds an order step to the query.
func (sq *SprayQuery) Order(o ...OrderFunc) *SprayQuery {
// Order specifies how the records should be ordered.
func (sq *SprayQuery) Order(o ...spray.OrderOption) *SprayQuery {
sq.order = append(sq.order, o...)
return sq
}
// QueryMatchPlayers chains the current query on the "match_players" edge.
func (sq *SprayQuery) QueryMatchPlayers() *MatchPlayerQuery {
query := &MatchPlayerQuery{config: sq.config}
query := (&MatchPlayerClient{config: sq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := sq.prepareQuery(ctx); err != nil {
return nil, err
@@ -90,7 +86,7 @@ func (sq *SprayQuery) QueryMatchPlayers() *MatchPlayerQuery {
// First returns the first Spray entity from the query.
// Returns a *NotFoundError when no Spray was found.
func (sq *SprayQuery) First(ctx context.Context) (*Spray, error) {
nodes, err := sq.Limit(1).All(ctx)
nodes, err := sq.Limit(1).All(setContextOp(ctx, sq.ctx, "First"))
if err != nil {
return nil, err
}
@@ -113,7 +109,7 @@ func (sq *SprayQuery) FirstX(ctx context.Context) *Spray {
// Returns a *NotFoundError when no Spray ID was found.
func (sq *SprayQuery) FirstID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = sq.Limit(1).IDs(ctx); err != nil {
if ids, err = sq.Limit(1).IDs(setContextOp(ctx, sq.ctx, "FirstID")); err != nil {
return
}
if len(ids) == 0 {
@@ -133,10 +129,10 @@ func (sq *SprayQuery) FirstIDX(ctx context.Context) int {
}
// Only returns a single Spray entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when exactly one Spray entity is not found.
// Returns a *NotSingularError when more than one Spray entity is found.
// Returns a *NotFoundError when no Spray entities are found.
func (sq *SprayQuery) Only(ctx context.Context) (*Spray, error) {
nodes, err := sq.Limit(2).All(ctx)
nodes, err := sq.Limit(2).All(setContextOp(ctx, sq.ctx, "Only"))
if err != nil {
return nil, err
}
@@ -160,11 +156,11 @@ func (sq *SprayQuery) OnlyX(ctx context.Context) *Spray {
}
// OnlyID is like Only, but returns the only Spray ID in the query.
// Returns a *NotSingularError when exactly one Spray ID is not found.
// Returns a *NotSingularError when more than one Spray ID is found.
// Returns a *NotFoundError when no entities are found.
func (sq *SprayQuery) OnlyID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = sq.Limit(2).IDs(ctx); err != nil {
if ids, err = sq.Limit(2).IDs(setContextOp(ctx, sq.ctx, "OnlyID")); err != nil {
return
}
switch len(ids) {
@@ -189,10 +185,12 @@ func (sq *SprayQuery) OnlyIDX(ctx context.Context) int {
// All executes the query and returns a list of Sprays.
func (sq *SprayQuery) All(ctx context.Context) ([]*Spray, error) {
ctx = setContextOp(ctx, sq.ctx, "All")
if err := sq.prepareQuery(ctx); err != nil {
return nil, err
}
return sq.sqlAll(ctx)
qr := querierAll[[]*Spray, *SprayQuery]()
return withInterceptors[[]*Spray](ctx, sq, qr, sq.inters)
}
// AllX is like All, but panics if an error occurs.
@@ -205,9 +203,12 @@ func (sq *SprayQuery) AllX(ctx context.Context) []*Spray {
}
// IDs executes the query and returns a list of Spray IDs.
func (sq *SprayQuery) IDs(ctx context.Context) ([]int, error) {
var ids []int
if err := sq.Select(spray.FieldID).Scan(ctx, &ids); err != nil {
func (sq *SprayQuery) IDs(ctx context.Context) (ids []int, err error) {
if sq.ctx.Unique == nil && sq.path != nil {
sq.Unique(true)
}
ctx = setContextOp(ctx, sq.ctx, "IDs")
if err = sq.Select(spray.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
@@ -224,10 +225,11 @@ func (sq *SprayQuery) IDsX(ctx context.Context) []int {
// Count returns the count of the given query.
func (sq *SprayQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, sq.ctx, "Count")
if err := sq.prepareQuery(ctx); err != nil {
return 0, err
}
return sq.sqlCount(ctx)
return withInterceptors[int](ctx, sq, querierCount[*SprayQuery](), sq.inters)
}
// CountX is like Count, but panics if an error occurs.
@@ -241,10 +243,15 @@ func (sq *SprayQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph.
func (sq *SprayQuery) Exist(ctx context.Context) (bool, error) {
if err := sq.prepareQuery(ctx); err != nil {
return false, err
ctx = setContextOp(ctx, sq.ctx, "Exist")
switch _, err := sq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
return sq.sqlExist(ctx)
}
// ExistX is like Exist, but panics if an error occurs.
@@ -264,9 +271,9 @@ func (sq *SprayQuery) Clone() *SprayQuery {
}
return &SprayQuery{
config: sq.config,
limit: sq.limit,
offset: sq.offset,
order: append([]OrderFunc{}, sq.order...),
ctx: sq.ctx.Clone(),
order: append([]spray.OrderOption{}, sq.order...),
inters: append([]Interceptor{}, sq.inters...),
predicates: append([]predicate.Spray{}, sq.predicates...),
withMatchPlayers: sq.withMatchPlayers.Clone(),
// clone intermediate query.
@@ -278,7 +285,7 @@ func (sq *SprayQuery) Clone() *SprayQuery {
// WithMatchPlayers tells the query-builder to eager-load the nodes that are connected to
// the "match_players" edge. The optional arguments are used to configure the query builder of the edge.
func (sq *SprayQuery) WithMatchPlayers(opts ...func(*MatchPlayerQuery)) *SprayQuery {
query := &MatchPlayerQuery{config: sq.config}
query := (&MatchPlayerClient{config: sq.config}).Query()
for _, opt := range opts {
opt(query)
}
@@ -300,17 +307,13 @@ func (sq *SprayQuery) WithMatchPlayers(opts ...func(*MatchPlayerQuery)) *SprayQu
// GroupBy(spray.FieldWeapon).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
//
func (sq *SprayQuery) GroupBy(field string, fields ...string) *SprayGroupBy {
group := &SprayGroupBy{config: sq.config}
group.fields = append([]string{field}, fields...)
group.path = func(ctx context.Context) (prev *sql.Selector, err error) {
if err := sq.prepareQuery(ctx); err != nil {
return nil, err
}
return sq.sqlQuery(ctx), nil
}
return group
sq.ctx.Fields = append([]string{field}, fields...)
grbuild := &SprayGroupBy{build: sq}
grbuild.flds = &sq.ctx.Fields
grbuild.label = spray.Label
grbuild.scan = grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
@@ -325,14 +328,31 @@ func (sq *SprayQuery) GroupBy(field string, fields ...string) *SprayGroupBy {
// client.Spray.Query().
// Select(spray.FieldWeapon).
// Scan(ctx, &v)
//
func (sq *SprayQuery) Select(fields ...string) *SpraySelect {
sq.fields = append(sq.fields, fields...)
return &SpraySelect{SprayQuery: sq}
sq.ctx.Fields = append(sq.ctx.Fields, fields...)
sbuild := &SpraySelect{SprayQuery: sq}
sbuild.label = spray.Label
sbuild.flds, sbuild.scan = &sq.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a SpraySelect configured with the given aggregations.
func (sq *SprayQuery) Aggregate(fns ...AggregateFunc) *SpraySelect {
return sq.Select().Aggregate(fns...)
}
func (sq *SprayQuery) prepareQuery(ctx context.Context) error {
for _, f := range sq.fields {
for _, inter := range sq.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, sq); err != nil {
return err
}
}
}
for _, f := range sq.ctx.Fields {
if !spray.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
@@ -347,7 +367,7 @@ func (sq *SprayQuery) prepareQuery(ctx context.Context) error {
return nil
}
func (sq *SprayQuery) sqlAll(ctx context.Context) ([]*Spray, error) {
func (sq *SprayQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Spray, error) {
var (
nodes = []*Spray{}
withFKs = sq.withFKs
@@ -362,30 +382,37 @@ func (sq *SprayQuery) sqlAll(ctx context.Context) ([]*Spray, error) {
if withFKs {
_spec.Node.Columns = append(_spec.Node.Columns, spray.ForeignKeys...)
}
_spec.ScanValues = func(columns []string) ([]interface{}, error) {
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*Spray).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []any) error {
node := &Spray{config: sq.config}
nodes = append(nodes, node)
return node.scanValues(columns)
}
_spec.Assign = func(columns []string, values []interface{}) error {
if len(nodes) == 0 {
return fmt.Errorf("ent: Assign called without calling ScanValues")
}
node := nodes[len(nodes)-1]
node.Edges.loadedTypes = loadedTypes
return node.assignValues(columns, values)
}
if len(sq.modifiers) > 0 {
_spec.Modifiers = sq.modifiers
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, sq.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
if query := sq.withMatchPlayers; query != nil {
if err := sq.loadMatchPlayers(ctx, query, nodes, nil,
func(n *Spray, e *MatchPlayer) { n.Edges.MatchPlayers = e }); err != nil {
return nil, err
}
}
return nodes, nil
}
func (sq *SprayQuery) loadMatchPlayers(ctx context.Context, query *MatchPlayerQuery, nodes []*Spray, init func(*Spray), assign func(*Spray, *MatchPlayer)) error {
ids := make([]int, 0, len(nodes))
nodeids := make(map[int][]*Spray)
for i := range nodes {
@@ -398,23 +425,24 @@ func (sq *SprayQuery) sqlAll(ctx context.Context) ([]*Spray, error) {
}
nodeids[fk] = append(nodeids[fk], nodes[i])
}
if len(ids) == 0 {
return nil
}
query.Where(matchplayer.IDIn(ids...))
neighbors, err := query.All(ctx)
if err != nil {
return nil, err
return err
}
for _, n := range neighbors {
nodes, ok := nodeids[n.ID]
if !ok {
return nil, fmt.Errorf(`unexpected foreign-key "match_player_spray" returned %v`, n.ID)
return fmt.Errorf(`unexpected foreign-key "match_player_spray" returned %v`, n.ID)
}
for i := range nodes {
nodes[i].Edges.MatchPlayers = n
assign(nodes[i], n)
}
}
}
return nodes, nil
return nil
}
func (sq *SprayQuery) sqlCount(ctx context.Context) (int, error) {
@@ -422,38 +450,22 @@ func (sq *SprayQuery) sqlCount(ctx context.Context) (int, error) {
if len(sq.modifiers) > 0 {
_spec.Modifiers = sq.modifiers
}
_spec.Node.Columns = sq.fields
if len(sq.fields) > 0 {
_spec.Unique = sq.unique != nil && *sq.unique
_spec.Node.Columns = sq.ctx.Fields
if len(sq.ctx.Fields) > 0 {
_spec.Unique = sq.ctx.Unique != nil && *sq.ctx.Unique
}
return sqlgraph.CountNodes(ctx, sq.driver, _spec)
}
func (sq *SprayQuery) sqlExist(ctx context.Context) (bool, error) {
n, err := sq.sqlCount(ctx)
if err != nil {
return false, fmt.Errorf("ent: check existence: %w", err)
}
return n > 0, nil
}
func (sq *SprayQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{
Node: &sqlgraph.NodeSpec{
Table: spray.Table,
Columns: spray.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: spray.FieldID,
},
},
From: sq.sql,
Unique: true,
}
if unique := sq.unique; unique != nil {
_spec := sqlgraph.NewQuerySpec(spray.Table, spray.Columns, sqlgraph.NewFieldSpec(spray.FieldID, field.TypeInt))
_spec.From = sq.sql
if unique := sq.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if sq.path != nil {
_spec.Unique = true
}
if fields := sq.fields; len(fields) > 0 {
if fields := sq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, spray.FieldID)
for i := range fields {
@@ -469,10 +481,10 @@ func (sq *SprayQuery) querySpec() *sqlgraph.QuerySpec {
}
}
}
if limit := sq.limit; limit != nil {
if limit := sq.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := sq.offset; offset != nil {
if offset := sq.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := sq.order; len(ps) > 0 {
@@ -488,7 +500,7 @@ func (sq *SprayQuery) querySpec() *sqlgraph.QuerySpec {
func (sq *SprayQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(sq.driver.Dialect())
t1 := builder.Table(spray.Table)
columns := sq.fields
columns := sq.ctx.Fields
if len(columns) == 0 {
columns = spray.Columns
}
@@ -497,7 +509,7 @@ func (sq *SprayQuery) sqlQuery(ctx context.Context) *sql.Selector {
selector = sq.sql
selector.Select(selector.Columns(columns...)...)
}
if sq.unique != nil && *sq.unique {
if sq.ctx.Unique != nil && *sq.ctx.Unique {
selector.Distinct()
}
for _, m := range sq.modifiers {
@@ -509,12 +521,12 @@ func (sq *SprayQuery) sqlQuery(ctx context.Context) *sql.Selector {
for _, p := range sq.order {
p(selector)
}
if offset := sq.offset; offset != nil {
if offset := sq.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := sq.limit; limit != nil {
if limit := sq.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
@@ -528,12 +540,8 @@ func (sq *SprayQuery) Modify(modifiers ...func(s *sql.Selector)) *SpraySelect {
// SprayGroupBy is the group-by builder for Spray entities.
type SprayGroupBy struct {
config
fields []string
fns []AggregateFunc
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
selector
build *SprayQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
@@ -542,471 +550,77 @@ func (sgb *SprayGroupBy) Aggregate(fns ...AggregateFunc) *SprayGroupBy {
return sgb
}
// Scan applies the group-by query and scans the result into the given value.
func (sgb *SprayGroupBy) Scan(ctx context.Context, v interface{}) error {
query, err := sgb.path(ctx)
if err != nil {
// Scan applies the selector query and scans the result into the given value.
func (sgb *SprayGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, sgb.build.ctx, "GroupBy")
if err := sgb.build.prepareQuery(ctx); err != nil {
return err
}
sgb.sql = query
return sgb.sqlScan(ctx, v)
return scanWithInterceptors[*SprayQuery, *SprayGroupBy](ctx, sgb.build, sgb, sgb.build.inters, v)
}
// ScanX is like Scan, but panics if an error occurs.
func (sgb *SprayGroupBy) ScanX(ctx context.Context, v interface{}) {
if err := sgb.Scan(ctx, v); err != nil {
panic(err)
func (sgb *SprayGroupBy) sqlScan(ctx context.Context, root *SprayQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(sgb.fns))
for _, fn := range sgb.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*sgb.flds)+len(sgb.fns))
for _, f := range *sgb.flds {
columns = append(columns, selector.C(f))
}
// Strings returns list of strings from group-by.
// It is only allowed when executing a group-by query with one field.
func (sgb *SprayGroupBy) Strings(ctx context.Context) ([]string, error) {
if len(sgb.fields) > 1 {
return nil, errors.New("ent: SprayGroupBy.Strings is not achievable when grouping more than 1 field")
columns = append(columns, aggregation...)
selector.Select(columns...)
}
var v []string
if err := sgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// StringsX is like Strings, but panics if an error occurs.
func (sgb *SprayGroupBy) StringsX(ctx context.Context) []string {
v, err := sgb.Strings(ctx)
if err != nil {
panic(err)
}
return v
}
// String returns a single string from a group-by query.
// It is only allowed when executing a group-by query with one field.
func (sgb *SprayGroupBy) String(ctx context.Context) (_ string, err error) {
var v []string
if v, err = sgb.Strings(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{spray.Label}
default:
err = fmt.Errorf("ent: SprayGroupBy.Strings returned %d results when one was expected", len(v))
}
return
}
// StringX is like String, but panics if an error occurs.
func (sgb *SprayGroupBy) StringX(ctx context.Context) string {
v, err := sgb.String(ctx)
if err != nil {
panic(err)
}
return v
}
// Ints returns list of ints from group-by.
// It is only allowed when executing a group-by query with one field.
func (sgb *SprayGroupBy) Ints(ctx context.Context) ([]int, error) {
if len(sgb.fields) > 1 {
return nil, errors.New("ent: SprayGroupBy.Ints is not achievable when grouping more than 1 field")
}
var v []int
if err := sgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// IntsX is like Ints, but panics if an error occurs.
func (sgb *SprayGroupBy) IntsX(ctx context.Context) []int {
v, err := sgb.Ints(ctx)
if err != nil {
panic(err)
}
return v
}
// Int returns a single int from a group-by query.
// It is only allowed when executing a group-by query with one field.
func (sgb *SprayGroupBy) Int(ctx context.Context) (_ int, err error) {
var v []int
if v, err = sgb.Ints(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{spray.Label}
default:
err = fmt.Errorf("ent: SprayGroupBy.Ints returned %d results when one was expected", len(v))
}
return
}
// IntX is like Int, but panics if an error occurs.
func (sgb *SprayGroupBy) IntX(ctx context.Context) int {
v, err := sgb.Int(ctx)
if err != nil {
panic(err)
}
return v
}
// Float64s returns list of float64s from group-by.
// It is only allowed when executing a group-by query with one field.
func (sgb *SprayGroupBy) Float64s(ctx context.Context) ([]float64, error) {
if len(sgb.fields) > 1 {
return nil, errors.New("ent: SprayGroupBy.Float64s is not achievable when grouping more than 1 field")
}
var v []float64
if err := sgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// Float64sX is like Float64s, but panics if an error occurs.
func (sgb *SprayGroupBy) Float64sX(ctx context.Context) []float64 {
v, err := sgb.Float64s(ctx)
if err != nil {
panic(err)
}
return v
}
// Float64 returns a single float64 from a group-by query.
// It is only allowed when executing a group-by query with one field.
func (sgb *SprayGroupBy) Float64(ctx context.Context) (_ float64, err error) {
var v []float64
if v, err = sgb.Float64s(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{spray.Label}
default:
err = fmt.Errorf("ent: SprayGroupBy.Float64s returned %d results when one was expected", len(v))
}
return
}
// Float64X is like Float64, but panics if an error occurs.
func (sgb *SprayGroupBy) Float64X(ctx context.Context) float64 {
v, err := sgb.Float64(ctx)
if err != nil {
panic(err)
}
return v
}
// Bools returns list of bools from group-by.
// It is only allowed when executing a group-by query with one field.
func (sgb *SprayGroupBy) Bools(ctx context.Context) ([]bool, error) {
if len(sgb.fields) > 1 {
return nil, errors.New("ent: SprayGroupBy.Bools is not achievable when grouping more than 1 field")
}
var v []bool
if err := sgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// BoolsX is like Bools, but panics if an error occurs.
func (sgb *SprayGroupBy) BoolsX(ctx context.Context) []bool {
v, err := sgb.Bools(ctx)
if err != nil {
panic(err)
}
return v
}
// Bool returns a single bool from a group-by query.
// It is only allowed when executing a group-by query with one field.
func (sgb *SprayGroupBy) Bool(ctx context.Context) (_ bool, err error) {
var v []bool
if v, err = sgb.Bools(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{spray.Label}
default:
err = fmt.Errorf("ent: SprayGroupBy.Bools returned %d results when one was expected", len(v))
}
return
}
// BoolX is like Bool, but panics if an error occurs.
func (sgb *SprayGroupBy) BoolX(ctx context.Context) bool {
v, err := sgb.Bool(ctx)
if err != nil {
panic(err)
}
return v
}
func (sgb *SprayGroupBy) sqlScan(ctx context.Context, v interface{}) error {
for _, f := range sgb.fields {
if !spray.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)}
}
}
selector := sgb.sqlQuery()
selector.GroupBy(selector.Columns(*sgb.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := sgb.driver.Query(ctx, query, args, rows); err != nil {
if err := sgb.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
func (sgb *SprayGroupBy) sqlQuery() *sql.Selector {
selector := sgb.sql.Select()
aggregation := make([]string, 0, len(sgb.fns))
for _, fn := range sgb.fns {
aggregation = append(aggregation, fn(selector))
}
// If no columns were selected in a custom aggregation function, the default
// selection is the fields used for "group-by", and the aggregation functions.
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(sgb.fields)+len(sgb.fns))
for _, f := range sgb.fields {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
return selector.GroupBy(selector.Columns(sgb.fields...)...)
}
// SpraySelect is the builder for selecting fields of Spray entities.
type SpraySelect struct {
*SprayQuery
// intermediate query (i.e. traversal path).
sql *sql.Selector
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (ss *SpraySelect) Aggregate(fns ...AggregateFunc) *SpraySelect {
ss.fns = append(ss.fns, fns...)
return ss
}
// Scan applies the selector query and scans the result into the given value.
func (ss *SpraySelect) Scan(ctx context.Context, v interface{}) error {
func (ss *SpraySelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, ss.ctx, "Select")
if err := ss.prepareQuery(ctx); err != nil {
return err
}
ss.sql = ss.SprayQuery.sqlQuery(ctx)
return ss.sqlScan(ctx, v)
return scanWithInterceptors[*SprayQuery, *SpraySelect](ctx, ss.SprayQuery, ss, ss.inters, v)
}
// ScanX is like Scan, but panics if an error occurs.
func (ss *SpraySelect) ScanX(ctx context.Context, v interface{}) {
if err := ss.Scan(ctx, v); err != nil {
panic(err)
func (ss *SpraySelect) sqlScan(ctx context.Context, root *SprayQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(ss.fns))
for _, fn := range ss.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*ss.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
// Strings returns list of strings from a selector. It is only allowed when selecting one field.
func (ss *SpraySelect) Strings(ctx context.Context) ([]string, error) {
if len(ss.fields) > 1 {
return nil, errors.New("ent: SpraySelect.Strings is not achievable when selecting more than 1 field")
}
var v []string
if err := ss.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// StringsX is like Strings, but panics if an error occurs.
func (ss *SpraySelect) StringsX(ctx context.Context) []string {
v, err := ss.Strings(ctx)
if err != nil {
panic(err)
}
return v
}
// String returns a single string from a selector. It is only allowed when selecting one field.
func (ss *SpraySelect) String(ctx context.Context) (_ string, err error) {
var v []string
if v, err = ss.Strings(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{spray.Label}
default:
err = fmt.Errorf("ent: SpraySelect.Strings returned %d results when one was expected", len(v))
}
return
}
// StringX is like String, but panics if an error occurs.
func (ss *SpraySelect) StringX(ctx context.Context) string {
v, err := ss.String(ctx)
if err != nil {
panic(err)
}
return v
}
// Ints returns list of ints from a selector. It is only allowed when selecting one field.
func (ss *SpraySelect) Ints(ctx context.Context) ([]int, error) {
if len(ss.fields) > 1 {
return nil, errors.New("ent: SpraySelect.Ints is not achievable when selecting more than 1 field")
}
var v []int
if err := ss.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// IntsX is like Ints, but panics if an error occurs.
func (ss *SpraySelect) IntsX(ctx context.Context) []int {
v, err := ss.Ints(ctx)
if err != nil {
panic(err)
}
return v
}
// Int returns a single int from a selector. It is only allowed when selecting one field.
func (ss *SpraySelect) Int(ctx context.Context) (_ int, err error) {
var v []int
if v, err = ss.Ints(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{spray.Label}
default:
err = fmt.Errorf("ent: SpraySelect.Ints returned %d results when one was expected", len(v))
}
return
}
// IntX is like Int, but panics if an error occurs.
func (ss *SpraySelect) IntX(ctx context.Context) int {
v, err := ss.Int(ctx)
if err != nil {
panic(err)
}
return v
}
// Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
func (ss *SpraySelect) Float64s(ctx context.Context) ([]float64, error) {
if len(ss.fields) > 1 {
return nil, errors.New("ent: SpraySelect.Float64s is not achievable when selecting more than 1 field")
}
var v []float64
if err := ss.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// Float64sX is like Float64s, but panics if an error occurs.
func (ss *SpraySelect) Float64sX(ctx context.Context) []float64 {
v, err := ss.Float64s(ctx)
if err != nil {
panic(err)
}
return v
}
// Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
func (ss *SpraySelect) Float64(ctx context.Context) (_ float64, err error) {
var v []float64
if v, err = ss.Float64s(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{spray.Label}
default:
err = fmt.Errorf("ent: SpraySelect.Float64s returned %d results when one was expected", len(v))
}
return
}
// Float64X is like Float64, but panics if an error occurs.
func (ss *SpraySelect) Float64X(ctx context.Context) float64 {
v, err := ss.Float64(ctx)
if err != nil {
panic(err)
}
return v
}
// Bools returns list of bools from a selector. It is only allowed when selecting one field.
func (ss *SpraySelect) Bools(ctx context.Context) ([]bool, error) {
if len(ss.fields) > 1 {
return nil, errors.New("ent: SpraySelect.Bools is not achievable when selecting more than 1 field")
}
var v []bool
if err := ss.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// BoolsX is like Bools, but panics if an error occurs.
func (ss *SpraySelect) BoolsX(ctx context.Context) []bool {
v, err := ss.Bools(ctx)
if err != nil {
panic(err)
}
return v
}
// Bool returns a single bool from a selector. It is only allowed when selecting one field.
func (ss *SpraySelect) Bool(ctx context.Context) (_ bool, err error) {
var v []bool
if v, err = ss.Bools(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{spray.Label}
default:
err = fmt.Errorf("ent: SpraySelect.Bools returned %d results when one was expected", len(v))
}
return
}
// BoolX is like Bool, but panics if an error occurs.
func (ss *SpraySelect) BoolX(ctx context.Context) bool {
v, err := ss.Bool(ctx)
if err != nil {
panic(err)
}
return v
}
func (ss *SpraySelect) sqlScan(ctx context.Context, v interface{}) error {
rows := &sql.Rows{}
query, args := ss.sql.Query()
query, args := selector.Query()
if err := ss.driver.Query(ctx, query, args, rows); err != nil {
return err
}

View File

@@ -1,18 +1,18 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"csgowtfd/ent/matchplayer"
"csgowtfd/ent/predicate"
"csgowtfd/ent/spray"
"errors"
"fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"somegit.dev/csgowtf/csgowtfd/ent/matchplayer"
"somegit.dev/csgowtf/csgowtfd/ent/predicate"
"somegit.dev/csgowtf/csgowtfd/ent/spray"
)
// SprayUpdate is the builder for updating Spray entities.
@@ -20,6 +20,7 @@ type SprayUpdate struct {
config
hooks []Hook
mutation *SprayMutation
modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the SprayUpdate builder.
@@ -79,34 +80,7 @@ func (su *SprayUpdate) ClearMatchPlayers() *SprayUpdate {
// Save executes the query and returns the number of nodes affected by the update operation.
func (su *SprayUpdate) Save(ctx context.Context) (int, error) {
var (
err error
affected int
)
if len(su.hooks) == 0 {
affected, err = su.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*SprayMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
su.mutation = mutation
affected, err = su.sqlSave(ctx)
mutation.done = true
return affected, err
})
for i := len(su.hooks) - 1; i >= 0; i-- {
if su.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = su.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, su.mutation); err != nil {
return 0, err
}
}
return affected, err
return withHooks(ctx, su.sqlSave, su.mutation, su.hooks)
}
// SaveX is like Save, but panics if an error occurs.
@@ -131,17 +105,14 @@ func (su *SprayUpdate) ExecX(ctx context.Context) {
}
}
func (su *SprayUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: spray.Table,
Columns: spray.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: spray.FieldID,
},
},
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (su *SprayUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *SprayUpdate {
su.modifiers = append(su.modifiers, modifiers...)
return su
}
func (su *SprayUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := sqlgraph.NewUpdateSpec(spray.Table, spray.Columns, sqlgraph.NewFieldSpec(spray.FieldID, field.TypeInt))
if ps := su.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
@@ -150,25 +121,13 @@ func (su *SprayUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
}
if value, ok := su.mutation.Weapon(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: spray.FieldWeapon,
})
_spec.SetField(spray.FieldWeapon, field.TypeInt, value)
}
if value, ok := su.mutation.AddedWeapon(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: spray.FieldWeapon,
})
_spec.AddField(spray.FieldWeapon, field.TypeInt, value)
}
if value, ok := su.mutation.Spray(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeBytes,
Value: value,
Column: spray.FieldSpray,
})
_spec.SetField(spray.FieldSpray, field.TypeBytes, value)
}
if su.mutation.MatchPlayersCleared() {
edge := &sqlgraph.EdgeSpec{
@@ -178,10 +137,7 @@ func (su *SprayUpdate) sqlSave(ctx context.Context) (n int, err error) {
Columns: []string{spray.MatchPlayersColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
@@ -194,10 +150,7 @@ func (su *SprayUpdate) sqlSave(ctx context.Context) (n int, err error) {
Columns: []string{spray.MatchPlayersColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
@@ -205,14 +158,16 @@ func (su *SprayUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_spec.AddModifiers(su.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, su.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{spray.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
su.mutation.done = true
return n, nil
}
@@ -222,6 +177,7 @@ type SprayUpdateOne struct {
fields []string
hooks []Hook
mutation *SprayMutation
modifiers []func(*sql.UpdateBuilder)
}
// SetWeapon sets the "weapon" field.
@@ -273,6 +229,12 @@ func (suo *SprayUpdateOne) ClearMatchPlayers() *SprayUpdateOne {
return suo
}
// Where appends a list predicates to the SprayUpdate builder.
func (suo *SprayUpdateOne) Where(ps ...predicate.Spray) *SprayUpdateOne {
suo.mutation.Where(ps...)
return suo
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (suo *SprayUpdateOne) Select(field string, fields ...string) *SprayUpdateOne {
@@ -282,34 +244,7 @@ func (suo *SprayUpdateOne) Select(field string, fields ...string) *SprayUpdateOn
// Save executes the query and returns the updated Spray entity.
func (suo *SprayUpdateOne) Save(ctx context.Context) (*Spray, error) {
var (
err error
node *Spray
)
if len(suo.hooks) == 0 {
node, err = suo.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*SprayMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
suo.mutation = mutation
node, err = suo.sqlSave(ctx)
mutation.done = true
return node, err
})
for i := len(suo.hooks) - 1; i >= 0; i-- {
if suo.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = suo.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, suo.mutation); err != nil {
return nil, err
}
}
return node, err
return withHooks(ctx, suo.sqlSave, suo.mutation, suo.hooks)
}
// SaveX is like Save, but panics if an error occurs.
@@ -334,17 +269,14 @@ func (suo *SprayUpdateOne) ExecX(ctx context.Context) {
}
}
func (suo *SprayUpdateOne) sqlSave(ctx context.Context) (_node *Spray, err error) {
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: spray.Table,
Columns: spray.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: spray.FieldID,
},
},
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (suo *SprayUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *SprayUpdateOne {
suo.modifiers = append(suo.modifiers, modifiers...)
return suo
}
func (suo *SprayUpdateOne) sqlSave(ctx context.Context) (_node *Spray, err error) {
_spec := sqlgraph.NewUpdateSpec(spray.Table, spray.Columns, sqlgraph.NewFieldSpec(spray.FieldID, field.TypeInt))
id, ok := suo.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Spray.id" for update`)}
@@ -370,25 +302,13 @@ func (suo *SprayUpdateOne) sqlSave(ctx context.Context) (_node *Spray, err error
}
}
if value, ok := suo.mutation.Weapon(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: spray.FieldWeapon,
})
_spec.SetField(spray.FieldWeapon, field.TypeInt, value)
}
if value, ok := suo.mutation.AddedWeapon(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: spray.FieldWeapon,
})
_spec.AddField(spray.FieldWeapon, field.TypeInt, value)
}
if value, ok := suo.mutation.Spray(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeBytes,
Value: value,
Column: spray.FieldSpray,
})
_spec.SetField(spray.FieldSpray, field.TypeBytes, value)
}
if suo.mutation.MatchPlayersCleared() {
edge := &sqlgraph.EdgeSpec{
@@ -398,10 +318,7 @@ func (suo *SprayUpdateOne) sqlSave(ctx context.Context) (_node *Spray, err error
Columns: []string{spray.MatchPlayersColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
@@ -414,10 +331,7 @@ func (suo *SprayUpdateOne) sqlSave(ctx context.Context) (_node *Spray, err error
Columns: []string{spray.MatchPlayersColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
@@ -425,6 +339,7 @@ func (suo *SprayUpdateOne) sqlSave(ctx context.Context) (_node *Spray, err error
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_spec.AddModifiers(suo.modifiers...)
_node = &Spray{config: suo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
@@ -432,9 +347,10 @@ func (suo *SprayUpdateOne) sqlSave(ctx context.Context) (_node *Spray, err error
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{spray.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
suo.mutation.done = true
return _node, nil
}

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
@@ -30,12 +30,6 @@ type Tx struct {
// lazily loaded.
client *Client
clientOnce sync.Once
// completion callbacks.
mu sync.Mutex
onCommit []CommitHook
onRollback []RollbackHook
// ctx lives for the life of the transaction. It is
// the same context used by the underlying connection.
ctx context.Context
@@ -80,9 +74,9 @@ func (tx *Tx) Commit() error {
var fn Committer = CommitFunc(func(context.Context, *Tx) error {
return txDriver.tx.Commit()
})
tx.mu.Lock()
hooks := append([]CommitHook(nil), tx.onCommit...)
tx.mu.Unlock()
txDriver.mu.Lock()
hooks := append([]CommitHook(nil), txDriver.onCommit...)
txDriver.mu.Unlock()
for i := len(hooks) - 1; i >= 0; i-- {
fn = hooks[i](fn)
}
@@ -91,9 +85,10 @@ func (tx *Tx) Commit() error {
// OnCommit adds a hook to call on commit.
func (tx *Tx) OnCommit(f CommitHook) {
tx.mu.Lock()
defer tx.mu.Unlock()
tx.onCommit = append(tx.onCommit, f)
txDriver := tx.config.driver.(*txDriver)
txDriver.mu.Lock()
txDriver.onCommit = append(txDriver.onCommit, f)
txDriver.mu.Unlock()
}
type (
@@ -135,9 +130,9 @@ func (tx *Tx) Rollback() error {
var fn Rollbacker = RollbackFunc(func(context.Context, *Tx) error {
return txDriver.tx.Rollback()
})
tx.mu.Lock()
hooks := append([]RollbackHook(nil), tx.onRollback...)
tx.mu.Unlock()
txDriver.mu.Lock()
hooks := append([]RollbackHook(nil), txDriver.onRollback...)
txDriver.mu.Unlock()
for i := len(hooks) - 1; i >= 0; i-- {
fn = hooks[i](fn)
}
@@ -146,9 +141,10 @@ func (tx *Tx) Rollback() error {
// OnRollback adds a hook to call on rollback.
func (tx *Tx) OnRollback(f RollbackHook) {
tx.mu.Lock()
defer tx.mu.Unlock()
tx.onRollback = append(tx.onRollback, f)
txDriver := tx.config.driver.(*txDriver)
txDriver.mu.Lock()
txDriver.onRollback = append(txDriver.onRollback, f)
txDriver.mu.Unlock()
}
// Client returns a Client that binds to current transaction.
@@ -186,6 +182,10 @@ type txDriver struct {
drv dialect.Driver
// tx is the underlying transaction.
tx dialect.Tx
// completion hooks.
mu sync.Mutex
onCommit []CommitHook
onRollback []RollbackHook
}
// newTx creates a new transactional driver.
@@ -216,12 +216,12 @@ func (*txDriver) Commit() error { return nil }
func (*txDriver) Rollback() error { return nil }
// Exec calls tx.Exec.
func (tx *txDriver) Exec(ctx context.Context, query string, args, v interface{}) error {
func (tx *txDriver) Exec(ctx context.Context, query string, args, v any) error {
return tx.tx.Exec(ctx, query, args, v)
}
// Query calls tx.Query.
func (tx *txDriver) Query(ctx context.Context, query string, args, v interface{}) error {
func (tx *txDriver) Query(ctx context.Context, query string, args, v any) error {
return tx.tx.Query(ctx, query, args, v)
}

View File

@@ -1,14 +1,15 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"csgowtfd/ent/matchplayer"
"csgowtfd/ent/weapon"
"fmt"
"strings"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"somegit.dev/csgowtf/csgowtfd/ent/matchplayer"
"somegit.dev/csgowtf/csgowtfd/ent/weapon"
)
// Weapon is the model entity for the Weapon schema.
@@ -28,6 +29,7 @@ type Weapon struct {
// The values are being populated by the WeaponQuery when eager-loading is set.
Edges WeaponEdges `json:"edges"`
match_player_weapon_stats *int
selectValues sql.SelectValues
}
// WeaponEdges holds the relations/edges for other nodes in the graph.
@@ -44,8 +46,7 @@ type WeaponEdges struct {
func (e WeaponEdges) StatOrErr() (*MatchPlayer, error) {
if e.loadedTypes[0] {
if e.Stat == nil {
// The edge stat was loaded in eager-loading,
// but was not found.
// Edge was loaded but was not found.
return nil, &NotFoundError{label: matchplayer.Label}
}
return e.Stat, nil
@@ -54,8 +55,8 @@ func (e WeaponEdges) StatOrErr() (*MatchPlayer, error) {
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Weapon) scanValues(columns []string) ([]interface{}, error) {
values := make([]interface{}, len(columns))
func (*Weapon) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case weapon.FieldID, weapon.FieldVictim, weapon.FieldDmg, weapon.FieldEqType, weapon.FieldHitGroup:
@@ -63,7 +64,7 @@ func (*Weapon) scanValues(columns []string) ([]interface{}, error) {
case weapon.ForeignKeys[0]: // match_player_weapon_stats
values[i] = new(sql.NullInt64)
default:
return nil, fmt.Errorf("unexpected column %q for type Weapon", columns[i])
values[i] = new(sql.UnknownType)
}
}
return values, nil
@@ -71,7 +72,7 @@ func (*Weapon) scanValues(columns []string) ([]interface{}, error) {
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the Weapon fields.
func (w *Weapon) assignValues(columns []string, values []interface{}) error {
func (w *Weapon) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
@@ -114,31 +115,39 @@ func (w *Weapon) assignValues(columns []string, values []interface{}) error {
w.match_player_weapon_stats = new(int)
*w.match_player_weapon_stats = int(value.Int64)
}
default:
w.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the Weapon.
// This includes values selected through modifiers, order, etc.
func (w *Weapon) Value(name string) (ent.Value, error) {
return w.selectValues.Get(name)
}
// QueryStat queries the "stat" edge of the Weapon entity.
func (w *Weapon) QueryStat() *MatchPlayerQuery {
return (&WeaponClient{config: w.config}).QueryStat(w)
return NewWeaponClient(w.config).QueryStat(w)
}
// Update returns a builder for updating this Weapon.
// Note that you need to call Weapon.Unwrap() before calling this method if this Weapon
// was returned from a transaction, and the transaction was committed or rolled back.
func (w *Weapon) Update() *WeaponUpdateOne {
return (&WeaponClient{config: w.config}).UpdateOne(w)
return NewWeaponClient(w.config).UpdateOne(w)
}
// Unwrap unwraps the Weapon 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 (w *Weapon) Unwrap() *Weapon {
tx, ok := w.config.driver.(*txDriver)
_tx, ok := w.config.driver.(*txDriver)
if !ok {
panic("ent: Weapon is not a transactional entity")
}
w.config.driver = tx.drv
w.config.driver = _tx.drv
return w
}
@@ -146,14 +155,17 @@ func (w *Weapon) Unwrap() *Weapon {
func (w *Weapon) String() string {
var builder strings.Builder
builder.WriteString("Weapon(")
builder.WriteString(fmt.Sprintf("id=%v", w.ID))
builder.WriteString(", victim=")
builder.WriteString(fmt.Sprintf("id=%v, ", w.ID))
builder.WriteString("victim=")
builder.WriteString(fmt.Sprintf("%v", w.Victim))
builder.WriteString(", dmg=")
builder.WriteString(", ")
builder.WriteString("dmg=")
builder.WriteString(fmt.Sprintf("%v", w.Dmg))
builder.WriteString(", eq_type=")
builder.WriteString(", ")
builder.WriteString("eq_type=")
builder.WriteString(fmt.Sprintf("%v", w.EqType))
builder.WriteString(", hit_group=")
builder.WriteString(", ")
builder.WriteString("hit_group=")
builder.WriteString(fmt.Sprintf("%v", w.HitGroup))
builder.WriteByte(')')
return builder.String()
@@ -161,9 +173,3 @@ func (w *Weapon) String() string {
// Weapons is a parsable slice of Weapon.
type Weapons []*Weapon
func (w Weapons) config(cfg config) {
for _i := range w {
w[_i].config = cfg
}
}

View File

@@ -1,7 +1,12 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package weapon
import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
const (
// Label holds the string label denoting the weapon type in the database.
Label = "weapon"
@@ -57,3 +62,45 @@ func ValidColumn(column string) bool {
}
return false
}
// OrderOption defines the ordering options for the Weapon queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByVictim orders the results by the victim field.
func ByVictim(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldVictim, opts...).ToFunc()
}
// ByDmg orders the results by the dmg field.
func ByDmg(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDmg, opts...).ToFunc()
}
// ByEqType orders the results by the eq_type field.
func ByEqType(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldEqType, opts...).ToFunc()
}
// ByHitGroup orders the results by the hit_group field.
func ByHitGroup(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldHitGroup, opts...).ToFunc()
}
// ByStatField orders the results by stat field.
func ByStatField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newStatStep(), sql.OrderByField(field, opts...))
}
}
func newStatStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(StatInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, StatTable, StatColumn),
)
}

View File

@@ -1,427 +1,236 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package weapon
import (
"csgowtfd/ent/predicate"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"somegit.dev/csgowtf/csgowtfd/ent/predicate"
)
// ID filters vertices based on their ID field.
func ID(id int) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldID), id))
})
return predicate.Weapon(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id int) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldID), id))
})
return predicate.Weapon(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id int) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.NEQ(s.C(FieldID), id))
})
return predicate.Weapon(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int) predicate.Weapon {
return predicate.Weapon(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...))
})
return predicate.Weapon(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int) predicate.Weapon {
return predicate.Weapon(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...))
})
return predicate.Weapon(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id int) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.GT(s.C(FieldID), id))
})
return predicate.Weapon(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id int) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.GTE(s.C(FieldID), id))
})
return predicate.Weapon(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id int) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.LT(s.C(FieldID), id))
})
return predicate.Weapon(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id int) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.LTE(s.C(FieldID), id))
})
return predicate.Weapon(sql.FieldLTE(FieldID, id))
}
// Victim applies equality check predicate on the "victim" field. It's identical to VictimEQ.
func Victim(v uint64) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldVictim), v))
})
return predicate.Weapon(sql.FieldEQ(FieldVictim, v))
}
// Dmg applies equality check predicate on the "dmg" field. It's identical to DmgEQ.
func Dmg(v uint) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldDmg), v))
})
return predicate.Weapon(sql.FieldEQ(FieldDmg, v))
}
// EqType applies equality check predicate on the "eq_type" field. It's identical to EqTypeEQ.
func EqType(v int) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldEqType), v))
})
return predicate.Weapon(sql.FieldEQ(FieldEqType, v))
}
// HitGroup applies equality check predicate on the "hit_group" field. It's identical to HitGroupEQ.
func HitGroup(v int) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldHitGroup), v))
})
return predicate.Weapon(sql.FieldEQ(FieldHitGroup, v))
}
// VictimEQ applies the EQ predicate on the "victim" field.
func VictimEQ(v uint64) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldVictim), v))
})
return predicate.Weapon(sql.FieldEQ(FieldVictim, v))
}
// VictimNEQ applies the NEQ predicate on the "victim" field.
func VictimNEQ(v uint64) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.NEQ(s.C(FieldVictim), v))
})
return predicate.Weapon(sql.FieldNEQ(FieldVictim, v))
}
// VictimIn applies the In predicate on the "victim" field.
func VictimIn(vs ...uint64) predicate.Weapon {
v := make([]interface{}, len(vs))
for i := range v {
v[i] = vs[i]
}
return predicate.Weapon(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...))
})
return predicate.Weapon(sql.FieldIn(FieldVictim, vs...))
}
// VictimNotIn applies the NotIn predicate on the "victim" field.
func VictimNotIn(vs ...uint64) predicate.Weapon {
v := make([]interface{}, len(vs))
for i := range v {
v[i] = vs[i]
}
return predicate.Weapon(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...))
})
return predicate.Weapon(sql.FieldNotIn(FieldVictim, vs...))
}
// VictimGT applies the GT predicate on the "victim" field.
func VictimGT(v uint64) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.GT(s.C(FieldVictim), v))
})
return predicate.Weapon(sql.FieldGT(FieldVictim, v))
}
// VictimGTE applies the GTE predicate on the "victim" field.
func VictimGTE(v uint64) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.GTE(s.C(FieldVictim), v))
})
return predicate.Weapon(sql.FieldGTE(FieldVictim, v))
}
// VictimLT applies the LT predicate on the "victim" field.
func VictimLT(v uint64) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.LT(s.C(FieldVictim), v))
})
return predicate.Weapon(sql.FieldLT(FieldVictim, v))
}
// VictimLTE applies the LTE predicate on the "victim" field.
func VictimLTE(v uint64) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.LTE(s.C(FieldVictim), v))
})
return predicate.Weapon(sql.FieldLTE(FieldVictim, v))
}
// DmgEQ applies the EQ predicate on the "dmg" field.
func DmgEQ(v uint) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldDmg), v))
})
return predicate.Weapon(sql.FieldEQ(FieldDmg, v))
}
// DmgNEQ applies the NEQ predicate on the "dmg" field.
func DmgNEQ(v uint) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.NEQ(s.C(FieldDmg), v))
})
return predicate.Weapon(sql.FieldNEQ(FieldDmg, v))
}
// DmgIn applies the In predicate on the "dmg" field.
func DmgIn(vs ...uint) predicate.Weapon {
v := make([]interface{}, len(vs))
for i := range v {
v[i] = vs[i]
}
return predicate.Weapon(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...))
})
return predicate.Weapon(sql.FieldIn(FieldDmg, vs...))
}
// DmgNotIn applies the NotIn predicate on the "dmg" field.
func DmgNotIn(vs ...uint) predicate.Weapon {
v := make([]interface{}, len(vs))
for i := range v {
v[i] = vs[i]
}
return predicate.Weapon(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...))
})
return predicate.Weapon(sql.FieldNotIn(FieldDmg, vs...))
}
// DmgGT applies the GT predicate on the "dmg" field.
func DmgGT(v uint) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.GT(s.C(FieldDmg), v))
})
return predicate.Weapon(sql.FieldGT(FieldDmg, v))
}
// DmgGTE applies the GTE predicate on the "dmg" field.
func DmgGTE(v uint) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.GTE(s.C(FieldDmg), v))
})
return predicate.Weapon(sql.FieldGTE(FieldDmg, v))
}
// DmgLT applies the LT predicate on the "dmg" field.
func DmgLT(v uint) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.LT(s.C(FieldDmg), v))
})
return predicate.Weapon(sql.FieldLT(FieldDmg, v))
}
// DmgLTE applies the LTE predicate on the "dmg" field.
func DmgLTE(v uint) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.LTE(s.C(FieldDmg), v))
})
return predicate.Weapon(sql.FieldLTE(FieldDmg, v))
}
// EqTypeEQ applies the EQ predicate on the "eq_type" field.
func EqTypeEQ(v int) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldEqType), v))
})
return predicate.Weapon(sql.FieldEQ(FieldEqType, v))
}
// EqTypeNEQ applies the NEQ predicate on the "eq_type" field.
func EqTypeNEQ(v int) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.NEQ(s.C(FieldEqType), v))
})
return predicate.Weapon(sql.FieldNEQ(FieldEqType, v))
}
// EqTypeIn applies the In predicate on the "eq_type" field.
func EqTypeIn(vs ...int) predicate.Weapon {
v := make([]interface{}, len(vs))
for i := range v {
v[i] = vs[i]
}
return predicate.Weapon(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...))
})
return predicate.Weapon(sql.FieldIn(FieldEqType, vs...))
}
// EqTypeNotIn applies the NotIn predicate on the "eq_type" field.
func EqTypeNotIn(vs ...int) predicate.Weapon {
v := make([]interface{}, len(vs))
for i := range v {
v[i] = vs[i]
}
return predicate.Weapon(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...))
})
return predicate.Weapon(sql.FieldNotIn(FieldEqType, vs...))
}
// EqTypeGT applies the GT predicate on the "eq_type" field.
func EqTypeGT(v int) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.GT(s.C(FieldEqType), v))
})
return predicate.Weapon(sql.FieldGT(FieldEqType, v))
}
// EqTypeGTE applies the GTE predicate on the "eq_type" field.
func EqTypeGTE(v int) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.GTE(s.C(FieldEqType), v))
})
return predicate.Weapon(sql.FieldGTE(FieldEqType, v))
}
// EqTypeLT applies the LT predicate on the "eq_type" field.
func EqTypeLT(v int) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.LT(s.C(FieldEqType), v))
})
return predicate.Weapon(sql.FieldLT(FieldEqType, v))
}
// EqTypeLTE applies the LTE predicate on the "eq_type" field.
func EqTypeLTE(v int) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.LTE(s.C(FieldEqType), v))
})
return predicate.Weapon(sql.FieldLTE(FieldEqType, v))
}
// HitGroupEQ applies the EQ predicate on the "hit_group" field.
func HitGroupEQ(v int) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldHitGroup), v))
})
return predicate.Weapon(sql.FieldEQ(FieldHitGroup, v))
}
// HitGroupNEQ applies the NEQ predicate on the "hit_group" field.
func HitGroupNEQ(v int) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.NEQ(s.C(FieldHitGroup), v))
})
return predicate.Weapon(sql.FieldNEQ(FieldHitGroup, v))
}
// HitGroupIn applies the In predicate on the "hit_group" field.
func HitGroupIn(vs ...int) predicate.Weapon {
v := make([]interface{}, len(vs))
for i := range v {
v[i] = vs[i]
}
return predicate.Weapon(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...))
})
return predicate.Weapon(sql.FieldIn(FieldHitGroup, vs...))
}
// HitGroupNotIn applies the NotIn predicate on the "hit_group" field.
func HitGroupNotIn(vs ...int) predicate.Weapon {
v := make([]interface{}, len(vs))
for i := range v {
v[i] = vs[i]
}
return predicate.Weapon(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...))
})
return predicate.Weapon(sql.FieldNotIn(FieldHitGroup, vs...))
}
// HitGroupGT applies the GT predicate on the "hit_group" field.
func HitGroupGT(v int) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.GT(s.C(FieldHitGroup), v))
})
return predicate.Weapon(sql.FieldGT(FieldHitGroup, v))
}
// HitGroupGTE applies the GTE predicate on the "hit_group" field.
func HitGroupGTE(v int) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.GTE(s.C(FieldHitGroup), v))
})
return predicate.Weapon(sql.FieldGTE(FieldHitGroup, v))
}
// HitGroupLT applies the LT predicate on the "hit_group" field.
func HitGroupLT(v int) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.LT(s.C(FieldHitGroup), v))
})
return predicate.Weapon(sql.FieldLT(FieldHitGroup, v))
}
// HitGroupLTE applies the LTE predicate on the "hit_group" field.
func HitGroupLTE(v int) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.LTE(s.C(FieldHitGroup), v))
})
return predicate.Weapon(sql.FieldLTE(FieldHitGroup, v))
}
// HasStat applies the HasEdge predicate on the "stat" edge.
@@ -429,7 +238,6 @@ func HasStat() predicate.Weapon {
return predicate.Weapon(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)
@@ -439,11 +247,7 @@ func HasStat() predicate.Weapon {
// HasStatWith applies the HasEdge predicate on the "stat" edge with a given conditions (other predicates).
func HasStatWith(preds ...predicate.MatchPlayer) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(StatInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, StatTable, StatColumn),
)
step := newStatStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)

View File

@@ -1,16 +1,16 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"csgowtfd/ent/matchplayer"
"csgowtfd/ent/weapon"
"errors"
"fmt"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"somegit.dev/csgowtf/csgowtfd/ent/matchplayer"
"somegit.dev/csgowtf/csgowtfd/ent/weapon"
)
// WeaponCreate is the builder for creating a Weapon entity.
@@ -70,43 +70,7 @@ func (wc *WeaponCreate) Mutation() *WeaponMutation {
// Save creates the Weapon in the database.
func (wc *WeaponCreate) Save(ctx context.Context) (*Weapon, error) {
var (
err error
node *Weapon
)
if len(wc.hooks) == 0 {
if err = wc.check(); err != nil {
return nil, err
}
node, err = wc.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*WeaponMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = wc.check(); err != nil {
return nil, err
}
wc.mutation = mutation
if node, err = wc.sqlSave(ctx); err != nil {
return nil, err
}
mutation.id = &node.ID
mutation.done = true
return node, err
})
for i := len(wc.hooks) - 1; i >= 0; i-- {
if wc.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = wc.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, wc.mutation); err != nil {
return nil, err
}
}
return node, err
return withHooks(ctx, wc.sqlSave, wc.mutation, wc.hooks)
}
// SaveX calls Save and panics if Save returns an error.
@@ -149,59 +113,42 @@ func (wc *WeaponCreate) check() error {
}
func (wc *WeaponCreate) sqlSave(ctx context.Context) (*Weapon, error) {
if err := wc.check(); err != nil {
return nil, err
}
_node, _spec := wc.createSpec()
if err := sqlgraph.CreateNode(ctx, wc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
id := _spec.ID.Value.(int64)
_node.ID = int(id)
wc.mutation.id = &_node.ID
wc.mutation.done = true
return _node, nil
}
func (wc *WeaponCreate) createSpec() (*Weapon, *sqlgraph.CreateSpec) {
var (
_node = &Weapon{config: wc.config}
_spec = &sqlgraph.CreateSpec{
Table: weapon.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: weapon.FieldID,
},
}
_spec = sqlgraph.NewCreateSpec(weapon.Table, sqlgraph.NewFieldSpec(weapon.FieldID, field.TypeInt))
)
if value, ok := wc.mutation.Victim(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeUint64,
Value: value,
Column: weapon.FieldVictim,
})
_spec.SetField(weapon.FieldVictim, field.TypeUint64, value)
_node.Victim = value
}
if value, ok := wc.mutation.Dmg(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: weapon.FieldDmg,
})
_spec.SetField(weapon.FieldDmg, field.TypeUint, value)
_node.Dmg = value
}
if value, ok := wc.mutation.EqType(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: weapon.FieldEqType,
})
_spec.SetField(weapon.FieldEqType, field.TypeInt, value)
_node.EqType = value
}
if value, ok := wc.mutation.HitGroup(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: weapon.FieldHitGroup,
})
_spec.SetField(weapon.FieldHitGroup, field.TypeInt, value)
_node.HitGroup = value
}
if nodes := wc.mutation.StatIDs(); len(nodes) > 0 {
@@ -212,10 +159,7 @@ func (wc *WeaponCreate) createSpec() (*Weapon, *sqlgraph.CreateSpec) {
Columns: []string{weapon.StatColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
@@ -250,8 +194,8 @@ func (wcb *WeaponCreateBulk) Save(ctx context.Context) ([]*Weapon, error) {
return nil, err
}
builder.mutation = mutation
nodes[i], specs[i] = builder.createSpec()
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, wcb.builders[i+1].mutation)
} else {
@@ -259,7 +203,7 @@ func (wcb *WeaponCreateBulk) Save(ctx context.Context) ([]*Weapon, error) {
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, wcb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
@@ -267,11 +211,11 @@ func (wcb *WeaponCreateBulk) Save(ctx context.Context) ([]*Weapon, error) {
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)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -1,16 +1,15 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"csgowtfd/ent/predicate"
"csgowtfd/ent/weapon"
"fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"somegit.dev/csgowtf/csgowtfd/ent/predicate"
"somegit.dev/csgowtf/csgowtfd/ent/weapon"
)
// WeaponDelete is the builder for deleting a Weapon entity.
@@ -28,34 +27,7 @@ func (wd *WeaponDelete) Where(ps ...predicate.Weapon) *WeaponDelete {
// Exec executes the deletion query and returns how many vertices were deleted.
func (wd *WeaponDelete) Exec(ctx context.Context) (int, error) {
var (
err error
affected int
)
if len(wd.hooks) == 0 {
affected, err = wd.sqlExec(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*WeaponMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
wd.mutation = mutation
affected, err = wd.sqlExec(ctx)
mutation.done = true
return affected, err
})
for i := len(wd.hooks) - 1; i >= 0; i-- {
if wd.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = wd.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, wd.mutation); err != nil {
return 0, err
}
}
return affected, err
return withHooks(ctx, wd.sqlExec, wd.mutation, wd.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
@@ -68,15 +40,7 @@ func (wd *WeaponDelete) ExecX(ctx context.Context) int {
}
func (wd *WeaponDelete) sqlExec(ctx context.Context) (int, error) {
_spec := &sqlgraph.DeleteSpec{
Node: &sqlgraph.NodeSpec{
Table: weapon.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: weapon.FieldID,
},
},
}
_spec := sqlgraph.NewDeleteSpec(weapon.Table, sqlgraph.NewFieldSpec(weapon.FieldID, field.TypeInt))
if ps := wd.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
@@ -84,7 +48,12 @@ func (wd *WeaponDelete) sqlExec(ctx context.Context) (int, error) {
}
}
}
return sqlgraph.DeleteNodes(ctx, wd.driver, _spec)
affected, err := sqlgraph.DeleteNodes(ctx, wd.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
wd.mutation.done = true
return affected, err
}
// WeaponDeleteOne is the builder for deleting a single Weapon entity.
@@ -92,6 +61,12 @@ type WeaponDeleteOne struct {
wd *WeaponDelete
}
// Where appends a list predicates to the WeaponDelete builder.
func (wdo *WeaponDeleteOne) Where(ps ...predicate.Weapon) *WeaponDeleteOne {
wdo.wd.mutation.Where(ps...)
return wdo
}
// Exec executes the deletion query.
func (wdo *WeaponDeleteOne) Exec(ctx context.Context) error {
n, err := wdo.wd.Exec(ctx)
@@ -107,5 +82,7 @@ func (wdo *WeaponDeleteOne) Exec(ctx context.Context) error {
// ExecX is like Exec, but panics if an error occurs.
func (wdo *WeaponDeleteOne) ExecX(ctx context.Context) {
wdo.wd.ExecX(ctx)
if err := wdo.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -1,34 +1,30 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"csgowtfd/ent/matchplayer"
"csgowtfd/ent/predicate"
"csgowtfd/ent/weapon"
"errors"
"fmt"
"math"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"somegit.dev/csgowtf/csgowtfd/ent/matchplayer"
"somegit.dev/csgowtf/csgowtfd/ent/predicate"
"somegit.dev/csgowtf/csgowtfd/ent/weapon"
)
// WeaponQuery is the builder for querying Weapon entities.
type WeaponQuery struct {
config
limit *int
offset *int
unique *bool
order []OrderFunc
fields []string
ctx *QueryContext
order []weapon.OrderOption
inters []Interceptor
predicates []predicate.Weapon
// eager-loading edges.
withStat *MatchPlayerQuery
withFKs bool
modifiers []func(s *sql.Selector)
modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -40,34 +36,34 @@ func (wq *WeaponQuery) Where(ps ...predicate.Weapon) *WeaponQuery {
return wq
}
// Limit adds a limit step to the query.
// Limit the number of records to be returned by this query.
func (wq *WeaponQuery) Limit(limit int) *WeaponQuery {
wq.limit = &limit
wq.ctx.Limit = &limit
return wq
}
// Offset adds an offset step to the query.
// Offset to start from.
func (wq *WeaponQuery) Offset(offset int) *WeaponQuery {
wq.offset = &offset
wq.ctx.Offset = &offset
return wq
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (wq *WeaponQuery) Unique(unique bool) *WeaponQuery {
wq.unique = &unique
wq.ctx.Unique = &unique
return wq
}
// Order adds an order step to the query.
func (wq *WeaponQuery) Order(o ...OrderFunc) *WeaponQuery {
// Order specifies how the records should be ordered.
func (wq *WeaponQuery) Order(o ...weapon.OrderOption) *WeaponQuery {
wq.order = append(wq.order, o...)
return wq
}
// QueryStat chains the current query on the "stat" edge.
func (wq *WeaponQuery) QueryStat() *MatchPlayerQuery {
query := &MatchPlayerQuery{config: wq.config}
query := (&MatchPlayerClient{config: wq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := wq.prepareQuery(ctx); err != nil {
return nil, err
@@ -90,7 +86,7 @@ func (wq *WeaponQuery) QueryStat() *MatchPlayerQuery {
// First returns the first Weapon entity from the query.
// Returns a *NotFoundError when no Weapon was found.
func (wq *WeaponQuery) First(ctx context.Context) (*Weapon, error) {
nodes, err := wq.Limit(1).All(ctx)
nodes, err := wq.Limit(1).All(setContextOp(ctx, wq.ctx, "First"))
if err != nil {
return nil, err
}
@@ -113,7 +109,7 @@ func (wq *WeaponQuery) FirstX(ctx context.Context) *Weapon {
// Returns a *NotFoundError when no Weapon ID was found.
func (wq *WeaponQuery) FirstID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = wq.Limit(1).IDs(ctx); err != nil {
if ids, err = wq.Limit(1).IDs(setContextOp(ctx, wq.ctx, "FirstID")); err != nil {
return
}
if len(ids) == 0 {
@@ -133,10 +129,10 @@ func (wq *WeaponQuery) FirstIDX(ctx context.Context) int {
}
// Only returns a single Weapon entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when exactly one Weapon entity is not found.
// Returns a *NotSingularError when more than one Weapon entity is found.
// Returns a *NotFoundError when no Weapon entities are found.
func (wq *WeaponQuery) Only(ctx context.Context) (*Weapon, error) {
nodes, err := wq.Limit(2).All(ctx)
nodes, err := wq.Limit(2).All(setContextOp(ctx, wq.ctx, "Only"))
if err != nil {
return nil, err
}
@@ -160,11 +156,11 @@ func (wq *WeaponQuery) OnlyX(ctx context.Context) *Weapon {
}
// OnlyID is like Only, but returns the only Weapon ID in the query.
// Returns a *NotSingularError when exactly one Weapon ID is not found.
// Returns a *NotSingularError when more than one Weapon ID is found.
// Returns a *NotFoundError when no entities are found.
func (wq *WeaponQuery) OnlyID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = wq.Limit(2).IDs(ctx); err != nil {
if ids, err = wq.Limit(2).IDs(setContextOp(ctx, wq.ctx, "OnlyID")); err != nil {
return
}
switch len(ids) {
@@ -189,10 +185,12 @@ func (wq *WeaponQuery) OnlyIDX(ctx context.Context) int {
// All executes the query and returns a list of Weapons.
func (wq *WeaponQuery) All(ctx context.Context) ([]*Weapon, error) {
ctx = setContextOp(ctx, wq.ctx, "All")
if err := wq.prepareQuery(ctx); err != nil {
return nil, err
}
return wq.sqlAll(ctx)
qr := querierAll[[]*Weapon, *WeaponQuery]()
return withInterceptors[[]*Weapon](ctx, wq, qr, wq.inters)
}
// AllX is like All, but panics if an error occurs.
@@ -205,9 +203,12 @@ func (wq *WeaponQuery) AllX(ctx context.Context) []*Weapon {
}
// IDs executes the query and returns a list of Weapon IDs.
func (wq *WeaponQuery) IDs(ctx context.Context) ([]int, error) {
var ids []int
if err := wq.Select(weapon.FieldID).Scan(ctx, &ids); err != nil {
func (wq *WeaponQuery) IDs(ctx context.Context) (ids []int, err error) {
if wq.ctx.Unique == nil && wq.path != nil {
wq.Unique(true)
}
ctx = setContextOp(ctx, wq.ctx, "IDs")
if err = wq.Select(weapon.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
@@ -224,10 +225,11 @@ func (wq *WeaponQuery) IDsX(ctx context.Context) []int {
// Count returns the count of the given query.
func (wq *WeaponQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, wq.ctx, "Count")
if err := wq.prepareQuery(ctx); err != nil {
return 0, err
}
return wq.sqlCount(ctx)
return withInterceptors[int](ctx, wq, querierCount[*WeaponQuery](), wq.inters)
}
// CountX is like Count, but panics if an error occurs.
@@ -241,10 +243,15 @@ func (wq *WeaponQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph.
func (wq *WeaponQuery) Exist(ctx context.Context) (bool, error) {
if err := wq.prepareQuery(ctx); err != nil {
return false, err
ctx = setContextOp(ctx, wq.ctx, "Exist")
switch _, err := wq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
return wq.sqlExist(ctx)
}
// ExistX is like Exist, but panics if an error occurs.
@@ -264,9 +271,9 @@ func (wq *WeaponQuery) Clone() *WeaponQuery {
}
return &WeaponQuery{
config: wq.config,
limit: wq.limit,
offset: wq.offset,
order: append([]OrderFunc{}, wq.order...),
ctx: wq.ctx.Clone(),
order: append([]weapon.OrderOption{}, wq.order...),
inters: append([]Interceptor{}, wq.inters...),
predicates: append([]predicate.Weapon{}, wq.predicates...),
withStat: wq.withStat.Clone(),
// clone intermediate query.
@@ -278,7 +285,7 @@ func (wq *WeaponQuery) Clone() *WeaponQuery {
// WithStat tells the query-builder to eager-load the nodes that are connected to
// the "stat" edge. The optional arguments are used to configure the query builder of the edge.
func (wq *WeaponQuery) WithStat(opts ...func(*MatchPlayerQuery)) *WeaponQuery {
query := &MatchPlayerQuery{config: wq.config}
query := (&MatchPlayerClient{config: wq.config}).Query()
for _, opt := range opts {
opt(query)
}
@@ -300,17 +307,13 @@ func (wq *WeaponQuery) WithStat(opts ...func(*MatchPlayerQuery)) *WeaponQuery {
// GroupBy(weapon.FieldVictim).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
//
func (wq *WeaponQuery) GroupBy(field string, fields ...string) *WeaponGroupBy {
group := &WeaponGroupBy{config: wq.config}
group.fields = append([]string{field}, fields...)
group.path = func(ctx context.Context) (prev *sql.Selector, err error) {
if err := wq.prepareQuery(ctx); err != nil {
return nil, err
}
return wq.sqlQuery(ctx), nil
}
return group
wq.ctx.Fields = append([]string{field}, fields...)
grbuild := &WeaponGroupBy{build: wq}
grbuild.flds = &wq.ctx.Fields
grbuild.label = weapon.Label
grbuild.scan = grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
@@ -325,14 +328,31 @@ func (wq *WeaponQuery) GroupBy(field string, fields ...string) *WeaponGroupBy {
// client.Weapon.Query().
// Select(weapon.FieldVictim).
// Scan(ctx, &v)
//
func (wq *WeaponQuery) Select(fields ...string) *WeaponSelect {
wq.fields = append(wq.fields, fields...)
return &WeaponSelect{WeaponQuery: wq}
wq.ctx.Fields = append(wq.ctx.Fields, fields...)
sbuild := &WeaponSelect{WeaponQuery: wq}
sbuild.label = weapon.Label
sbuild.flds, sbuild.scan = &wq.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a WeaponSelect configured with the given aggregations.
func (wq *WeaponQuery) Aggregate(fns ...AggregateFunc) *WeaponSelect {
return wq.Select().Aggregate(fns...)
}
func (wq *WeaponQuery) prepareQuery(ctx context.Context) error {
for _, f := range wq.fields {
for _, inter := range wq.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, wq); err != nil {
return err
}
}
}
for _, f := range wq.ctx.Fields {
if !weapon.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
@@ -347,7 +367,7 @@ func (wq *WeaponQuery) prepareQuery(ctx context.Context) error {
return nil
}
func (wq *WeaponQuery) sqlAll(ctx context.Context) ([]*Weapon, error) {
func (wq *WeaponQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Weapon, error) {
var (
nodes = []*Weapon{}
withFKs = wq.withFKs
@@ -362,30 +382,37 @@ func (wq *WeaponQuery) sqlAll(ctx context.Context) ([]*Weapon, error) {
if withFKs {
_spec.Node.Columns = append(_spec.Node.Columns, weapon.ForeignKeys...)
}
_spec.ScanValues = func(columns []string) ([]interface{}, error) {
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*Weapon).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []any) error {
node := &Weapon{config: wq.config}
nodes = append(nodes, node)
return node.scanValues(columns)
}
_spec.Assign = func(columns []string, values []interface{}) error {
if len(nodes) == 0 {
return fmt.Errorf("ent: Assign called without calling ScanValues")
}
node := nodes[len(nodes)-1]
node.Edges.loadedTypes = loadedTypes
return node.assignValues(columns, values)
}
if len(wq.modifiers) > 0 {
_spec.Modifiers = wq.modifiers
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, wq.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
if query := wq.withStat; query != nil {
if err := wq.loadStat(ctx, query, nodes, nil,
func(n *Weapon, e *MatchPlayer) { n.Edges.Stat = e }); err != nil {
return nil, err
}
}
return nodes, nil
}
func (wq *WeaponQuery) loadStat(ctx context.Context, query *MatchPlayerQuery, nodes []*Weapon, init func(*Weapon), assign func(*Weapon, *MatchPlayer)) error {
ids := make([]int, 0, len(nodes))
nodeids := make(map[int][]*Weapon)
for i := range nodes {
@@ -398,23 +425,24 @@ func (wq *WeaponQuery) sqlAll(ctx context.Context) ([]*Weapon, error) {
}
nodeids[fk] = append(nodeids[fk], nodes[i])
}
if len(ids) == 0 {
return nil
}
query.Where(matchplayer.IDIn(ids...))
neighbors, err := query.All(ctx)
if err != nil {
return nil, err
return err
}
for _, n := range neighbors {
nodes, ok := nodeids[n.ID]
if !ok {
return nil, fmt.Errorf(`unexpected foreign-key "match_player_weapon_stats" returned %v`, n.ID)
return fmt.Errorf(`unexpected foreign-key "match_player_weapon_stats" returned %v`, n.ID)
}
for i := range nodes {
nodes[i].Edges.Stat = n
assign(nodes[i], n)
}
}
}
return nodes, nil
return nil
}
func (wq *WeaponQuery) sqlCount(ctx context.Context) (int, error) {
@@ -422,38 +450,22 @@ func (wq *WeaponQuery) sqlCount(ctx context.Context) (int, error) {
if len(wq.modifiers) > 0 {
_spec.Modifiers = wq.modifiers
}
_spec.Node.Columns = wq.fields
if len(wq.fields) > 0 {
_spec.Unique = wq.unique != nil && *wq.unique
_spec.Node.Columns = wq.ctx.Fields
if len(wq.ctx.Fields) > 0 {
_spec.Unique = wq.ctx.Unique != nil && *wq.ctx.Unique
}
return sqlgraph.CountNodes(ctx, wq.driver, _spec)
}
func (wq *WeaponQuery) sqlExist(ctx context.Context) (bool, error) {
n, err := wq.sqlCount(ctx)
if err != nil {
return false, fmt.Errorf("ent: check existence: %w", err)
}
return n > 0, nil
}
func (wq *WeaponQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{
Node: &sqlgraph.NodeSpec{
Table: weapon.Table,
Columns: weapon.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: weapon.FieldID,
},
},
From: wq.sql,
Unique: true,
}
if unique := wq.unique; unique != nil {
_spec := sqlgraph.NewQuerySpec(weapon.Table, weapon.Columns, sqlgraph.NewFieldSpec(weapon.FieldID, field.TypeInt))
_spec.From = wq.sql
if unique := wq.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if wq.path != nil {
_spec.Unique = true
}
if fields := wq.fields; len(fields) > 0 {
if fields := wq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, weapon.FieldID)
for i := range fields {
@@ -469,10 +481,10 @@ func (wq *WeaponQuery) querySpec() *sqlgraph.QuerySpec {
}
}
}
if limit := wq.limit; limit != nil {
if limit := wq.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := wq.offset; offset != nil {
if offset := wq.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := wq.order; len(ps) > 0 {
@@ -488,7 +500,7 @@ func (wq *WeaponQuery) querySpec() *sqlgraph.QuerySpec {
func (wq *WeaponQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(wq.driver.Dialect())
t1 := builder.Table(weapon.Table)
columns := wq.fields
columns := wq.ctx.Fields
if len(columns) == 0 {
columns = weapon.Columns
}
@@ -497,7 +509,7 @@ func (wq *WeaponQuery) sqlQuery(ctx context.Context) *sql.Selector {
selector = wq.sql
selector.Select(selector.Columns(columns...)...)
}
if wq.unique != nil && *wq.unique {
if wq.ctx.Unique != nil && *wq.ctx.Unique {
selector.Distinct()
}
for _, m := range wq.modifiers {
@@ -509,12 +521,12 @@ func (wq *WeaponQuery) sqlQuery(ctx context.Context) *sql.Selector {
for _, p := range wq.order {
p(selector)
}
if offset := wq.offset; offset != nil {
if offset := wq.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := wq.limit; limit != nil {
if limit := wq.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
@@ -528,12 +540,8 @@ func (wq *WeaponQuery) Modify(modifiers ...func(s *sql.Selector)) *WeaponSelect
// WeaponGroupBy is the group-by builder for Weapon entities.
type WeaponGroupBy struct {
config
fields []string
fns []AggregateFunc
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
selector
build *WeaponQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
@@ -542,471 +550,77 @@ func (wgb *WeaponGroupBy) Aggregate(fns ...AggregateFunc) *WeaponGroupBy {
return wgb
}
// Scan applies the group-by query and scans the result into the given value.
func (wgb *WeaponGroupBy) Scan(ctx context.Context, v interface{}) error {
query, err := wgb.path(ctx)
if err != nil {
// Scan applies the selector query and scans the result into the given value.
func (wgb *WeaponGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, wgb.build.ctx, "GroupBy")
if err := wgb.build.prepareQuery(ctx); err != nil {
return err
}
wgb.sql = query
return wgb.sqlScan(ctx, v)
return scanWithInterceptors[*WeaponQuery, *WeaponGroupBy](ctx, wgb.build, wgb, wgb.build.inters, v)
}
// ScanX is like Scan, but panics if an error occurs.
func (wgb *WeaponGroupBy) ScanX(ctx context.Context, v interface{}) {
if err := wgb.Scan(ctx, v); err != nil {
panic(err)
func (wgb *WeaponGroupBy) sqlScan(ctx context.Context, root *WeaponQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(wgb.fns))
for _, fn := range wgb.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*wgb.flds)+len(wgb.fns))
for _, f := range *wgb.flds {
columns = append(columns, selector.C(f))
}
// Strings returns list of strings from group-by.
// It is only allowed when executing a group-by query with one field.
func (wgb *WeaponGroupBy) Strings(ctx context.Context) ([]string, error) {
if len(wgb.fields) > 1 {
return nil, errors.New("ent: WeaponGroupBy.Strings is not achievable when grouping more than 1 field")
columns = append(columns, aggregation...)
selector.Select(columns...)
}
var v []string
if err := wgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// StringsX is like Strings, but panics if an error occurs.
func (wgb *WeaponGroupBy) StringsX(ctx context.Context) []string {
v, err := wgb.Strings(ctx)
if err != nil {
panic(err)
}
return v
}
// String returns a single string from a group-by query.
// It is only allowed when executing a group-by query with one field.
func (wgb *WeaponGroupBy) String(ctx context.Context) (_ string, err error) {
var v []string
if v, err = wgb.Strings(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{weapon.Label}
default:
err = fmt.Errorf("ent: WeaponGroupBy.Strings returned %d results when one was expected", len(v))
}
return
}
// StringX is like String, but panics if an error occurs.
func (wgb *WeaponGroupBy) StringX(ctx context.Context) string {
v, err := wgb.String(ctx)
if err != nil {
panic(err)
}
return v
}
// Ints returns list of ints from group-by.
// It is only allowed when executing a group-by query with one field.
func (wgb *WeaponGroupBy) Ints(ctx context.Context) ([]int, error) {
if len(wgb.fields) > 1 {
return nil, errors.New("ent: WeaponGroupBy.Ints is not achievable when grouping more than 1 field")
}
var v []int
if err := wgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// IntsX is like Ints, but panics if an error occurs.
func (wgb *WeaponGroupBy) IntsX(ctx context.Context) []int {
v, err := wgb.Ints(ctx)
if err != nil {
panic(err)
}
return v
}
// Int returns a single int from a group-by query.
// It is only allowed when executing a group-by query with one field.
func (wgb *WeaponGroupBy) Int(ctx context.Context) (_ int, err error) {
var v []int
if v, err = wgb.Ints(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{weapon.Label}
default:
err = fmt.Errorf("ent: WeaponGroupBy.Ints returned %d results when one was expected", len(v))
}
return
}
// IntX is like Int, but panics if an error occurs.
func (wgb *WeaponGroupBy) IntX(ctx context.Context) int {
v, err := wgb.Int(ctx)
if err != nil {
panic(err)
}
return v
}
// Float64s returns list of float64s from group-by.
// It is only allowed when executing a group-by query with one field.
func (wgb *WeaponGroupBy) Float64s(ctx context.Context) ([]float64, error) {
if len(wgb.fields) > 1 {
return nil, errors.New("ent: WeaponGroupBy.Float64s is not achievable when grouping more than 1 field")
}
var v []float64
if err := wgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// Float64sX is like Float64s, but panics if an error occurs.
func (wgb *WeaponGroupBy) Float64sX(ctx context.Context) []float64 {
v, err := wgb.Float64s(ctx)
if err != nil {
panic(err)
}
return v
}
// Float64 returns a single float64 from a group-by query.
// It is only allowed when executing a group-by query with one field.
func (wgb *WeaponGroupBy) Float64(ctx context.Context) (_ float64, err error) {
var v []float64
if v, err = wgb.Float64s(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{weapon.Label}
default:
err = fmt.Errorf("ent: WeaponGroupBy.Float64s returned %d results when one was expected", len(v))
}
return
}
// Float64X is like Float64, but panics if an error occurs.
func (wgb *WeaponGroupBy) Float64X(ctx context.Context) float64 {
v, err := wgb.Float64(ctx)
if err != nil {
panic(err)
}
return v
}
// Bools returns list of bools from group-by.
// It is only allowed when executing a group-by query with one field.
func (wgb *WeaponGroupBy) Bools(ctx context.Context) ([]bool, error) {
if len(wgb.fields) > 1 {
return nil, errors.New("ent: WeaponGroupBy.Bools is not achievable when grouping more than 1 field")
}
var v []bool
if err := wgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// BoolsX is like Bools, but panics if an error occurs.
func (wgb *WeaponGroupBy) BoolsX(ctx context.Context) []bool {
v, err := wgb.Bools(ctx)
if err != nil {
panic(err)
}
return v
}
// Bool returns a single bool from a group-by query.
// It is only allowed when executing a group-by query with one field.
func (wgb *WeaponGroupBy) Bool(ctx context.Context) (_ bool, err error) {
var v []bool
if v, err = wgb.Bools(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{weapon.Label}
default:
err = fmt.Errorf("ent: WeaponGroupBy.Bools returned %d results when one was expected", len(v))
}
return
}
// BoolX is like Bool, but panics if an error occurs.
func (wgb *WeaponGroupBy) BoolX(ctx context.Context) bool {
v, err := wgb.Bool(ctx)
if err != nil {
panic(err)
}
return v
}
func (wgb *WeaponGroupBy) sqlScan(ctx context.Context, v interface{}) error {
for _, f := range wgb.fields {
if !weapon.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)}
}
}
selector := wgb.sqlQuery()
selector.GroupBy(selector.Columns(*wgb.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := wgb.driver.Query(ctx, query, args, rows); err != nil {
if err := wgb.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
func (wgb *WeaponGroupBy) sqlQuery() *sql.Selector {
selector := wgb.sql.Select()
aggregation := make([]string, 0, len(wgb.fns))
for _, fn := range wgb.fns {
aggregation = append(aggregation, fn(selector))
}
// If no columns were selected in a custom aggregation function, the default
// selection is the fields used for "group-by", and the aggregation functions.
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(wgb.fields)+len(wgb.fns))
for _, f := range wgb.fields {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
return selector.GroupBy(selector.Columns(wgb.fields...)...)
}
// WeaponSelect is the builder for selecting fields of Weapon entities.
type WeaponSelect struct {
*WeaponQuery
// intermediate query (i.e. traversal path).
sql *sql.Selector
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (ws *WeaponSelect) Aggregate(fns ...AggregateFunc) *WeaponSelect {
ws.fns = append(ws.fns, fns...)
return ws
}
// Scan applies the selector query and scans the result into the given value.
func (ws *WeaponSelect) Scan(ctx context.Context, v interface{}) error {
func (ws *WeaponSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, ws.ctx, "Select")
if err := ws.prepareQuery(ctx); err != nil {
return err
}
ws.sql = ws.WeaponQuery.sqlQuery(ctx)
return ws.sqlScan(ctx, v)
return scanWithInterceptors[*WeaponQuery, *WeaponSelect](ctx, ws.WeaponQuery, ws, ws.inters, v)
}
// ScanX is like Scan, but panics if an error occurs.
func (ws *WeaponSelect) ScanX(ctx context.Context, v interface{}) {
if err := ws.Scan(ctx, v); err != nil {
panic(err)
func (ws *WeaponSelect) sqlScan(ctx context.Context, root *WeaponQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(ws.fns))
for _, fn := range ws.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*ws.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
// Strings returns list of strings from a selector. It is only allowed when selecting one field.
func (ws *WeaponSelect) Strings(ctx context.Context) ([]string, error) {
if len(ws.fields) > 1 {
return nil, errors.New("ent: WeaponSelect.Strings is not achievable when selecting more than 1 field")
}
var v []string
if err := ws.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// StringsX is like Strings, but panics if an error occurs.
func (ws *WeaponSelect) StringsX(ctx context.Context) []string {
v, err := ws.Strings(ctx)
if err != nil {
panic(err)
}
return v
}
// String returns a single string from a selector. It is only allowed when selecting one field.
func (ws *WeaponSelect) String(ctx context.Context) (_ string, err error) {
var v []string
if v, err = ws.Strings(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{weapon.Label}
default:
err = fmt.Errorf("ent: WeaponSelect.Strings returned %d results when one was expected", len(v))
}
return
}
// StringX is like String, but panics if an error occurs.
func (ws *WeaponSelect) StringX(ctx context.Context) string {
v, err := ws.String(ctx)
if err != nil {
panic(err)
}
return v
}
// Ints returns list of ints from a selector. It is only allowed when selecting one field.
func (ws *WeaponSelect) Ints(ctx context.Context) ([]int, error) {
if len(ws.fields) > 1 {
return nil, errors.New("ent: WeaponSelect.Ints is not achievable when selecting more than 1 field")
}
var v []int
if err := ws.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// IntsX is like Ints, but panics if an error occurs.
func (ws *WeaponSelect) IntsX(ctx context.Context) []int {
v, err := ws.Ints(ctx)
if err != nil {
panic(err)
}
return v
}
// Int returns a single int from a selector. It is only allowed when selecting one field.
func (ws *WeaponSelect) Int(ctx context.Context) (_ int, err error) {
var v []int
if v, err = ws.Ints(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{weapon.Label}
default:
err = fmt.Errorf("ent: WeaponSelect.Ints returned %d results when one was expected", len(v))
}
return
}
// IntX is like Int, but panics if an error occurs.
func (ws *WeaponSelect) IntX(ctx context.Context) int {
v, err := ws.Int(ctx)
if err != nil {
panic(err)
}
return v
}
// Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
func (ws *WeaponSelect) Float64s(ctx context.Context) ([]float64, error) {
if len(ws.fields) > 1 {
return nil, errors.New("ent: WeaponSelect.Float64s is not achievable when selecting more than 1 field")
}
var v []float64
if err := ws.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// Float64sX is like Float64s, but panics if an error occurs.
func (ws *WeaponSelect) Float64sX(ctx context.Context) []float64 {
v, err := ws.Float64s(ctx)
if err != nil {
panic(err)
}
return v
}
// Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
func (ws *WeaponSelect) Float64(ctx context.Context) (_ float64, err error) {
var v []float64
if v, err = ws.Float64s(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{weapon.Label}
default:
err = fmt.Errorf("ent: WeaponSelect.Float64s returned %d results when one was expected", len(v))
}
return
}
// Float64X is like Float64, but panics if an error occurs.
func (ws *WeaponSelect) Float64X(ctx context.Context) float64 {
v, err := ws.Float64(ctx)
if err != nil {
panic(err)
}
return v
}
// Bools returns list of bools from a selector. It is only allowed when selecting one field.
func (ws *WeaponSelect) Bools(ctx context.Context) ([]bool, error) {
if len(ws.fields) > 1 {
return nil, errors.New("ent: WeaponSelect.Bools is not achievable when selecting more than 1 field")
}
var v []bool
if err := ws.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// BoolsX is like Bools, but panics if an error occurs.
func (ws *WeaponSelect) BoolsX(ctx context.Context) []bool {
v, err := ws.Bools(ctx)
if err != nil {
panic(err)
}
return v
}
// Bool returns a single bool from a selector. It is only allowed when selecting one field.
func (ws *WeaponSelect) Bool(ctx context.Context) (_ bool, err error) {
var v []bool
if v, err = ws.Bools(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{weapon.Label}
default:
err = fmt.Errorf("ent: WeaponSelect.Bools returned %d results when one was expected", len(v))
}
return
}
// BoolX is like Bool, but panics if an error occurs.
func (ws *WeaponSelect) BoolX(ctx context.Context) bool {
v, err := ws.Bool(ctx)
if err != nil {
panic(err)
}
return v
}
func (ws *WeaponSelect) sqlScan(ctx context.Context, v interface{}) error {
rows := &sql.Rows{}
query, args := ws.sql.Query()
query, args := selector.Query()
if err := ws.driver.Query(ctx, query, args, rows); err != nil {
return err
}

View File

@@ -1,18 +1,18 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"csgowtfd/ent/matchplayer"
"csgowtfd/ent/predicate"
"csgowtfd/ent/weapon"
"errors"
"fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"somegit.dev/csgowtf/csgowtfd/ent/matchplayer"
"somegit.dev/csgowtf/csgowtfd/ent/predicate"
"somegit.dev/csgowtf/csgowtfd/ent/weapon"
)
// WeaponUpdate is the builder for updating Weapon entities.
@@ -20,6 +20,7 @@ type WeaponUpdate struct {
config
hooks []Hook
mutation *WeaponMutation
modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the WeaponUpdate builder.
@@ -112,34 +113,7 @@ func (wu *WeaponUpdate) ClearStat() *WeaponUpdate {
// Save executes the query and returns the number of nodes affected by the update operation.
func (wu *WeaponUpdate) Save(ctx context.Context) (int, error) {
var (
err error
affected int
)
if len(wu.hooks) == 0 {
affected, err = wu.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*WeaponMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
wu.mutation = mutation
affected, err = wu.sqlSave(ctx)
mutation.done = true
return affected, err
})
for i := len(wu.hooks) - 1; i >= 0; i-- {
if wu.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = wu.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, wu.mutation); err != nil {
return 0, err
}
}
return affected, err
return withHooks(ctx, wu.sqlSave, wu.mutation, wu.hooks)
}
// SaveX is like Save, but panics if an error occurs.
@@ -164,17 +138,14 @@ func (wu *WeaponUpdate) ExecX(ctx context.Context) {
}
}
func (wu *WeaponUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: weapon.Table,
Columns: weapon.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: weapon.FieldID,
},
},
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (wu *WeaponUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *WeaponUpdate {
wu.modifiers = append(wu.modifiers, modifiers...)
return wu
}
func (wu *WeaponUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := sqlgraph.NewUpdateSpec(weapon.Table, weapon.Columns, sqlgraph.NewFieldSpec(weapon.FieldID, field.TypeInt))
if ps := wu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
@@ -183,60 +154,28 @@ func (wu *WeaponUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
}
if value, ok := wu.mutation.Victim(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeUint64,
Value: value,
Column: weapon.FieldVictim,
})
_spec.SetField(weapon.FieldVictim, field.TypeUint64, value)
}
if value, ok := wu.mutation.AddedVictim(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeUint64,
Value: value,
Column: weapon.FieldVictim,
})
_spec.AddField(weapon.FieldVictim, field.TypeUint64, value)
}
if value, ok := wu.mutation.Dmg(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: weapon.FieldDmg,
})
_spec.SetField(weapon.FieldDmg, field.TypeUint, value)
}
if value, ok := wu.mutation.AddedDmg(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: weapon.FieldDmg,
})
_spec.AddField(weapon.FieldDmg, field.TypeUint, value)
}
if value, ok := wu.mutation.EqType(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: weapon.FieldEqType,
})
_spec.SetField(weapon.FieldEqType, field.TypeInt, value)
}
if value, ok := wu.mutation.AddedEqType(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: weapon.FieldEqType,
})
_spec.AddField(weapon.FieldEqType, field.TypeInt, value)
}
if value, ok := wu.mutation.HitGroup(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: weapon.FieldHitGroup,
})
_spec.SetField(weapon.FieldHitGroup, field.TypeInt, value)
}
if value, ok := wu.mutation.AddedHitGroup(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: weapon.FieldHitGroup,
})
_spec.AddField(weapon.FieldHitGroup, field.TypeInt, value)
}
if wu.mutation.StatCleared() {
edge := &sqlgraph.EdgeSpec{
@@ -246,10 +185,7 @@ func (wu *WeaponUpdate) sqlSave(ctx context.Context) (n int, err error) {
Columns: []string{weapon.StatColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
@@ -262,10 +198,7 @@ func (wu *WeaponUpdate) sqlSave(ctx context.Context) (n int, err error) {
Columns: []string{weapon.StatColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
@@ -273,14 +206,16 @@ func (wu *WeaponUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_spec.AddModifiers(wu.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, wu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{weapon.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
wu.mutation.done = true
return n, nil
}
@@ -290,6 +225,7 @@ type WeaponUpdateOne struct {
fields []string
hooks []Hook
mutation *WeaponMutation
modifiers []func(*sql.UpdateBuilder)
}
// SetVictim sets the "victim" field.
@@ -374,6 +310,12 @@ func (wuo *WeaponUpdateOne) ClearStat() *WeaponUpdateOne {
return wuo
}
// Where appends a list predicates to the WeaponUpdate builder.
func (wuo *WeaponUpdateOne) Where(ps ...predicate.Weapon) *WeaponUpdateOne {
wuo.mutation.Where(ps...)
return wuo
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (wuo *WeaponUpdateOne) Select(field string, fields ...string) *WeaponUpdateOne {
@@ -383,34 +325,7 @@ func (wuo *WeaponUpdateOne) Select(field string, fields ...string) *WeaponUpdate
// Save executes the query and returns the updated Weapon entity.
func (wuo *WeaponUpdateOne) Save(ctx context.Context) (*Weapon, error) {
var (
err error
node *Weapon
)
if len(wuo.hooks) == 0 {
node, err = wuo.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*WeaponMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
wuo.mutation = mutation
node, err = wuo.sqlSave(ctx)
mutation.done = true
return node, err
})
for i := len(wuo.hooks) - 1; i >= 0; i-- {
if wuo.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = wuo.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, wuo.mutation); err != nil {
return nil, err
}
}
return node, err
return withHooks(ctx, wuo.sqlSave, wuo.mutation, wuo.hooks)
}
// SaveX is like Save, but panics if an error occurs.
@@ -435,17 +350,14 @@ func (wuo *WeaponUpdateOne) ExecX(ctx context.Context) {
}
}
func (wuo *WeaponUpdateOne) sqlSave(ctx context.Context) (_node *Weapon, err error) {
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: weapon.Table,
Columns: weapon.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: weapon.FieldID,
},
},
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (wuo *WeaponUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *WeaponUpdateOne {
wuo.modifiers = append(wuo.modifiers, modifiers...)
return wuo
}
func (wuo *WeaponUpdateOne) sqlSave(ctx context.Context) (_node *Weapon, err error) {
_spec := sqlgraph.NewUpdateSpec(weapon.Table, weapon.Columns, sqlgraph.NewFieldSpec(weapon.FieldID, field.TypeInt))
id, ok := wuo.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Weapon.id" for update`)}
@@ -471,60 +383,28 @@ func (wuo *WeaponUpdateOne) sqlSave(ctx context.Context) (_node *Weapon, err err
}
}
if value, ok := wuo.mutation.Victim(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeUint64,
Value: value,
Column: weapon.FieldVictim,
})
_spec.SetField(weapon.FieldVictim, field.TypeUint64, value)
}
if value, ok := wuo.mutation.AddedVictim(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeUint64,
Value: value,
Column: weapon.FieldVictim,
})
_spec.AddField(weapon.FieldVictim, field.TypeUint64, value)
}
if value, ok := wuo.mutation.Dmg(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: weapon.FieldDmg,
})
_spec.SetField(weapon.FieldDmg, field.TypeUint, value)
}
if value, ok := wuo.mutation.AddedDmg(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeUint,
Value: value,
Column: weapon.FieldDmg,
})
_spec.AddField(weapon.FieldDmg, field.TypeUint, value)
}
if value, ok := wuo.mutation.EqType(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: weapon.FieldEqType,
})
_spec.SetField(weapon.FieldEqType, field.TypeInt, value)
}
if value, ok := wuo.mutation.AddedEqType(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: weapon.FieldEqType,
})
_spec.AddField(weapon.FieldEqType, field.TypeInt, value)
}
if value, ok := wuo.mutation.HitGroup(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: weapon.FieldHitGroup,
})
_spec.SetField(weapon.FieldHitGroup, field.TypeInt, value)
}
if value, ok := wuo.mutation.AddedHitGroup(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeInt,
Value: value,
Column: weapon.FieldHitGroup,
})
_spec.AddField(weapon.FieldHitGroup, field.TypeInt, value)
}
if wuo.mutation.StatCleared() {
edge := &sqlgraph.EdgeSpec{
@@ -534,10 +414,7 @@ func (wuo *WeaponUpdateOne) sqlSave(ctx context.Context) (_node *Weapon, err err
Columns: []string{weapon.StatColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
@@ -550,10 +427,7 @@ func (wuo *WeaponUpdateOne) sqlSave(ctx context.Context) (_node *Weapon, err err
Columns: []string{weapon.StatColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: matchplayer.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
@@ -561,6 +435,7 @@ func (wuo *WeaponUpdateOne) sqlSave(ctx context.Context) (_node *Weapon, err err
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_spec.AddModifiers(wuo.modifiers...)
_node = &Weapon{config: wuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
@@ -568,9 +443,10 @@ func (wuo *WeaponUpdateOne) sqlSave(ctx context.Context) (_node *Weapon, err err
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{weapon.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
wuo.mutation.done = true
return _node, nil
}

101
go.mod
View File

@@ -1,64 +1,83 @@
module csgowtfd
module somegit.dev/csgowtf/csgowtfd
go 1.17
go 1.20
require (
entgo.io/ent v0.10.0
entgo.io/ent v0.12.3
github.com/aclements/go-moremath v0.0.0-20210112150236-f10218a38794
github.com/an0nfunc/go-steam/v3 v3.0.6
github.com/an0nfunc/go-steamapi v1.1.0
github.com/go-redis/cache/v8 v8.4.3
github.com/go-redis/redis/v8 v8.11.4
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551
github.com/gorilla/handlers v1.5.1
github.com/gorilla/mux v1.8.0
github.com/jackc/pgx/v4 v4.14.1
github.com/markus-wa/demoinfocs-golang/v2 v2.13.0
github.com/sirupsen/logrus v1.8.1
github.com/an0nfunc/go-steamapi v1.1.3
github.com/gin-contrib/cors v1.4.0
github.com/gin-gonic/gin v1.9.1
github.com/go-redis/cache/v8 v8.4.4
github.com/go-redis/redis/v8 v8.11.5
github.com/golang/geo v0.0.0-20230421003525-6adc56603217
github.com/jackc/pgx/v4 v4.18.1
github.com/markus-wa/demoinfocs-golang/v3 v3.3.0
github.com/pkg/errors v0.9.1
github.com/sethvargo/go-retry v0.2.4
github.com/sirupsen/logrus v1.9.3
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-20210107192922-496545a6307b
golang.org/x/text v0.12.0
golang.org/x/time v0.3.0
google.golang.org/protobuf v1.31.0
gopkg.in/yaml.v3 v3.0.1
somegit.dev/anonfunc/gositemap v0.1.3
)
require (
ariga.io/atlas v0.3.2 // indirect
ariga.io/atlas v0.13.3 // indirect
github.com/agext/levenshtein v1.2.3 // indirect
github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/bytedance/sonic v1.10.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
github.com/chenzhuoyu/iasm v0.9.0 // 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.2 // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-openapi/inflect v0.19.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/go-cmp v0.5.7 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/hashicorp/hcl/v2 v2.11.1 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.15.3 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/hashicorp/hcl/v2 v2.18.0 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgconn v1.10.1 // indirect
github.com/jackc/pgconn v1.14.1 // indirect
github.com/jackc/pgio v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgproto3/v2 v2.2.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
github.com/jackc/pgtype v1.9.1 // indirect
github.com/klauspost/compress v1.14.2 // indirect
github.com/kr/pretty v0.2.0 // indirect
github.com/markus-wa/go-unassert v0.1.2 // indirect
github.com/jackc/pgproto3/v2 v2.3.2 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/pgtype v1.14.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.16.7 // indirect
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/markus-wa/go-unassert v0.1.3 // indirect
github.com/markus-wa/gobitread v0.2.3 // indirect
github.com/markus-wa/godispatch v1.4.1 // indirect
github.com/markus-wa/ice-cipher-go v0.0.0-20220126215401-a6adadccc817 // indirect
github.com/markus-wa/quickhull-go/v2 v2.1.0 // indirect
github.com/markus-wa/ice-cipher-go v0.0.0-20230901094113-348096939ba7 // indirect
github.com/markus-wa/quickhull-go/v2 v2.2.0 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/oklog/ulid/v2 v2.1.0 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
github.com/vmihailenco/go-tinylfu v0.2.2 // indirect
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/zclconf/go-cty v1.10.0 // indirect
golang.org/x/crypto v0.0.0-20220128200615-198e4374d7ed // indirect
golang.org/x/exp v0.0.0-20220128181451-c853b6ddb95e // indirect
golang.org/x/mod v0.6.0-dev.0.20211013180041-c96bc1413d57 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 // indirect
golang.org/x/text v0.3.7 // indirect
github.com/zclconf/go-cty v1.14.0 // indirect
golang.org/x/arch v0.4.0 // indirect
golang.org/x/crypto v0.12.0 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.11.0 // indirect
)

600
go.sum
View File

@@ -1,141 +1,93 @@
ariga.io/atlas v0.3.2 h1:rE0OMGK08+5fg2Q8ukFkKSjygJx7pyH7UsJveCQ62Rw=
ariga.io/atlas v0.3.2/go.mod h1:XcLUpQX7Cq4qtagEHIleq3MJaBeeJ76BS8doc4gkOJk=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20201218220906-28db891af037/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
entgo.io/ent v0.10.0 h1:9cBomE1fh+WX34DPYQL7tDNAIvhKa3tXvwxuLyhYCMo=
entgo.io/ent v0.10.0/go.mod h1:5bjIYdTizykmdtPY3knXrrGpxAh0cMjFfxdNnlNiUGU=
ariga.io/atlas v0.13.3 h1:L6Zz/0/yo86flQclZwIqJEKrHoJxQOkj3Z2JPvzZEHE=
ariga.io/atlas v0.13.3/go.mod h1:+TR129FJZ5Lvzms6dvCeGWh1yR6hMvmXBhug4hrNIGk=
entgo.io/ent v0.12.3 h1:N5lO2EOrHpCH5HYfiMOCHYbo+oh5M8GjT0/cx5x6xkk=
entgo.io/ent v0.12.3/go.mod h1:AigGGx+tbrBBYHAzGOg8ND661E5cxx1Uiu5o/otJ6Yg=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc=
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=
github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/aclements/go-moremath v0.0.0-20210112150236-f10218a38794 h1:xlwdaKcTNVW4PtpQb8aKA4Pjy0CdJHEqvFbAnvR5m2g=
github.com/aclements/go-moremath v0.0.0-20210112150236-f10218a38794/go.mod h1:7e+I0LQFUI9AXWxOfsQROs9xPhoJtbsyWcjJqDd4KPY=
github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo=
github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/an0nfunc/go-steam/v3 v3.0.6 h1:HKkbSokGzoM5W+CsRlzOkmPayLgksW4UekmEaq98lRU=
github.com/an0nfunc/go-steam/v3 v3.0.6/go.mod h1:HnlYcTVnAJbSlyzC5lxft9jQOu2mjTw8LHfN/bYuDEs=
github.com/an0nfunc/go-steamapi v1.1.0 h1:sBOSAKO0zEmzKrkMX2bVhoFiErA+Gyx9hRl+7Bb9dCk=
github.com/an0nfunc/go-steamapi v1.1.0/go.mod h1:tInHdrGkh0gaXuPnvhMG4BoW9S5gVcWOY9gJ9gCBKOI=
github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129 h1:MzBOUgng9orim59UnfUTLRjMpd09C5uEVQ6RPGeCaVI=
github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129/go.mod h1:rFgpPQZYZ8vdbc+48xibu8ALc3yeyd64IhHS+PU6Yyg=
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM=
github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk=
github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw=
github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo=
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A=
github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU=
github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/an0nfunc/go-steamapi v1.1.3 h1:xJSeaIcZoEmpRi24DZJ7zVxhiqBAoqzvYqF7FQUVlOQ=
github.com/an0nfunc/go-steamapi v1.1.3/go.mod h1:76PULrtacpYOZF6WbddaU7aopPwwpBJDrMFPFNKokmI=
github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY=
github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4=
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM=
github.com/bytedance/sonic v1.10.0 h1:qtNZduETEIWJVIyDl01BeNxur2rW9OwTQ/yBqFRkKEk=
github.com/bytedance/sonic v1.10.0/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d h1:77cEq6EriyTZ0g/qfRdp61a3Uu/AWrgIq2s0ClJV1g0=
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d/go.mod h1:8EPpVsBuRksnlj1mLy4AWzRNQYxauNi62uWcE3to6eA=
github.com/chenzhuoyu/iasm v0.9.0 h1:9fhXjVzq5hUy2gkhhgHl95zG2cEAhw9OSGs8toWWAwo=
github.com/chenzhuoyu/iasm v0.9.0/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog=
github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I=
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
github.com/coreos/go-semver v0.2.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/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/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/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/dustin/go-heatmap v0.0.0-20180603032536-b89dbd73785a/go.mod h1:VBmwC4U3p2SMEKr+/m5j0eby7rmUtSoA5TGLwe6P+3A=
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
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/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=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI=
github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-gl/gl v0.0.0-20180407155706-68e253793080/go.mod h1:482civXOzJJCPzJ4ZOX/pwvXBWSnzD4OKMdH4ClKGbk=
github.com/go-gl/glfw v0.0.0-20180426074136-46a8d530c326/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o=
github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU=
github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA=
github.com/gin-contrib/cors v1.4.0 h1:oJ6gwtUl3lqV0WEIwM/LxPF1QZ5qe2lGWdY2+bz7y0g=
github.com/gin-contrib/cors v1.4.0/go.mod h1:bs9pNM0x/UsmHPBWT2xZz9ROh8xYjYkiURUfmBoMlcs=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk=
github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg=
github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU=
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
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=
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos=
github.com/go-playground/validator/v10 v10.15.3 h1:S+sSpunYjNPDuXkWbK+x+bA7iXiW296KG4dL3X7xUZo=
github.com/go-playground/validator/v10 v10.15.3/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
github.com/go-redis/cache/v8 v8.4.4 h1:Rm0wZ55X22BA2JMqVtRQNHYyzDd0I5f+Ec/C9Xx3mXY=
github.com/go-redis/cache/v8 v8.4.4/go.mod h1:JM6CkupsPvAu/LYEVGQy6UB4WDAzQSXkR0lUCbeIcKc=
github.com/go-redis/redis/v8 v8.11.3/go.mod h1:xNJ9xDG09FsIPwh3bWdk+0oDWHbtF9rPN0F/oD9XeKc=
github.com/go-redis/redis/v8 v8.11.4 h1:kHoYkfZP6+pe04aFTnhDH6GDROa5yJdHJVNxV3F46Tg=
github.com/go-redis/redis/v8 v8.11.4/go.mod h1:2Z2wHZXdQpCDXEGzqMockDpNyYvi2l4Pxt6RJr792+w=
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw=
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
github.com/golang/geo v0.0.0-20180826223333-635502111454/go.mod h1:vgWZ7cu0fq0KY3PpEHsocXOWJpRtkcbKemU4IUw0M60=
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 h1:gtexQ/VGyN+VVFRXSFiguSNcXmS6rkKT+X7FdIrTtfo=
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/geo v0.0.0-20230421003525-6adc56603217 h1:HKlyj6in2JV6wVkmQ4XmG/EIm+SCYlPZ+V4GWit7Z+I=
github.com/golang/geo v0.0.0-20230421003525-6adc56603217/go.mod h1:8wI0hitZ3a1IxZfeH3/5I97CI8i5cLGsYe7xNhQGs9U=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
@@ -144,60 +96,20 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o=
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4=
github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q=
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE=
github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU=
github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/hcl/v2 v2.11.1 h1:yTyWcXcm9XB0TEkyU/JCRU6rYy4K+mgLtzn2wlrJbcc=
github.com/hashicorp/hcl/v2 v2.11.1/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg=
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hashicorp/hcl/v2 v2.18.0 h1:wYnG7Lt31t2zYkcquwgKo6MWXzRUDIeIVU5naZwHLl8=
github.com/hashicorp/hcl/v2 v2.18.0/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo=
github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8=
@@ -208,8 +120,9 @@ github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsU
github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o=
github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY=
github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI=
github.com/jackc/pgconn v1.10.1 h1:DzdIHIjG1AxGwoEEqS+mGsURyjt4enSmqzACXvVzOT8=
github.com/jackc/pgconn v1.10.1/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI=
github.com/jackc/pgconn v1.14.0/go.mod h1:9mBNlny0UvkgJdCDvdVHYSjI+8tD2rnKK69Wz8ti++E=
github.com/jackc/pgconn v1.14.1 h1:smbxIaZA08n6YuxEX1sDyjV/qkbtUtkH20qLkR9MUR4=
github.com/jackc/pgconn v1.14.1/go.mod h1:9mBNlny0UvkgJdCDvdVHYSjI+8tD2rnKK69Wz8ti++E=
github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE=
github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8=
github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE=
@@ -225,427 +138,279 @@ github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvW
github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM=
github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
github.com/jackc/pgproto3/v2 v2.2.0 h1:r7JypeP2D3onoQTCxWdTpCtJ4D+qpKr0TxvoyMhZ5ns=
github.com/jackc/pgproto3/v2 v2.2.0/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b h1:C8S2+VttkHFdOOCXJe+YGfa4vHYwlt4Zx+IVXQ97jYg=
github.com/jackc/pgproto3/v2 v2.3.2 h1:7eY55bdBeCz1F2fTzSz69QC+pG46jYq9/jtSPiJ5nn0=
github.com/jackc/pgproto3/v2 v2.3.2/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E=
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk=
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg=
github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc=
github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw=
github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM=
github.com/jackc/pgtype v1.9.1 h1:MJc2s0MFS8C3ok1wQTdQxWuXQcB6+HwAm5x1CzW7mf0=
github.com/jackc/pgtype v1.9.1/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4=
github.com/jackc/pgtype v1.14.0 h1:y+xUdabmyMkJLyApYuPj38mW+aAIqCe5uuBB51rH3Vw=
github.com/jackc/pgtype v1.14.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4=
github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y=
github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM=
github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc=
github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs=
github.com/jackc/pgx/v4 v4.14.1 h1:71oo1KAGI6mXhLiTMn6iDFcp3e7+zon/capWjl2OEFU=
github.com/jackc/pgx/v4 v4.14.1/go.mod h1:RgDuE4Z34o7XE92RpLsvFiOEfrAUT0Xt2KxvX73W06M=
github.com/jackc/pgx/v4 v4.18.1 h1:YP7G1KABtKpB5IHrO9vYwSrCOhs7p3uqhvhhQBptya0=
github.com/jackc/pgx/v4 v4.18.1/go.mod h1:FydWkUyadDmdNH/mHnGob881GawxeEm7TcMCzkb+qQE=
github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jackc/puddle v1.2.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/jung-kurt/gofpdf v1.0.0/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes=
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/jackc/puddle v1.3.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/klauspost/compress v1.14.2 h1:S0OHlFk/Gbon/yauFJ4FfJJF5V0fc5HbBTJazi28pRw=
github.com/klauspost/compress v1.14.2/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I=
github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg=
github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs=
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
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/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4=
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.10.2 h1:AqzbZs4ZoCBp+GtejcpCpcxM3zlSMx29dXbUSeVtJb8=
github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lib/pq v1.10.4 h1:SO9z7FRPzA03QhHKJrH5BXA6HU1rS4V2nIVrrNC1iYk=
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=
github.com/llgcode/draw2d v0.0.0-20200930101115-bfaf5d914d1e/go.mod h1:mVa0dA29Db2S4LVqDYLlsePDzRJLDfdhVZiI15uY0FA=
github.com/llgcode/ps v0.0.0-20150911083025-f1443b32eedb/go.mod h1:1l8ky+Ew27CMX29uG+a2hNOKpeNYEQjjtiALiBlFQbY=
github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ=
github.com/markus-wa/demoinfocs-golang/v2 v2.13.0 h1:WwmNt9BfYYlJb6xG3DFULAfj86/bHPn95MkAFsbfTgI=
github.com/markus-wa/demoinfocs-golang/v2 v2.13.0/go.mod h1:2mL3quPmFnXa8WkrsQTEFUm/iDBuzq5I3AeJ6SsMIn4=
github.com/markus-wa/go-unassert v0.1.2 h1:uXWlMDa8JVtc4RgNq4XJIjyRejv9MOVuy/E0VECPxxo=
github.com/markus-wa/go-unassert v0.1.2/go.mod h1:XEvrxR+trvZeMDfXcZPvzqGo6eumEtdk5VjNRuvvzxQ=
github.com/markus-wa/demoinfocs-golang/v3 v3.3.0 h1:cXAI081cH5tDmmyPuyUzuIGeP8strtVzdtRB5VlIvL8=
github.com/markus-wa/demoinfocs-golang/v3 v3.3.0/go.mod h1:NzAkCtDshPkoSMg3hAyojkmHE4ZgnNWCM1Vv4yCPLsI=
github.com/markus-wa/go-unassert v0.1.3 h1:4N2fPLUS3929Rmkv94jbWskjsLiyNT2yQpCulTFFWfM=
github.com/markus-wa/go-unassert v0.1.3/go.mod h1:/pqt7a0LRmdsRNYQ2nU3SGrXfw3bLXrvIkakY/6jpPY=
github.com/markus-wa/gobitread v0.2.3 h1:COx7dtYQ7Q+77hgUmD+O4MvOcqG7y17RP3Z7BbjRvPs=
github.com/markus-wa/gobitread v0.2.3/go.mod h1:PcWXMH4gx7o2CKslbkFkLyJB/aHW7JVRG3MRZe3PINg=
github.com/markus-wa/godispatch v1.4.1 h1:Cdff5x33ShuX3sDmUbYWejk7tOuoHErFYMhUc2h7sLc=
github.com/markus-wa/godispatch v1.4.1/go.mod h1:tk8L0yzLO4oAcFwM2sABMge0HRDJMdE8E7xm4gK/+xM=
github.com/markus-wa/ice-cipher-go v0.0.0-20220126215401-a6adadccc817 h1:VB4ANo078mbGQNBgauLOzJkoHpIqrMygbPHVW0jjql0=
github.com/markus-wa/ice-cipher-go v0.0.0-20220126215401-a6adadccc817/go.mod h1:JIsht5Oa9P50VnGJTvH2a6nkOqDFJbUeU1YRZYvdplw=
github.com/markus-wa/quickhull-go/v2 v2.1.0 h1:DA2pzEzH0k5CEnlUsouRqNdD+jzNFb4DBhrX4Hpa5So=
github.com/markus-wa/quickhull-go/v2 v2.1.0/go.mod h1:bOlBUpIzGSMMhHX0f9N8CQs0VZD4nnPeta0OocH7m4o=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/markus-wa/ice-cipher-go v0.0.0-20230901094113-348096939ba7 h1:aR9pvnlnBxifXBmzidpAiq2prLSGlkhE904qnk2sCz4=
github.com/markus-wa/ice-cipher-go v0.0.0-20230901094113-348096939ba7/go.mod h1:JIsht5Oa9P50VnGJTvH2a6nkOqDFJbUeU1YRZYvdplw=
github.com/markus-wa/quickhull-go/v2 v2.2.0 h1:rB99NLYeUHoZQ/aNRcGOGqjNBGmrOaRxdtqTnsTUPTA=
github.com/markus-wa/quickhull-go/v2 v2.2.0/go.mod h1:EuLMucfr4B+62eipXm335hOs23LTnO62W7Psn3qvU2k=
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
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-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0=
github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0=
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg=
github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU=
github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k=
github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w=
github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs=
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
github.com/oklog/ulid/v2 v2.1.0 h1:+9lhoxAP56we25tyYETBBY1YLA2SaoLvUFgrP2miPJU=
github.com/oklog/ulid/v2 v2.1.0/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNsTT1QQ=
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=
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc=
github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/onsi/gomega v1.15.0/go.mod h1:cIuvLEne0aoVhAgh/O6ac0Op8WWw9H6eYCriF+tEHG0=
github.com/onsi/gomega v1.16.0 h1:6gjqkI8iiRHMvdccRJM8rVKjCWk6ZIm6FTm3ddIe4/c=
github.com/onsi/gomega v1.16.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis=
github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74=
github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxSfWAKL3wpBW7V8scJMt8N8gnaMCS9E/cA=
github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw=
github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4=
github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4=
github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM=
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac=
github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc=
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o=
github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo=
github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4=
github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA=
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU=
github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc=
github.com/rs/zerolog v1.21.0/go.mod h1:ZPhntP/xmq1nnND05hhpAh2QMhSsA4UN3MGZ6O2J3hM=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/sethvargo/go-retry v0.2.4 h1:T+jHEQy/zKJf5s95UkguisicE0zuF9y7+/vgz08Ocec=
github.com/sethvargo/go-retry v0.2.4/go.mod h1:1afjQuvh7s4gflMObvjLPaWgluLLyhA1wmVZ6KLpICw=
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY=
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1-0.20210427113832-6241f9ab9942 h1:t0lM6y/M5IiUZyvbBTcngso8SZEZICH7is9B6g/obVU=
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M=
github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY=
github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU=
github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
github.com/vmihailenco/go-tinylfu v0.2.2 h1:H1eiG6HM36iniK6+21n9LLpzx1G9R3DJa2UjUjbynsI=
github.com/vmihailenco/go-tinylfu v0.2.2/go.mod h1:CutYi2Q9puTxfcolkliPq4npPuofg9N9t8JVrjzwa3Q=
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4=
github.com/vmihailenco/msgpack/v5 v5.3.4/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc=
github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU=
github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc=
github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
github.com/wercker/journalhook v0.0.0-20180428041537-5d0a5ae867b3 h1:shC1HB1UogxN5Ech3Yqaaxj1X/P656PPCB4RbojIJqc=
github.com/wercker/journalhook v0.0.0-20180428041537-5d0a5ae867b3/go.mod h1:XCsSkdKK4gwBMNrOCZWww0pX6AOt+2gYc5Z6jBRrNVg=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8=
github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk=
github.com/zclconf/go-cty v1.10.0 h1:mp9ZXQeIcN8kAwuqorjH+Q+njbJKjLrvB2yIh4q7U+0=
github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk=
github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/zclconf/go-cty v1.14.0 h1:/Xrd39K7DXbHzlisFP9c4pHao4yyf+/Ug9LEz+Y/yhc=
github.com/zclconf/go-cty v1.14.0/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE=
github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg=
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opentelemetry.io/otel v0.20.0/go.mod h1:Y3ugLH2oa81t5QO+Lty+zXf8zC9L26ax4Nzoxm/dooo=
go.opentelemetry.io/otel/metric v0.20.0/go.mod h1:598I5tYlH1vzBjn+BTuhzTCSb/9debfNp6R3s7Pr1eU=
go.opentelemetry.io/otel/oteltest v0.20.0/go.mod h1:L7bgKf9ZB7qCwT9Up7i9/pn0PWIa9FqQ2IQ8LoxiGnw=
go.opentelemetry.io/otel/sdk v0.20.0/go.mod h1:g/IcepuwNsoiX5Byy2nNV0ySUF1em498m7hBWC279Yc=
go.opentelemetry.io/otel/trace v0.20.0/go.mod h1:6GjCW8zgDjwGHGa6GkyeB8+/5vjT16gUEi0Nf1iBdgw=
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
go.uber.org/ratelimit v0.2.0 h1:UQE2Bgi7p2B85uP5dC2bbRtig0C+OeNRnNEafLjsLPA=
go.uber.org/ratelimit v0.2.0/go.mod h1:YYBV4e4naJvhpitQrWJu1vCpgB7CboMe0qhltKt6mUg=
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/arch v0.4.0 h1:A8WCeEWhLwPBKNbFi5Wv5UTCBx5zzubnXDlMOFAzFMc=
golang.org/x/arch v0.4.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220128200615-198e4374d7ed h1:YoWVYYAfvQ4ddHv3OKmIvX7NCAhFGTj62VP2l2kfBbA=
golang.org/x/crypto v0.0.0-20220128200615-198e4374d7ed/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56/go.mod h1:JhuoJpWY28nO4Vef9tZUw9qufEGTyX1+7lmHxV5q5G4=
golang.org/x/exp v0.0.0-20210916165020-5cb4fee858ee/go.mod h1:a3o/VtDNHN+dCVLEpzjjUHOzR+Ln3DHX056ZPzoZGGA=
golang.org/x/exp v0.0.0-20220128181451-c853b6ddb95e h1:FmsvSkPHPBTboKvYBUtHbHvkQGxq+XSrqPXKDQf2W3s=
golang.org/x/exp v0.0.0-20220128181451-c853b6ddb95e/go.mod h1:M50CtfS+xv2iy/epuEazynj250ScQ0/DOjcsin9UE8k=
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=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk=
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
golang.org/x/mobile v0.0.0-20201217150744-e6ae53a27f4f/go.mod h1:skQtrUTUwhdJvXM/2KKJzY8pDgNr9I/FOMqDVRPBUS4=
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.1.1-0.20191209134235-331c550502dd/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
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.5.1-0.20210830214625-1b1db11ec8f4/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
golang.org/x/mod v0.6.0-dev.0.20211013180041-c96bc1413d57 h1:LQmS1nU0twXLA96Kt7U9qtHJEbBk3z6Q0V4UXjZkpr4=
golang.org/x/mod v0.6.0-dev.0.20211013180041-c96bc1413d57/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 h1:CIJ76btIcR3eFI5EgSo6k1qKw9KJexJuRLI9G7Hp5wE=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190502175342-a43fa875dd82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 h1:XDXtA5hveEEV8JB2l7nhMTp3t3cHp9ZpwcdjqyEWLlo=
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190823170909-c4a336ef6a2f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200117012304-6edc0a871e69/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
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.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
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=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/genproto v0.0.0-20190530194941-fb225487d101/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
@@ -654,36 +419,31 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o=
gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s=
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
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/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-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las=
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
somegit.dev/anonfunc/gositemap v0.1.3 h1:3rsj+cejR6qdihXq6ZlFqwTDNefOXoSOYmvHrXkw+DE=
somegit.dev/anonfunc/gositemap v0.1.3/go.mod h1:2v84uOYv0OQyfvQu9Fq1WI4zr/EjDOoxry5JrMZVEqo=

895
main.go

File diff suppressed because it is too large Load Diff

View File

@@ -2,25 +2,25 @@ package utils
import (
"context"
"csgowtfd/ent"
"csgowtfd/ent/match"
"csgowtfd/ent/matchplayer"
"csgowtfd/ent/player"
"csgowtfd/ent/roundstats"
"csgowtfd/ent/spray"
"csgowtfd/ent/weapon"
"encoding/json"
"entgo.io/ent/dialect/sql"
"errors"
"fmt"
"github.com/an0nfunc/go-steamapi"
log "github.com/sirupsen/logrus"
"go.uber.org/ratelimit"
"golang.org/x/time/rate"
"io"
"io/ioutil"
"net/http"
"net/url"
"path"
"regexp"
"somegit.dev/csgowtf/csgowtfd/ent"
"somegit.dev/csgowtf/csgowtfd/ent/match"
"somegit.dev/csgowtf/csgowtfd/ent/matchplayer"
"somegit.dev/csgowtf/csgowtfd/ent/player"
"somegit.dev/csgowtf/csgowtfd/ent/roundstats"
"somegit.dev/csgowtf/csgowtfd/ent/spray"
"somegit.dev/csgowtf/csgowtfd/ent/weapon"
"sort"
"strconv"
"strings"
@@ -31,10 +31,10 @@ type Conf struct {
Logging struct {
Level string
}
Db struct {
DB struct {
Driver string
ConnectTo string `yaml:"connect_to"`
}
} `yaml:"db"`
Parser struct {
Worker int
}
@@ -43,9 +43,10 @@ type Conf struct {
Password string
AuthCode string `yaml:"auth_code"`
APIKey string `yaml:"api_key"`
RatePerSecond int `yaml:"rate_per_sec"`
RatePerSecond float64 `yaml:"rate_per_sec"`
Sentry string
LoginKey string `yaml:"login_key"`
MaxRetryWait int `yaml:"max_retry_wait"`
}
Redis struct {
Address string
@@ -64,8 +65,18 @@ type Conf struct {
SharecodeUpdate string `yaml:"sharecode_update"`
DemosExpire int `yaml:"demos_expire"`
SprayTimeout int `yaml:"spray_timeout"`
Timeout struct {
Read int
Write int
Idle int
}
}
DeepL struct {
BaseURL string `yaml:"base_url"`
APIKey string `yaml:"api_key"`
Timeout int `yaml:"timeout"`
} `yaml:"deepl"`
}
type CommunityXML struct {
SteamID64 uint64 `xml:"steamID64"`
@@ -82,6 +93,13 @@ type ShareCodeResponse struct {
} `json:"result"`
}
type DeepLResponse struct {
Translations []struct {
DetectedSourceLanguage string `json:"detected_source_language"`
Text string `json:"text"`
} `json:"translations"`
}
type MatchStats struct {
Win int `json:"win,omitempty"`
Tie int `json:"tie,omitempty"`
@@ -160,6 +178,8 @@ type ChatResponse struct {
Message string `json:"message"`
AllChat bool `json:"all_chat"`
Tick int `json:"tick"`
TranslatedFrom string `json:"translated_from,omitempty"`
TranslatedTo string `json:"translated_to,omitempty"`
}
type WeaponDmg struct {
@@ -179,7 +199,7 @@ type MetaStatsResponse struct {
}
type MatchResponse struct {
MatchId uint64 `json:"match_id,string"`
MatchID uint64 `json:"match_id,string"`
ShareCode string `json:"share_code,omitempty"`
Map string `json:"map"`
Date int64 `json:"date"`
@@ -193,47 +213,32 @@ type MatchResponse struct {
GameBan bool `json:"game_ban"`
Stats interface{} `json:"stats,omitempty"`
AvgRank float64 `json:"avg_rank,omitempty"`
TickRate float64 `json:"tick_rate,omitempty"`
}
type (
AuthcodeUnauthorizedError struct {
error
}
AuthcodeRateLimitError struct {
error
}
SharecodeNoMatchError struct {
error
}
var (
ErrorSharecodeNoMatch = errors.New("sharecode not provided")
ErrorAuthcodeRateLimit = errors.New("temporary rate-limited")
ErrorAuthcodeUnavailable = errors.New("temporary unavailable")
ErrorAuthcodeUnauthorized = errors.New("authcode unauthorized")
ErrorNoMatch = errors.New("no match found")
)
const (
shareCodeURLEntry = "https://api.steampowered.com/ICSGOPlayers_730/GetNextMatchSharingCode/v1?key=%s&steamid=%d&steamidkey=%s&knowncode=%s"
SideMetaCacheKey = "csgowtfd_side_meta_%d"
CachePrefix = "csgowtfd_"
SideMetaCacheKey = CachePrefix + "side_meta_%d"
MatchChatCacheKey = CachePrefix + "chat_%d_%s"
)
//goland:noinspection SpellCheckingInspection
var (
SteamId64RegEx = regexp.MustCompile(`^\d{17}$`)
SteamID64RegEx = regexp.MustCompile(`^\d{17}$`)
ShareCodeRegEx = regexp.MustCompile(`^CSGO(?:-?[ABCDEFGHJKLMNOPQRSTUVWXYZabcdefhijkmnopqrstuvwxyz23456789]{5}){5}$`)
AuthCodeRegEx = regexp.MustCompile(`^[ABCDEFGHJKLMNOPQRSTUVWXYZ23456789]{4}-[ABCDEFGHJKLMNOPQRSTUVWXYZ23456789]{5}-[ABCDEFGHJKLMNOPQRSTUVWXYZ23456789]{4}$`)
AuthCodeRegEx = regexp.MustCompile(
`^[ABCDEFGHJKLMNOPQRSTUVWXYZ23456789]{4}-[ABCDEFGHJKLMNOPQRSTUVWXYZ23456789]{5}-[ABCDEFGHJKLMNOPQRSTUVWXYZ23456789]{4}$`)
)
func SendJSON(data interface{}, w http.ResponseWriter) error {
w.Header().Set("content-type", "application/json")
playerJson, err := json.Marshal(data)
if err != nil {
return err
}
w.WriteHeader(http.StatusOK)
_, err = w.Write(playerJson)
if err != nil {
return err
}
return nil
}
func GetMetaStats(dbPlayer *ent.Player) (*MetaStatsResponse, error) {
mResponse := new(MetaStatsResponse)
mResponse.Player = &PlayerResponse{SteamID64: dbPlayer.ID}
@@ -269,7 +274,7 @@ func GetMetaStats(dbPlayer *ent.Player) (*MetaStatsResponse, error) {
pMatches, err := s.QueryMatches().
Select(match.FieldID, match.FieldMatchResult, match.FieldMap).
Where(match.IDIn(matchIDs...)).
WithStats().
WithStats(). // TODO: limit fields returned
Where(match.HasStatsWith(matchplayer.Or(matchplayer.PlayerStats(dbPlayer.ID), matchplayer.PlayerStats(s.ID)))).
All(context.Background())
if err != nil {
@@ -427,7 +432,7 @@ func DeleteMatch(matchDel *ent.Match, db *ent.Client) error {
return nil
}
func GetWinLossTieForPlayer(dbPlayer *ent.Player) (wins int, looses int, ties int, err error) {
func GetWinLossTieForPlayer(dbPlayer *ent.Player) (wins, looses, ties int, err error) {
var res []struct {
MatchResult int `json:"match_result"`
Count int `json:"count"`
@@ -470,60 +475,66 @@ func GetWinLossTieForPlayer(dbPlayer *ent.Player) (wins int, looses int, ties in
return
}
func IsAuthCodeValid(player *ent.Player, apiKey string, shareCode string, authCode string, rl ratelimit.Limiter) (bool, error) {
func IsAuthCodeValid(tPlayer *ent.Player, apiKey, shareCode, authCode string, rl *rate.Limiter) (bool, error) {
var tMatch *ent.Match
var err error
if shareCode == "" {
tMatch, err = player.QueryMatches().Order(ent.Asc(match.FieldDate)).First(context.Background())
tMatch, err = tPlayer.QueryMatches().Order(ent.Asc(match.FieldDate)).First(context.Background())
if err != nil {
return false, err
return false, ErrorSharecodeNoMatch
}
_, err := getNextShareCode(tMatch.ShareCode, apiKey, authCode, player.ID, rl)
if err != nil {
return false, err
}
return true, nil
} else {
_, err := getNextShareCode(shareCode, apiKey, authCode, player.ID, rl)
_, err := getNextShareCode(tMatch.ShareCode, apiKey, authCode, tPlayer.ID, rl)
if err != nil {
return false, err
}
return true, nil
}
_, err = getNextShareCode(shareCode, apiKey, authCode, tPlayer.ID, rl)
if err != nil {
return false, err
}
return true, nil
}
func GetNewShareCodesForPlayer(player *ent.Player, apiKey string, rl ratelimit.Limiter) ([]string, error) {
latestMatch, err := player.QueryMatches().Order(ent.Desc(match.FieldDate)).First(context.Background())
func GetNewShareCodesForPlayer(tPlayer *ent.Player, apiKey string, rl *rate.Limiter) ([]string, error) {
latestMatch, err := tPlayer.QueryMatches().Order(ent.Desc(match.FieldDate)).First(context.Background())
if err != nil {
if ent.IsNotFound(err) {
return nil, ErrorNoMatch
}
return nil, err
}
oldestMatch, err := player.QueryMatches().Order(ent.Asc(match.FieldDate)).First(context.Background())
oldestMatch, err := tPlayer.QueryMatches().Order(ent.Asc(match.FieldDate)).First(context.Background())
if err != nil {
if ent.IsNotFound(err) {
return nil, ErrorNoMatch
}
return nil, err
}
var newShareCode string
if oldestMatch.ShareCode == player.OldestSharecodeSeen {
newShareCode, err = getNextShareCode(latestMatch.ShareCode, apiKey, player.AuthCode, player.ID, rl)
var newShareCode *string
if oldestMatch.ShareCode == tPlayer.OldestSharecodeSeen {
newShareCode, err = getNextShareCode(latestMatch.ShareCode, apiKey, tPlayer.AuthCode, tPlayer.ID, rl)
} else {
newShareCode, err = getNextShareCode(oldestMatch.ShareCode, apiKey, player.AuthCode, player.ID, rl)
newShareCode, err = getNextShareCode(oldestMatch.ShareCode, apiKey, tPlayer.AuthCode, tPlayer.ID, rl)
}
if err != nil {
return nil, err
}
var rCodes []string
for newShareCode != "n/a" {
rCodes = append(rCodes, newShareCode)
newShareCode, err = getNextShareCode(rCodes[len(rCodes)-1], apiKey, player.AuthCode, player.ID, rl)
for newShareCode != nil {
rCodes = append(rCodes, *newShareCode)
newShareCode, err = getNextShareCode(rCodes[len(rCodes)-1], apiKey, tPlayer.AuthCode, tPlayer.ID, rl)
if err != nil {
return nil, err
}
}
err = player.Update().SetSharecodeUpdated(time.Now().UTC()).SetOldestSharecodeSeen(oldestMatch.ShareCode).Exec(context.Background())
err = tPlayer.Update().SetSharecodeUpdated(time.Now().UTC()).SetOldestSharecodeSeen(oldestMatch.ShareCode).Exec(context.Background())
if err != nil {
return nil, err
}
@@ -531,60 +542,61 @@ func GetNewShareCodesForPlayer(player *ent.Player, apiKey string, rl ratelimit.L
return rCodes, nil
}
func getNextShareCode(lastCode string, apiKey string, authCode string, steamId uint64, rl ratelimit.Limiter) (string, error) {
if lastCode == "" || apiKey == "" || authCode == "" || steamId == 0 {
return "", fmt.Errorf("invalid arguments")
func getNextShareCode(lastCode, apiKey, authCode string, steamID uint64, rl *rate.Limiter) (*string, error) {
if lastCode == "" || apiKey == "" || authCode == "" || steamID == 0 {
return nil, fmt.Errorf("invalid arguments")
}
if rl != nil {
rl.Take()
}
log.Debugf("[SC] STEAMPI with %s", fmt.Sprintf(shareCodeURLEntry, "REDACTED", steamId, "REDACTED", lastCode))
r, err := http.Get(fmt.Sprintf(shareCodeURLEntry, apiKey, steamId, authCode, lastCode))
err := rl.Wait(context.Background())
if err != nil {
return "", err
return nil, err
}
}
log.Debugf("[SC] STEAMPI with %s", fmt.Sprintf(shareCodeURLEntry, "REDACTED", steamID, "REDACTED", lastCode))
r, err := http.Get(fmt.Sprintf(shareCodeURLEntry, apiKey, steamID, authCode, lastCode)) //nolint:noctx
if err != nil {
return nil, err
}
switch r.StatusCode {
case http.StatusAccepted:
return "n/a", nil
return nil, nil //nolint:nilnil
case http.StatusTooManyRequests:
return "", AuthcodeRateLimitError{errors.New("temporary ratelimited")}
return nil, ErrorAuthcodeRateLimit
case http.StatusServiceUnavailable:
return "", AuthcodeRateLimitError{errors.New("temporary unavailable")}
return nil, ErrorAuthcodeUnavailable
case http.StatusPreconditionFailed:
return "", SharecodeNoMatchError{errors.New("sharecode not from player history")}
return nil, ErrorSharecodeNoMatch
case http.StatusForbidden:
return "", AuthcodeUnauthorizedError{errors.New("authcode unauthorized")}
return nil, ErrorAuthcodeUnauthorized
case http.StatusOK:
break
default:
return "", errors.New("temporary steamapi error")
return nil, fmt.Errorf("temporary steamapi error (HTTP %d)", r.StatusCode)
}
defer func(Body io.ReadCloser) {
_ = Body.Close()
}(r.Body)
bJson, err := ioutil.ReadAll(r.Body)
bJSON, err := io.ReadAll(r.Body)
if err != nil {
return "", err
return nil, err
}
_ = r.Body.Close()
rJson := new(ShareCodeResponse)
err = json.Unmarshal(bJson, rJson)
rJSON := new(ShareCodeResponse)
err = json.Unmarshal(bJSON, rJSON)
if err != nil {
return "", err
return nil, err
}
return rJson.Result.Code, nil
return &rJSON.Result.Code, nil
}
func Player(db *ent.Client, id interface{}, apiKey string, rl ratelimit.Limiter) (*ent.Player, error) {
func Player(db *ent.Client, id interface{}, apiKey string, rl *rate.Limiter) (*ent.Player, error) {
switch e := id.(type) {
case uint64:
return PlayerFromSteamID64(db, e, apiKey, rl)
case string:
if SteamId64RegEx.MatchString(e) {
if SteamID64RegEx.MatchString(e) {
steamID64, err := strconv.ParseUint(e, 10, 64)
if err != nil {
return nil, err
@@ -599,7 +611,7 @@ func Player(db *ent.Client, id interface{}, apiKey string, rl ratelimit.Limiter)
}
}
func PlayerFromVanityURL(db *ent.Client, id string, apiKey string, rl ratelimit.Limiter) (*ent.Player, error) {
func PlayerFromVanityURL(db *ent.Client, id, apiKey string, rl *rate.Limiter) (*ent.Player, error) {
if id == "" {
return nil, fmt.Errorf("invalid arguments")
}
@@ -607,11 +619,9 @@ func PlayerFromVanityURL(db *ent.Client, id string, apiKey string, rl ratelimit.
tPlayer, err := db.Player.Query().Where(player.VanityURL(strings.ToLower(id))).Only(context.Background())
if err == nil {
return tPlayer, nil
} else {
if rl != nil {
rl.Take()
}
resp, err := steamapi.ResolveVanityURL(id, apiKey)
resp, err := steamapi.ResolveVanityURL(id, apiKey, rl)
if err != nil {
return nil, err
}
@@ -627,13 +637,13 @@ func PlayerFromVanityURL(db *ent.Client, id string, apiKey string, rl ratelimit.
return nPlayer, nil
}
}
func PlayerFromSteamID64(db *ent.Client, steamID uint64, apiKey string, rl ratelimit.Limiter) (*ent.Player, error) {
func PlayerFromSteamID64(db *ent.Client, steamID uint64, apiKey string, rl *rate.Limiter) (*ent.Player, error) {
tPlayer, err := db.Player.Get(context.Background(), steamID)
if err == nil {
return tPlayer, nil
} else {
}
nPlayer := &ent.Player{ID: steamID}
uPlayer, err := PlayerFromSteam([]*ent.Player{nPlayer}, nil, apiKey, rl)
if err != nil {
@@ -663,28 +673,53 @@ func PlayerFromSteamID64(db *ent.Client, steamID uint64, apiKey string, rl ratel
return nil, fmt.Errorf("player %d not found", steamID)
}
func TranslateWithDeepL(text, language, baseURL, apiKey string, timeout int) (translated, detectedLanguage string, err error) {
c := &http.Client{
Timeout: time.Duration(timeout) * time.Second,
}
v := url.Values{}
v.Set("auth_key", apiKey)
v.Set("text", text)
v.Set("target_lang", language)
dlResp, err := c.PostForm("https://"+baseURL+"/v2/translate", v) //nolint:noctx
switch {
case err != nil:
return "", "", fmt.Errorf("deepl response: %w", err)
case dlResp.StatusCode != http.StatusOK:
return "", "", fmt.Errorf("deepl response %d", dlResp.StatusCode)
default:
respBytes, err := io.ReadAll(dlResp.Body)
if err != nil {
return "", "", fmt.Errorf("error reading deepl response: %w", err)
}
_ = dlResp.Body.Close()
dlRespJSON := new(DeepLResponse)
err = json.Unmarshal(respBytes, &dlRespJSON)
if err != nil {
return "", "", fmt.Errorf("error decoding json from deepl: %w", err)
}
return dlRespJSON.Translations[0].Text, strings.ToLower(dlRespJSON.Translations[0].DetectedSourceLanguage), nil
}
}
func PlayerFromSteam(players []*ent.Player, db *ent.Client, apiKey string, rl ratelimit.Limiter) ([]*ent.Player, error) {
var idsToUpdate []uint64
func PlayerFromSteam(players []*ent.Player, db *ent.Client, apiKey string, rl *rate.Limiter) ([]*ent.Player, error) {
idsToUpdate := make([]uint64, 0, len(players))
for _, updatePlayer := range players {
idsToUpdate = append(idsToUpdate, updatePlayer.ID)
}
if rl != nil {
rl.Take()
}
playerSum, err := steamapi.GetPlayerSummaries(idsToUpdate, apiKey)
playerSum, err := steamapi.GetPlayerSummaries(idsToUpdate, apiKey, rl)
if err != nil {
return nil, err
}
// TODO: what happens if a player deleted their profile?
var nPlayers []*ent.Player
var nPlayers []*ent.Player //nolint:prealloc
for _, pS := range playerSum {
// check for vanityURL
if SteamId64RegEx.MatchString(path.Base(pS.ProfileURL)) {
if SteamID64RegEx.MatchString(path.Base(pS.ProfileURL)) {
pS.ProfileURL = ""
} else {
pS.ProfileURL = path.Base(pS.ProfileURL)
@@ -717,10 +752,7 @@ func PlayerFromSteam(players []*ent.Player, db *ent.Client, apiKey string, rl ra
nPlayers = append(nPlayers, tPlayer)
}
if rl != nil {
rl.Take()
}
bans, err := steamapi.GetPlayerBans(idsToUpdate, apiKey)
bans, err := steamapi.GetPlayerBans(idsToUpdate, apiKey, rl)
if err != nil {
return nil, err
}
@@ -760,3 +792,18 @@ func PlayerFromSteam(players []*ent.Player, db *ent.Client, apiKey string, rl ra
return nPlayers, nil
}
func RealIP(header *http.Header, fallback string) string {
if header.Get("X-Forwarded-For") != "" {
return header.Get("X-Forwarded-For")
}
return fallback
}
func Rollback(tx *ent.Tx, err error) error {
if rErr := tx.Rollback(); rErr != nil {
err = fmt.Errorf("%w: %w", err, rErr)
}
return err
}