diff --git a/csgo/demo_loader.go b/csgo/demo_loader.go index 909d262..ea7636b 100644 --- a/csgo/demo_loader.go +++ b/csgo/demo_loader.go @@ -512,19 +512,27 @@ func (dml *DemoMatchLoader) handleDemo(demo *Demo, apiKey string, rl *rate.Limit for _, p := range players { err = dml.cache.Delete(context.Background(), fmt.Sprintf(utils.SideMetaCacheKey, p.ID)) if err != nil { + 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 { + 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 { + err = utils.Rollback(tx, err) return fmt.Errorf("error saving WinLossTie for player %d: %w", p.ID, err) } } + err = tx.Commit() + if err != nil { + 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)