fixed wrong addDate logic

This commit is contained in:
2021-11-02 09:13:39 +01:00
parent 87c69fd343
commit 491abc2869
3 changed files with 18 additions and 13 deletions

18
main.go
View File

@@ -81,19 +81,17 @@ func housekeeping() {
}
for _, bp := range bPlayers {
qMatch := db.Match.Update().Where(match.HasPlayersWith(player.ID(bp.ID)))
if !bp.GameBanDate.IsZero() {
qMatch.Where(match.DateLTE(bp.GameBanDate.AddDate(0, 0, -30))).SetGamebanPresent(true)
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 {
log.Warningf("[HK] Unable to set gameban/vac for match: %v", err)
}
}
if !bp.VacDate.IsZero() {
qMatch.Where(match.DateLTE(bp.VacDate.AddDate(0, 0, -30))).SetVacPresent(true)
}
err := qMatch.Exec(context.Background())
if err != nil {
log.Warningf("[HK] Unable to query for banned players matches: %v", err)
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 {
log.Warningf("[HK] Unable to set gameban/vac for match: %v", err)
}
}
}