added check for missing players to HK
This commit is contained in:
36
main.go
36
main.go
@@ -165,6 +165,42 @@ func housekeeping() {
|
||||
log.Warningf("[HK] Failure trying to parse match %d: %v", m.ID, err)
|
||||
}
|
||||
}
|
||||
|
||||
// check for inconsistent matches
|
||||
tMatchIDs, err := db.Match.Query().IDs(context.Background())
|
||||
|
||||
for _, mid := range tMatchIDs {
|
||||
var v []struct {
|
||||
ID int `json:"match_stats"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
err = db.MatchPlayer.Query().Where(matchplayer.MatchStats(mid)).GroupBy(matchplayer.FieldMatchStats).Aggregate(ent.Count()).Scan(context.Background(), &v)
|
||||
if err != nil {
|
||||
log.Warningf("[HK] Unable to query for matchplayers for match %d: %v", mid, err)
|
||||
continue
|
||||
}
|
||||
|
||||
log.Debugf("%+v", v)
|
||||
if v[0].Count < 10 {
|
||||
log.Warningf("[HK] Found match without all players, try to reload it.")
|
||||
tMatch, err := db.Match.Get(context.Background(), mid)
|
||||
if err != nil {
|
||||
log.Warningf("[HK] Unable to get match with id %d: %v", mid, err)
|
||||
continue
|
||||
}
|
||||
err = utils.DeleteMatch(tMatch, db)
|
||||
if err != nil {
|
||||
log.Warningf("[HK] Unable to delete match with id %d: %v", mid, err)
|
||||
continue
|
||||
}
|
||||
|
||||
err = demoLoader.LoadDemo(&csgo.Demo{ShareCode: tMatch.ShareCode})
|
||||
if err != nil {
|
||||
log.Warningf("[HK] Unable to requeue match with id %d: %v", mid, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user