From 9af3716977820a05b4db14726db90069c0761171 Mon Sep 17 00:00:00 2001 From: Klemek Date: Mon, 15 Mar 2021 21:04:15 +0100 Subject: [PATCH] fixed not cached channel in 'full' search --- src/logs/guild_logs.py | 4 +++- src/scanners/scanner.py | 21 +++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/logs/guild_logs.py b/src/logs/guild_logs.py index 713492c..135e3e5 100644 --- a/src/logs/guild_logs.py +++ b/src/logs/guild_logs.py @@ -112,7 +112,9 @@ class GuildLogs: # load channels t0 = datetime.now() if len(target_channels) == 0: - target_channels = self.guild.text_channels + target_channels = ( + self.guild.text_channels if not fast else self.channels.keys() + ) loading_new = 0 queried_msg = 0 total_chan = 0 diff --git a/src/scanners/scanner.py b/src/scanners/scanner.py index 058337e..f1fb14e 100644 --- a/src/scanners/scanner.py +++ b/src/scanners/scanner.py @@ -111,16 +111,17 @@ class Scanner(ABC): self.chan_count = 0 t0 = datetime.now() for channel in self.channels: - channel_logs = logs.channels[channel.id] - count = sum( - [ - self.compute_message(channel_logs, message_log) - for message_log in channel_logs.messages - ] - ) - self.total_msg += len(channel_logs.messages) - self.msg_count += count - self.chan_count += 1 if count > 0 else 0 + if channel.id in logs.channels: + channel_logs = logs.channels[channel.id] + count = sum( + [ + self.compute_message(channel_logs, message_log) + for message_log in channel_logs.messages + ] + ) + self.total_msg += len(channel_logs.messages) + self.msg_count += count + self.chan_count += 1 if count > 0 else 0 logging.info(f"scan {guild.id} > scanned in {delta(t0):,}ms") await progress.edit(content="```Computing results...```") # Display results