1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-01-31 09:09:00 +03:00

Fix a critical performance issue in GuildData, skip guild ticks if running behind

Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
Octol1ttle 2023-02-02 00:16:31 +05:00
parent 1c13f0a310
commit eaeacc1206
Signed by: Octol1ttle
GPG key ID: B77C34313AEE1FFF
3 changed files with 3 additions and 3 deletions

View file

@ -58,7 +58,6 @@ resharper_indent_nested_usings_stmt = true
resharper_indent_nested_while_stmt = true resharper_indent_nested_while_stmt = true
resharper_indent_preprocessor_if = usual_indent resharper_indent_preprocessor_if = usual_indent
resharper_indent_preprocessor_other = usual_indent resharper_indent_preprocessor_other = usual_indent
resharper_int_align_fields = true
resharper_int_align_methods = true resharper_int_align_methods = true
resharper_int_align_parameters = true resharper_int_align_parameters = true
resharper_int_align_properties = true resharper_int_align_properties = true

View file

@ -72,6 +72,8 @@ public static class Boyfriend {
} }
private static async void TickAllGuildsAsync(object? sender, ElapsedEventArgs e) { private static async void TickAllGuildsAsync(object? sender, ElapsedEventArgs e) {
if (GuildTickTasks.Count is not 0) return;
foreach (var guild in Client.Guilds) GuildTickTasks.Add(TickGuildAsync(guild)); foreach (var guild in Client.Guilds) GuildTickTasks.Add(TickGuildAsync(guild));
try { Task.WaitAll(GuildTickTasks.ToArray()); } catch (AggregateException ex) { try { Task.WaitAll(GuildTickTasks.ToArray()); } catch (AggregateException ex) {

View file

@ -74,7 +74,6 @@ public record GuildData {
MemberData.Add(deserialised!.Id, deserialised); MemberData.Add(deserialised!.Id, deserialised);
} }
guild.DownloadUsersAsync().Wait();
foreach (var member in guild.Users.Where(user => !user.IsBot)) { foreach (var member in guild.Users.Where(user => !user.IsBot)) {
if (MemberData.TryGetValue(member.Id, out var memberData)) { if (MemberData.TryGetValue(member.Id, out var memberData)) {
if (!memberData.IsInGuild if (!memberData.IsInGuild