From 6df2751f5e2cf6c26fbb8cfebf8343f7004a8f84 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Wed, 10 Jul 2024 17:02:55 +0330 Subject: [PATCH 1/3] fix: making heatmaps less intensive! + not querying the users now and just using the users interacting in the day (author, mention, and reply) --- .../analyzer/analyzer_heatmaps.py | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/discord_analyzer/analyzer/analyzer_heatmaps.py b/discord_analyzer/analyzer/analyzer_heatmaps.py index e4c5b1f..171704c 100644 --- a/discord_analyzer/analyzer/analyzer_heatmaps.py +++ b/discord_analyzer/analyzer/analyzer_heatmaps.py @@ -100,10 +100,6 @@ def analysis_heatmap(self, guildId: str, from_start: bool = False): guildId=guildId, ) - account_list = get_userids( - db_mongo_client=self.DB_connections.mongoOps.mongo_db_access.db_mongo_client, - guildId=guildId, - ) while last_date.date() < datetime.now().date(): entries = rawinfo_c.get_day_entries(last_date, "ANALYZER HEATMAPS: ") if len(entries) == 0: @@ -112,36 +108,38 @@ def analysis_heatmap(self, guildId: str, from_start: bool = False): continue prepared_list = [] + account_list = [] for entry in entries: if "replied_user" not in entry: reply = "" else: reply = entry["replied_user"] + if reply not in account_list and reply not in bot_ids: + account_list.append(reply) # eliminating bots - if entry["author"] not in bot_ids: + author = entry["author"] + mentioned_users = entry["user_mentions"] + if author not in bot_ids: prepared_list.append( { # .strftime('%Y-%m-%d %H:%M'), "datetime": entry["createdDate"], "channel": entry["channelId"], - "author": entry["author"], + "author": author, "replied_user": reply, - "user_mentions": entry["user_mentions"], + "user_mentions": mentioned_users, "reactions": entry["reactions"], "threadId": entry["threadId"], "mess_type": entry["type"], } ) - if ( - entry["author"] not in account_list - and entry["author"] not in bot_ids - ): - account_list.append(entry["author"]) - - if entry["user_mentions"] is not None: - for account in entry["user_mentions"]: + if author not in account_list: + account_list.append(author) + + if mentioned_users is not None: + for account in mentioned_users: if account not in account_list and account not in bot_ids: account_list.append(account) From 0f891cdc69975724bddc430808dc6695b88b9b6b Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Wed, 10 Jul 2024 17:22:18 +0330 Subject: [PATCH 2/3] fix: Adding missing reacting members in heatmaps analysis! --- discord_analyzer/analyzer/analyzer_heatmaps.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/discord_analyzer/analyzer/analyzer_heatmaps.py b/discord_analyzer/analyzer/analyzer_heatmaps.py index 171704c..56081ef 100644 --- a/discord_analyzer/analyzer/analyzer_heatmaps.py +++ b/discord_analyzer/analyzer/analyzer_heatmaps.py @@ -138,6 +138,12 @@ def analysis_heatmap(self, guildId: str, from_start: bool = False): if author not in account_list: account_list.append(author) + # Adding the interacting users + for users_reacting in entry["reactions"]: + for user in users_reacting.split(",")[:-1]: + if user not in account_list: + account_list.append(user) + if mentioned_users is not None: for account in mentioned_users: if account not in account_list and account not in bot_ids: From e55c2273cb425c768e8cf8cfbd6bd3aa03e147e4 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Wed, 10 Jul 2024 17:27:59 +0330 Subject: [PATCH 3/3] fix: black linter issue! --- discord_analyzer/analyzer/analyzer_heatmaps.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/discord_analyzer/analyzer/analyzer_heatmaps.py b/discord_analyzer/analyzer/analyzer_heatmaps.py index 56081ef..5c951ea 100644 --- a/discord_analyzer/analyzer/analyzer_heatmaps.py +++ b/discord_analyzer/analyzer/analyzer_heatmaps.py @@ -141,8 +141,8 @@ def analysis_heatmap(self, guildId: str, from_start: bool = False): # Adding the interacting users for users_reacting in entry["reactions"]: for user in users_reacting.split(",")[:-1]: - if user not in account_list: - account_list.append(user) + if user not in account_list: + account_list.append(user) if mentioned_users is not None: for account in mentioned_users: