mirror of
https://github.com/NoiTheCat/BirthdayBot.git
synced 2024-11-21 21:54:36 +00:00
Merge pull request #55 from NoiTheCat/fixes/retention-errors
Fix data retention bugs causing mass deletion of birthdays
This commit is contained in:
commit
df09e4ab18
2 changed files with 3 additions and 1 deletions
|
@ -53,9 +53,11 @@ class DataRetention : BackgroundService {
|
||||||
|
|
||||||
// And let go of old data
|
// And let go of old data
|
||||||
var staleGuildCount = await db.GuildConfigurations
|
var staleGuildCount = await db.GuildConfigurations
|
||||||
|
.Where(g => localGuilds.Contains(g.GuildId))
|
||||||
.Where(g => now - TimeSpan.FromDays(StaleGuildThreshold) > g.LastSeen)
|
.Where(g => now - TimeSpan.FromDays(StaleGuildThreshold) > g.LastSeen)
|
||||||
.ExecuteDeleteAsync();
|
.ExecuteDeleteAsync();
|
||||||
var staleUserCount = await db.UserEntries
|
var staleUserCount = await db.UserEntries
|
||||||
|
.Where(gu => localGuilds.Contains(gu.GuildId))
|
||||||
.Where(gu => now - TimeSpan.FromDays(StaleUserThreashold) > gu.LastSeen)
|
.Where(gu => now - TimeSpan.FromDays(StaleUserThreashold) > gu.LastSeen)
|
||||||
.ExecuteDeleteAsync();
|
.ExecuteDeleteAsync();
|
||||||
|
|
||||||
|
|
|
@ -57,11 +57,11 @@ class ShardBackgroundWorker : IDisposable {
|
||||||
if (Instance.DiscordClient.ConnectionState != ConnectionState.Connected) continue;
|
if (Instance.DiscordClient.ConnectionState != ConnectionState.Connected) continue;
|
||||||
|
|
||||||
// Execute tasks sequentially
|
// Execute tasks sequentially
|
||||||
|
_tickCount++;
|
||||||
foreach (var service in _workers) {
|
foreach (var service in _workers) {
|
||||||
CurrentExecutingService = service.GetType().Name;
|
CurrentExecutingService = service.GetType().Name;
|
||||||
try {
|
try {
|
||||||
if (_workerCanceller.IsCancellationRequested) break;
|
if (_workerCanceller.IsCancellationRequested) break;
|
||||||
_tickCount++;
|
|
||||||
await service.OnTick(_tickCount, _workerCanceller.Token);
|
await service.OnTick(_tickCount, _workerCanceller.Token);
|
||||||
} catch (Exception ex) when (ex is not
|
} catch (Exception ex) when (ex is not
|
||||||
(TaskCanceledException or OperationCanceledException or ObjectDisposedException)) {
|
(TaskCanceledException or OperationCanceledException or ObjectDisposedException)) {
|
||||||
|
|
Loading…
Reference in a new issue