From 41def830c48e0e968c6bad8128a358236ea7c551 Mon Sep 17 00:00:00 2001 From: Noi Date: Fri, 8 Dec 2023 20:44:42 -0800 Subject: [PATCH 1/2] Only remove data from guilds in own shard --- BackgroundServices/DataRetention.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/BackgroundServices/DataRetention.cs b/BackgroundServices/DataRetention.cs index 1156e48..76b1b83 100644 --- a/BackgroundServices/DataRetention.cs +++ b/BackgroundServices/DataRetention.cs @@ -53,9 +53,11 @@ class DataRetention : BackgroundService { // And let go of old data var staleGuildCount = await db.GuildConfigurations + .Where(g => localGuilds.Contains(g.GuildId)) .Where(g => now - TimeSpan.FromDays(StaleGuildThreshold) > g.LastSeen) .ExecuteDeleteAsync(); var staleUserCount = await db.UserEntries + .Where(gu => localGuilds.Contains(gu.GuildId)) .Where(gu => now - TimeSpan.FromDays(StaleUserThreashold) > gu.LastSeen) .ExecuteDeleteAsync(); From 85bb07ed96abc7a6071ff5e3e6706a01d7cfb923 Mon Sep 17 00:00:00 2001 From: Noi Date: Fri, 8 Dec 2023 20:45:40 -0800 Subject: [PATCH 2/2] Fix tickCount incrementing more than once per tick --- BackgroundServices/ShardBackgroundWorker.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BackgroundServices/ShardBackgroundWorker.cs b/BackgroundServices/ShardBackgroundWorker.cs index 2c6f2f9..baeb4aa 100644 --- a/BackgroundServices/ShardBackgroundWorker.cs +++ b/BackgroundServices/ShardBackgroundWorker.cs @@ -57,11 +57,11 @@ class ShardBackgroundWorker : IDisposable { if (Instance.DiscordClient.ConnectionState != ConnectionState.Connected) continue; // Execute tasks sequentially + _tickCount++; foreach (var service in _workers) { CurrentExecutingService = service.GetType().Name; try { if (_workerCanceller.IsCancellationRequested) break; - _tickCount++; await service.OnTick(_tickCount, _workerCanceller.Token); } catch (Exception ex) when (ex is not (TaskCanceledException or OperationCanceledException or ObjectDisposedException)) {