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

@@ -111,7 +111,7 @@ func housekeeping() {
log.Warningf("[HK] last shareCode for player %d does not match player", tPlayer.ID)
continue
default:
log.Errorf("[HK] Error while request sharecodes: %v", err)
log.Errorf("[HK] Error while requesting sharecodes for %d: %v", tPlayer.ID, err)
continue
}
}
@@ -611,13 +611,6 @@ func getMatch(w http.ResponseWriter, r *http.Request) {
Dmg: &utils.Damage{
Team: iStats.DmgTeam,
Enemy: iStats.DmgEnemy,
UD: &utils.UD{
HE: iStats.UdHe,
Smoke: iStats.UdSmoke,
Flash: iStats.UdFlash,
Decoy: iStats.UdDecoy,
Flames: iStats.UdFlames,
},
},
Color: iStats.Color.String(),
Crosshair: iStats.Crosshair,

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