switched to transactional queries for demo loading & parsing

This commit is contained in:
2022-11-03 03:18:24 +01:00
parent ff3bbe0037
commit abd8b74c08
3 changed files with 109 additions and 51 deletions

View File

@@ -17,7 +17,6 @@ import (
log "github.com/sirupsen/logrus"
"golang.org/x/time/rate"
"io"
"io/ioutil"
"math"
"net/http"
"net/url"
@@ -578,7 +577,7 @@ func getNextShareCode(lastCode string, apiKey string, authCode string, steamId u
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
}
@@ -823,3 +822,10 @@ func RealIP(header *http.Header, fallback string) string {
return fallback
}
}
func Rollback(tx *ent.Tx, err error) error {
if rErr := tx.Rollback(); rErr != nil {
err = fmt.Errorf("%w: %v", err, rErr)
}
return err
}