some formatting fixes
This commit is contained in:
36
main.go
36
main.go
@@ -37,7 +37,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
//goland:noinspection ALL
|
|
||||||
var (
|
var (
|
||||||
conf = utils.Conf{}
|
conf = utils.Conf{}
|
||||||
demoLoader = &csgo.DemoMatchLoader{}
|
demoLoader = &csgo.DemoMatchLoader{}
|
||||||
@@ -91,20 +90,34 @@ func housekeeping() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// mark matches as vac/gameban
|
// mark matches as vac/gameban
|
||||||
bPlayers, err := db.Player.Query().Select(player.FieldID, player.FieldGameBanDate, player.FieldVacDate).Where(player.Or(player.GameBanDateNotNil(), player.VacDateNotNil())).All(context.Background())
|
bPlayers, err := db.Player.Query().
|
||||||
|
Select(player.FieldID, player.FieldGameBanDate, player.FieldVacDate).
|
||||||
|
Where(player.Or(player.GameBanDateNotNil(), player.VacDateNotNil())).
|
||||||
|
All(context.Background())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warningf("[HK] Unable to query for banned players: %v", err)
|
log.Warningf("[HK] Unable to query for banned players: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, bp := range bPlayers {
|
for _, bp := range bPlayers {
|
||||||
if !bp.GameBanDate.IsZero() {
|
if !bp.GameBanDate.IsZero() {
|
||||||
err := db.Match.Update().Where(match.And(match.HasPlayersWith(player.ID(bp.ID)), match.DateLTE(bp.GameBanDate.AddDate(0, 0, 30)))).SetGamebanPresent(true).Exec(context.Background())
|
err := db.Match.Update().
|
||||||
|
Where(
|
||||||
|
match.And(
|
||||||
|
match.HasPlayersWith(player.ID(bp.ID)),
|
||||||
|
match.DateLTE(bp.GameBanDate.AddDate(0, 0, 30)),
|
||||||
|
)).
|
||||||
|
SetGamebanPresent(true).Exec(context.Background())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warningf("[HK] Unable to set gameban/vac for match: %v", err)
|
log.Warningf("[HK] Unable to set gameban/vac for match: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !bp.VacDate.IsZero() {
|
if !bp.VacDate.IsZero() {
|
||||||
err := db.Match.Update().Where(match.And(match.HasPlayersWith(player.ID(bp.ID)), match.DateLTE(bp.VacDate.AddDate(0, 0, 30)))).SetVacPresent(true).Exec(context.Background())
|
err := db.Match.Update().
|
||||||
|
Where(
|
||||||
|
match.And(
|
||||||
|
match.HasPlayersWith(player.ID(bp.ID)),
|
||||||
|
match.DateLTE(bp.VacDate.AddDate(0, 0, 30)),
|
||||||
|
)).SetVacPresent(true).Exec(context.Background())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warningf("[HK] Unable to set gameban/vac for match: %v", err)
|
log.Warningf("[HK] Unable to set gameban/vac for match: %v", err)
|
||||||
}
|
}
|
||||||
@@ -112,7 +125,12 @@ func housekeeping() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// try parsing demos not parsed
|
// try parsing demos not parsed
|
||||||
tMatches, err := db.Match.Query().Where(match.And(match.DateGT(time.Now().UTC().AddDate(0, 0, -1*conf.Csgowtfd.DemosExpire)), match.DemoParsed(false))).All(context.Background())
|
tMatches, err := db.Match.Query().
|
||||||
|
Where(
|
||||||
|
match.And(
|
||||||
|
match.DateGT(time.Now().UTC().AddDate(0, 0, -1*conf.Csgowtfd.DemosExpire)),
|
||||||
|
match.DemoParsed(false))).
|
||||||
|
All(context.Background())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warningf("[HK] Failure getting matches to retry parsing: %v", err)
|
log.Warningf("[HK] Failure getting matches to retry parsing: %v", err)
|
||||||
continue
|
continue
|
||||||
@@ -133,20 +151,22 @@ func housekeeping() {
|
|||||||
|
|
||||||
// check for inconsistent matches
|
// check for inconsistent matches
|
||||||
tMatchIDs, err := db.Match.Query().IDs(context.Background())
|
tMatchIDs, err := db.Match.Query().IDs(context.Background())
|
||||||
|
|
||||||
for _, mid := range tMatchIDs {
|
for _, mid := range tMatchIDs {
|
||||||
var v []struct {
|
var v []struct {
|
||||||
ID int `json:"match_stats"`
|
ID int `json:"match_stats"`
|
||||||
Count int `json:"count"`
|
Count int `json:"count"`
|
||||||
}
|
}
|
||||||
|
|
||||||
err = db.MatchPlayer.Query().Where(matchplayer.MatchStats(mid)).GroupBy(matchplayer.FieldMatchStats).Aggregate(ent.Count()).Scan(context.Background(), &v)
|
err = db.MatchPlayer.Query().
|
||||||
|
Where(matchplayer.MatchStats(mid)).
|
||||||
|
GroupBy(matchplayer.FieldMatchStats).
|
||||||
|
Aggregate(ent.Count()).
|
||||||
|
Scan(context.Background(), &v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warningf("[HK] Unable to query for matchplayers for match %d: %v", mid, err)
|
log.Warningf("[HK] Unable to query for matchplayers for match %d: %v", mid, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debugf("%+v", v)
|
|
||||||
if v[0].Count < 10 {
|
if v[0].Count < 10 {
|
||||||
log.Warningf("[HK] Found match without all players, try to reload it.")
|
log.Warningf("[HK] Found match without all players, try to reload it.")
|
||||||
tMatch, err := db.Match.Get(context.Background(), mid)
|
tMatch, err := db.Match.Get(context.Background(), mid)
|
||||||
|
@@ -278,7 +278,7 @@ func GetMetaStats(dbPlayer *ent.Player) (*MetaStatsResponse, error) {
|
|||||||
pMatches, err := s.QueryMatches().
|
pMatches, err := s.QueryMatches().
|
||||||
Select(match.FieldID, match.FieldMatchResult, match.FieldMap).
|
Select(match.FieldID, match.FieldMatchResult, match.FieldMap).
|
||||||
Where(match.IDIn(matchIDs...)).
|
Where(match.IDIn(matchIDs...)).
|
||||||
WithStats().
|
WithStats(). // TODO: limit fields returned
|
||||||
Where(match.HasStatsWith(matchplayer.Or(matchplayer.PlayerStats(dbPlayer.ID), matchplayer.PlayerStats(s.ID)))).
|
Where(match.HasStatsWith(matchplayer.Or(matchplayer.PlayerStats(dbPlayer.ID), matchplayer.PlayerStats(s.ID)))).
|
||||||
All(context.Background())
|
All(context.Background())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Reference in New Issue
Block a user