first already limits to 1, no need for limit

This commit is contained in:
2021-10-20 00:23:58 +02:00
parent de738aa458
commit 6aaa0f2e48
2 changed files with 3 additions and 19 deletions

View File

@@ -96,18 +96,9 @@ type Rank struct {
New int `json:"new,omitempty"`
}
type UD struct {
HE uint `json:"he,omitempty"`
Flames uint `json:"flames,omitempty"`
Flash uint `json:"flash,omitempty"`
Decoy uint `json:"decoy,omitempty"`
Smoke uint `json:"smoke,omitempty"`
}
type Damage struct {
Enemy uint `json:"enemy,omitempty"`
Team uint `json:"team,omitempty"`
UD *UD `json:"ud,omitempty"`
}
type SelfTeamEnemy struct {
@@ -258,7 +249,7 @@ func IsAuthCodeValid(player *ent.Player, lock *sync.RWMutex, apiKey string, shar
var err error
if shareCode == "" {
lock.RLock()
tMatch, err = player.QueryMatches().Order(ent.Asc(match.FieldDate)).Limit(1).Only(context.Background())
tMatch, err = player.QueryMatches().Order(ent.Asc(match.FieldDate)).First(context.Background())
lock.RUnlock()
if err != nil {
return false, err
@@ -280,7 +271,7 @@ func IsAuthCodeValid(player *ent.Player, lock *sync.RWMutex, apiKey string, shar
func GetNewShareCodesForPlayer(player *ent.Player, lock *sync.RWMutex, apiKey string, rl ratelimit.Limiter) ([]string, error) {
lock.RLock()
tMatch, err := player.QueryMatches().Order(ent.Desc(match.FieldDate)).Limit(1).Only(context.Background())
tMatch, err := player.QueryMatches().Order(ent.Desc(match.FieldDate)).First(context.Background())
lock.RUnlock()
if err != nil {
return nil, err