updated deps; code cleanup; updated golangci linter conf
This commit is contained in:
@@ -161,9 +161,8 @@ func (dml *DemoMatchLoader) getMatchDetails(sharecode string) (*protobuf.CMsgGCC
|
||||
for matchDetails := range dml.matchRecv {
|
||||
if *matchDetails.Matches[0].Matchid == matchID {
|
||||
return matchDetails, nil
|
||||
} else {
|
||||
dml.matchRecv <- matchDetails
|
||||
}
|
||||
dml.matchRecv <- matchDetails
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
@@ -173,8 +172,7 @@ func (dml *DemoMatchLoader) connectToSteam() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
_, err := dml.client.Connect()
|
||||
if err != nil {
|
||||
if _, err := dml.client.Connect(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
@@ -188,7 +186,7 @@ func (dml *DemoMatchLoader) Setup(config *DemoMatchLoaderConfig) error {
|
||||
dml.parseMap = map[string]bool{}
|
||||
dml.parseMapL = new(sync.RWMutex)
|
||||
dml.cache = config.Cache
|
||||
dml.connectFeedback = make(chan int, 10) //nolint:gomnd
|
||||
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)
|
||||
@@ -223,8 +221,8 @@ func (dml *DemoMatchLoader) Setup(config *DemoMatchLoaderConfig) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dml.matchRecv = make(chan *protobuf.CMsgGCCStrike15V2_MatchList, 1000) //nolint:gomnd
|
||||
dml.parseDemo = make(chan *Demo, 1000) //nolint:gomnd
|
||||
dml.matchRecv = make(chan *protobuf.CMsgGCCStrike15V2_MatchList, 1000)
|
||||
dml.parseDemo = make(chan *Demo, 1000)
|
||||
|
||||
go dml.connectLoop()
|
||||
go dml.steamEventHandler()
|
||||
@@ -299,7 +297,7 @@ func (dml *DemoMatchLoader) steamEventHandler() {
|
||||
go dml.setPlaying()
|
||||
case *steam.LogOnFailedEvent:
|
||||
log.Debugf("[DL] Steam login denied: %+v", e)
|
||||
switch e.Result {
|
||||
switch e.Result { //nolint:exhaustive
|
||||
case steamlang.EResult_AccountLogonDenied:
|
||||
log.Fatalf("[DL] Please provide AuthCode in config")
|
||||
case steamlang.EResult_InvalidPassword:
|
||||
@@ -426,7 +424,7 @@ func (dml *DemoMatchLoader) handleDemo(demo *Demo, apiKey string, rl *rate.Limit
|
||||
|
||||
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(tx.Client(), AccountID2SteamID(accountID), apiKey, rl)
|
||||
|
@@ -57,7 +57,7 @@ type Spray struct {
|
||||
}
|
||||
|
||||
var (
|
||||
DemoNotFoundError = errors.New("demo not found")
|
||||
ErrorDemoNotFound = errors.New("demo not found")
|
||||
)
|
||||
|
||||
func (s *Sprays) Add(currentTime time.Duration, sprayPoint []float32, timeout int) {
|
||||
@@ -108,7 +108,7 @@ func (s *Sprays) Avg() (avg [][]float32) {
|
||||
}
|
||||
|
||||
func (dp *DemoParser) Setup(db *ent.Client, worker, sprayTimeout int) error {
|
||||
dp.demoQueue = make(chan *Demo, 1000) //nolint:gomnd
|
||||
dp.demoQueue = make(chan *Demo, 1000)
|
||||
dp.db = db
|
||||
dp.sprayTimeout = sprayTimeout
|
||||
dp.Done = make(chan *Demo, worker)
|
||||
@@ -136,13 +136,13 @@ func (d *Demo) download() (io.Reader, error) {
|
||||
}
|
||||
|
||||
if r.StatusCode != http.StatusOK {
|
||||
return nil, DemoNotFoundError
|
||||
return nil, ErrorDemoNotFound
|
||||
}
|
||||
return bzip2.NewReader(r.Body), nil
|
||||
}
|
||||
|
||||
func (dp *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("unable to get stats from statList: %w", err)
|
||||
@@ -213,7 +213,7 @@ workloop:
|
||||
startTime := time.Now()
|
||||
fDemo, err := demo.download()
|
||||
if err != nil {
|
||||
if errors.Is(err, DemoNotFoundError) {
|
||||
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)
|
||||
@@ -222,12 +222,11 @@ workloop:
|
||||
}
|
||||
dp.Done <- demo
|
||||
continue
|
||||
} else {
|
||||
err = utils.Rollback(tx, err)
|
||||
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)
|
||||
|
||||
|
Reference in New Issue
Block a user