Hopefully fixed the startup issue
This commit is contained in:
parent
0d6b4da1ce
commit
e896c14303
2 changed files with 29 additions and 19 deletions
|
@ -244,7 +244,7 @@ public class UserPunishService : IEService, IReadyExecutor
|
|||
{
|
||||
await using var uow = _db.GetDbContext();
|
||||
|
||||
var cleared = await uow.GetTable<Warning>()
|
||||
var toClear = await uow.GetTable<Warning>()
|
||||
.Where(x => uow.GetTable<GuildConfig>()
|
||||
.Count(y => y.GuildId == x.GuildId
|
||||
&& y.WarnExpireHours > 0
|
||||
|
@ -256,13 +256,18 @@ public class UserPunishService : IEService, IReadyExecutor
|
|||
.Where(y => x.GuildId == y.GuildId)
|
||||
.Select(y => y.WarnExpireHours)
|
||||
.First()))
|
||||
.Select(x => x.Id)
|
||||
.ToListAsyncLinqToDB();
|
||||
|
||||
var cleared = await uow.GetTable<Warning>()
|
||||
.Where(x => toClear.Contains(x.Id))
|
||||
.UpdateAsync(_ => new()
|
||||
{
|
||||
Forgiven = true,
|
||||
ForgivenBy = "expiry"
|
||||
});
|
||||
|
||||
var deleted = await uow.GetTable<Warning>()
|
||||
var toDelete = await uow.GetTable<Warning>()
|
||||
.Where(x => uow.GetTable<GuildConfig>()
|
||||
.Count(y => y.GuildId == x.GuildId
|
||||
&& y.WarnExpireHours > 0
|
||||
|
@ -273,13 +278,18 @@ public class UserPunishService : IEService, IReadyExecutor
|
|||
.Where(y => x.GuildId == y.GuildId)
|
||||
.Select(y => y.WarnExpireHours)
|
||||
.First()))
|
||||
.Select(x => x.Id)
|
||||
.ToListAsyncLinqToDB();
|
||||
|
||||
var deleted = await uow.GetTable<Warning>()
|
||||
.Where(x => toDelete.Contains(x.Id))
|
||||
.DeleteAsync();
|
||||
|
||||
if (cleared > 0 || deleted > 0)
|
||||
{
|
||||
Log.Information("Cleared {ClearedWarnings} warnings and deleted {DeletedWarnings} warnings due to expiry",
|
||||
cleared,
|
||||
deleted);
|
||||
toDelete.Count);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue