From de304a39968db3de80b37f43cbc3f1fff5f7d7fb Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Mon, 1 Jul 2024 16:39:30 +0330 Subject: [PATCH 01/23] feat: wrapping analyzer in one unit! Now the analyzer will accept `platform_id`, `resources`, `period`, `action`, and `window` as input --- analyzer_init.py | 34 ------- discord_analyzer/tc_analyzer.py | 98 +++++++++++-------- discord_utils.py | 2 +- setup.py | 17 ++++ tests/integration/test_all_active_period.py | 7 +- .../test_all_joined_day_members.py | 7 +- tests/integration/test_analyzer_init.py | 2 +- ...iod_1year_recompute_available_analytics.py | 9 +- ..._period_1year_recompute_empty_analytics.py | 7 +- ...riod_1year_run_once_available_analytics.py | 7 +- ...r_period_1year_run_once_empty_analytics.py | 5 +- .../test_analyzer_period_35days_run_once.py | 7 +- ...od_3month_recompute_available_analytics.py | 9 +- ...period_3month_recompute_empty_analytics.py | 7 +- ...iod_3month_run_once_available_analytics.py | 5 +- ..._period_3month_run_once_empty_analytics.py | 7 +- ...od_6month_recompute_available_analytics.py | 9 +- ...period_6month_recompute_empty_analytics.py | 7 +- ...iod_6month_run_once_available_analytics.py | 5 +- ..._period_6month_run_once_empty_analytics.py | 7 +- ...iod_month_recompute_available_analytics.py | 9 +- ..._period_month_recompute_empty_analytics.py | 7 +- ...riod_month_run_once_available_analytics.py | 7 +- ...r_period_month_run_once_empty_analytics.py | 7 +- ...riod_week_recompute_available_analytics.py | 9 +- ...r_period_week_recompute_empty_analytics.py | 9 +- ...eriod_week_run_once_available_analytics.py | 7 +- ...er_period_week_run_once_empty_analytics.py | 7 +- .../test_assess_engagement_mention.py | 4 +- .../test_assess_engagement_reactions.py | 4 +- .../test_assess_engagement_replies.py | 4 +- tests/integration/test_exclude_bots.py | 7 +- ..._generated_graph_period_1_year_run_once.py | 7 +- .../test_generated_graph_period_1year.py | 9 +- .../test_generated_graph_period_35_days.py | 7 +- ...generated_graph_period_35_days_run_once.py | 7 +- .../test_generated_graph_period_3_months.py | 9 +- ...enerated_graph_period_3_months_run_once.py | 7 +- .../test_generated_graph_period_6_months.py | 9 +- ...enerated_graph_period_6_months_run_once.py | 7 +- ...est_member_activities_action_all_active.py | 22 ++--- ...member_activities_action_all_activities.py | 10 +- ...member_activity_from_start_no_past_data.py | 48 ++------- ...rom_start_with_guild_heatmaps_available.py | 9 +- ...t_with_guild_memberactivities_available.py | 9 +- ...r_activity_from_start_with_one_interval.py | 9 +- .../integration/test_member_activity_utils.py | 8 +- .../test_memberactivities_mentions.py | 9 +- .../test_memberactivities_reaction.py | 10 +- .../test_memberactivities_reply.py | 9 +- ...t_mentioned_active_members_from_message.py | 7 +- tests/integration/utils/analyzer_setup.py | 12 --- ...e_and_setup_guild.py => setup_platform.py} | 30 ++++-- worker.py | 28 ------ 54 files changed, 266 insertions(+), 355 deletions(-) delete mode 100644 analyzer_init.py create mode 100644 setup.py rename tests/integration/utils/{remove_and_setup_guild.py => setup_platform.py} (84%) delete mode 100644 worker.py diff --git a/analyzer_init.py b/analyzer_init.py deleted file mode 100644 index d29bf46..0000000 --- a/analyzer_init.py +++ /dev/null @@ -1,34 +0,0 @@ -from typing import Any - -from discord_analyzer.tc_analyzer import TCAnalyzer - - -class AnalyzerInit: - """ - initialize the analyzer with its configs - """ - - # TODO: update to platform_id as input - def __init__(self, guild_id: str) -> None: - self.guild_id = guild_id - - def get_analyzer(self) -> TCAnalyzer: - """ - Returns: - --------- - analyzer : TCAnalyzer - """ - analyzer = TCAnalyzer(self.guild_id) - analyzer.database_connect() - - return analyzer - - def _get_mongo_connection(self, mongo_creds: dict[str, Any]): - user = mongo_creds["user"] - password = mongo_creds["password"] - host = mongo_creds["host"] - port = mongo_creds["port"] - - connection = f"mongodb://{user}:{password}@{host}:{port}" - - return connection diff --git a/discord_analyzer/tc_analyzer.py b/discord_analyzer/tc_analyzer.py index a6933cf..010bc86 100644 --- a/discord_analyzer/tc_analyzer.py +++ b/discord_analyzer/tc_analyzer.py @@ -1,5 +1,6 @@ import logging +from datetime import datetime from discord_analyzer.metrics.analyzer_memberactivities import MemberActivities from discord_analyzer.metrics.heatmaps import Heatmaps from discord_analyzer.metrics.neo4j_analytics import Neo4JAnalytics @@ -7,38 +8,73 @@ from discord_analyzer.metrics.utils.platform import Platform from discord_analyzer.schemas import GraphSchema from discord_analyzer.schemas.platform_configs import DiscordAnalyzerConfig +from discord_analyzer.schemas.platform_configs.config_base import PlatformConfigBase +from discord_analyzer.schemas.platform_configs import DiscordAnalyzerConfig class TCAnalyzer(AnalyzerDBManager): """ - TCAnalyzer + TogetherCrew's Analyzer class that handles database connections and data analysis """ def __init__( self, platform_id: str, + resources: list[str], + period: datetime, + action: dict[str, int], + window: dict[str, int], + analyzer_config: PlatformConfigBase = DiscordAnalyzerConfig(), ): """ - Class initiation function + analyze the platform's data + producing heatmaps, memberactivities, and graph analytics + + Parameters + ----------- + platform_id : str + platform to analyze its data + resources : list[str] + the resources id for filtering on data + period : datetime + the period to compute the analytics for + action : dict[str, int] + Parameters for computing different memberactivities + window : dict[str, int] + Parameters for the whole analyzer, includes the step size and window size + analyzer_config : PlatformConfigBase + the config for analyzer to use """ logging.basicConfig() logging.getLogger().setLevel(logging.INFO) self.platform_id = platform_id - - # hard-coded for now - # TODO: define a structure and make it read from db - self.analyzer_config = DiscordAnalyzerConfig() + self.resources = resources + self.period = period + self.action = action + self.window = window + self.analyzer_config = analyzer_config self.platform_utils = Platform(platform_id) self.community_id = self.platform_utils.get_community_id() - self.graph_schema = GraphSchema(platform=self.analyzer_config.platform) + self.graph_schema = GraphSchema(platform=analyzer_config.platform) self.neo4j_analytics = Neo4JAnalytics(platform_id, self.graph_schema) + # connect to Neo4j & MongoDB database + self.database_connect() + + + def analyze(self, recompute: bool) -> None: + # TODO: merge run_one and recompute codes + if recompute: + self.run_once() + else: + self.recompute() + def run_once(self): - """Run analysis once (Wrapper)""" + """Run analysis and append to previous anlaytics""" # check if the platform was available # if not, will raise an error self.check_platform() @@ -47,8 +83,8 @@ def run_once(self): heatmaps_analysis = Heatmaps( platform_id=self.platform_id, - period=self.platform_utils.get_platform_period(), - resources=self.platform_utils.get_platform_resources(), + period=self.period, + resources=self.resources, analyzer_config=self.analyzer_config, ) heatmaps_data = heatmaps_analysis.start(from_start=False) @@ -66,14 +102,13 @@ def run_once(self): remove_heatmaps=False, ) - window, action = self.platform_utils.get_platform_analyzer_params() memberactivity_analysis = MemberActivities( platform_id=self.platform_id, - resources=self.platform_utils.get_platform_resources(), - action_config=action, - window_config=window, + resources=self.resources, + action_config=self.action, + window_config=self.window, analyzer_config=self.analyzer_config, - analyzer_period=self.platform_utils.get_platform_period(), + analyzer_period=self.period, ) ( member_activities_data, @@ -100,24 +135,10 @@ def run_once(self): self.platform_utils.update_isin_progress() - def recompute_analytics(self): + def recompute(self): """ - recompute the memberactivities (and heatmaps in case needed) - for a new selection of channels - - - - first it would update the channel selection in Core.Platform - - - Second the memebracitivites collection - of the input guildId would become empty - - - Third we would have the analytics running again on the - new channel selection (analytics would be inserted in memebractivities) - - - Returns: - --------- - `None` + recompute the analytics (heatmaps + memberactivities + graph analytics) + for a new selection of channels """ # check if the platform was available # if not, will raise an error @@ -126,8 +147,8 @@ def recompute_analytics(self): logging.info(f"Analyzing the Heatmaps data for platform: {self.platform_id}!") heatmaps_analysis = Heatmaps( platform_id=self.platform_id, - period=self.platform_utils.get_platform_period(), - resources=self.platform_utils.get_platform_resources(), + period=self.period, + resources=self.resources, analyzer_config=self.analyzer_config, ) heatmaps_data = heatmaps_analysis.start(from_start=True) @@ -149,14 +170,13 @@ def recompute_analytics(self): logging.info( f"Analyzing the MemberActivities data for platform: {self.platform_id}!" ) - window, action = self.platform_utils.get_platform_analyzer_params() memberactivity_analysis = MemberActivities( platform_id=self.platform_id, - resources=self.platform_utils.get_platform_resources(), - action_config=action, - window_config=window, + resources=self.resources, + action_config=self.action, + window_config=self.window, analyzer_config=self.analyzer_config, - analyzer_period=self.platform_utils.get_platform_period(), + analyzer_period=self.period, ) ( member_activities_data, diff --git a/discord_utils.py b/discord_utils.py index b21d8c9..69e0ca1 100644 --- a/discord_utils.py +++ b/discord_utils.py @@ -26,7 +26,7 @@ def analyzer_recompute(sagaId: str): def recompute_wrapper(**kwargs): logging.info("recompute wrapper") - analyzer.recompute_analytics() + analyzer.recompute() def publish_wrapper(**kwargs): pass diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..29cb148 --- /dev/null +++ b/setup.py @@ -0,0 +1,17 @@ +from setuptools import find_packages, setup + +with open("requirements.txt") as f: + requirements = f.read().splitlines() + + +setup( + name="tc-analyzer-lib", + version="1.0.0", + author="Mohammad Amin Dadgar, TogetherCrew", + maintainer="Mohammad Amin Dadgar", + maintainer_email="dadgaramin96@gmail.com", + packages=find_packages(), + description="A platform agnostic analyzer, computing the TogetherCrew dashboard metrics.", + long_description=open("README.md").read(), + install_requires=requirements, +) \ No newline at end of file diff --git a/tests/integration/test_all_active_period.py b/tests/integration/test_all_active_period.py index ab181f2..6ba4dd0 100644 --- a/tests/integration/test_all_active_period.py +++ b/tests/integration/test_all_active_period.py @@ -1,7 +1,7 @@ from datetime import datetime, timedelta -from .utils.analyzer_setup import launch_db_access, setup_analyzer -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.analyzer_setup import launch_db_access +from .utils.setup_platform import setup_platform def test_two_weeks_period_active_members(): @@ -20,7 +20,7 @@ def test_two_weeks_period_active_members(): # A guild connected at 35 days ago connected_days_before = 35 - setup_db_guild( + analyzer = setup_platform( db_access, platform_id, discordId_list=acc_id, @@ -170,7 +170,6 @@ def test_two_weeks_period_active_members(): rawinfo_samples ) - analyzer = setup_analyzer(platform_id) analyzer.run_once() memberactivities_cursor = db_access.query_db_find( diff --git a/tests/integration/test_all_joined_day_members.py b/tests/integration/test_all_joined_day_members.py index 9b01dfc..4796fa7 100644 --- a/tests/integration/test_all_joined_day_members.py +++ b/tests/integration/test_all_joined_day_members.py @@ -3,8 +3,8 @@ import numpy as np -from .utils.analyzer_setup import launch_db_access, setup_analyzer -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.analyzer_setup import launch_db_access +from .utils.setup_platform import setup_platform def test_all_joined_day_members(): @@ -26,7 +26,7 @@ def test_all_joined_day_members(): today - timedelta(days=13), ] - setup_db_guild( + analyzer = setup_platform( db_access, platform_id, discordId_list=acc_id, @@ -83,7 +83,6 @@ def test_all_joined_day_members(): rawinfo_samples ) - analyzer = setup_analyzer(platform_id) analyzer.run_once() cursor = db_access.db_mongo_client[platform_id]["memberactivities"].find([]) diff --git a/tests/integration/test_analyzer_init.py b/tests/integration/test_analyzer_init.py index 138ec5d..0007f14 100644 --- a/tests/integration/test_analyzer_init.py +++ b/tests/integration/test_analyzer_init.py @@ -100,7 +100,7 @@ def test_analyzer_init(): tc_discord_analyzer = analyzer.get_analyzer() - tc_discord_analyzer.recompute_analytics() + tc_discord_analyzer.recompute() heatmaps_data = mongo_client[guildId]["heatmaps"].find_one({}) assert heatmaps_data is not None diff --git a/tests/integration/test_analyzer_period_1year_recompute_available_analytics.py b/tests/integration/test_analyzer_period_1year_recompute_available_analytics.py index 9ecd3c6..5256b55 100644 --- a/tests/integration/test_analyzer_period_1year_recompute_available_analytics.py +++ b/tests/integration/test_analyzer_period_1year_recompute_available_analytics.py @@ -3,10 +3,10 @@ import numpy as np -from .utils.analyzer_setup import launch_db_access, setup_analyzer +from .utils.analyzer_setup import launch_db_access from .utils.mock_heatmaps import create_empty_heatmaps_data from .utils.mock_memberactivities import create_empty_memberactivities_data -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.setup_platform import setup_platform def test_analyzer_one_year_period_recompute_available_analytics(): @@ -23,7 +23,7 @@ def test_analyzer_one_year_period_recompute_available_analytics(): "973993299281076286", ] - setup_db_guild(db_access, platform_id, discordId_list=acc_id, days_ago_period=360) + analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=360) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") @@ -95,8 +95,7 @@ def test_analyzer_one_year_period_recompute_available_analytics(): rawinfo_samples ) - analyzer = setup_analyzer(platform_id) - analyzer.recompute_analytics() + analyzer.recompute() memberactivities_cursor = db_access.query_db_find( "memberactivities", {}, sorting=("date", -1) diff --git a/tests/integration/test_analyzer_period_1year_recompute_empty_analytics.py b/tests/integration/test_analyzer_period_1year_recompute_empty_analytics.py index 2392696..1403899 100644 --- a/tests/integration/test_analyzer_period_1year_recompute_empty_analytics.py +++ b/tests/integration/test_analyzer_period_1year_recompute_empty_analytics.py @@ -4,7 +4,7 @@ import numpy as np from .utils.analyzer_setup import launch_db_access, setup_analyzer -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.setup_platform import setup_platform def test_analyzer_one_year_period_recompute_empty_analytics(): @@ -21,7 +21,7 @@ def test_analyzer_one_year_period_recompute_empty_analytics(): "973993299281076286", ] - setup_db_guild(db_access, platform_id, discordId_list=acc_id, days_ago_period=360) + analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=360) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") @@ -75,8 +75,7 @@ def test_analyzer_one_year_period_recompute_empty_analytics(): rawinfo_samples ) - analyzer = setup_analyzer(platform_id) - analyzer.recompute_analytics() + analyzer.recompute() memberactivities_cursor = db_access.query_db_find( "memberactivities", {}, sorting=("date", -1) diff --git a/tests/integration/test_analyzer_period_1year_run_once_available_analytics.py b/tests/integration/test_analyzer_period_1year_run_once_available_analytics.py index 34f376c..3d9cb7f 100644 --- a/tests/integration/test_analyzer_period_1year_run_once_available_analytics.py +++ b/tests/integration/test_analyzer_period_1year_run_once_available_analytics.py @@ -3,10 +3,10 @@ import numpy as np -from .utils.analyzer_setup import launch_db_access, setup_analyzer +from .utils.analyzer_setup import launch_db_access from .utils.mock_heatmaps import create_empty_heatmaps_data from .utils.mock_memberactivities import create_empty_memberactivities_data -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.setup_platform import setup_platform def test_analyzer_one_year_period_run_once_available_analytics(): @@ -23,7 +23,7 @@ def test_analyzer_one_year_period_run_once_available_analytics(): "973993299281076286", ] - setup_db_guild(db_access, platform_id, discordId_list=acc_id, days_ago_period=360) + analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=360) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") @@ -99,7 +99,6 @@ def test_analyzer_one_year_period_run_once_available_analytics(): rawinfo_samples ) - analyzer = setup_analyzer(platform_id) analyzer.run_once() memberactivities_cursor = db_access.query_db_find( diff --git a/tests/integration/test_analyzer_period_1year_run_once_empty_analytics.py b/tests/integration/test_analyzer_period_1year_run_once_empty_analytics.py index cfaf8dc..c8d8ef9 100644 --- a/tests/integration/test_analyzer_period_1year_run_once_empty_analytics.py +++ b/tests/integration/test_analyzer_period_1year_run_once_empty_analytics.py @@ -4,7 +4,7 @@ import numpy as np from .utils.analyzer_setup import launch_db_access, setup_analyzer -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.setup_platform import setup_platform def test_analyzer_one_year_period_run_once_empty_analytics(): @@ -21,7 +21,7 @@ def test_analyzer_one_year_period_run_once_empty_analytics(): "973993299281076286", ] - setup_db_guild(db_access, platform_id, discordId_list=acc_id, days_ago_period=360) + analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=360) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") @@ -75,7 +75,6 @@ def test_analyzer_one_year_period_run_once_empty_analytics(): rawinfo_samples ) - analyzer = setup_analyzer(platform_id) analyzer.run_once() memberactivities_cursor = db_access.query_db_find( diff --git a/tests/integration/test_analyzer_period_35days_run_once.py b/tests/integration/test_analyzer_period_35days_run_once.py index 557636b..12f9373 100644 --- a/tests/integration/test_analyzer_period_35days_run_once.py +++ b/tests/integration/test_analyzer_period_35days_run_once.py @@ -3,10 +3,10 @@ import numpy as np -from .utils.analyzer_setup import launch_db_access, setup_analyzer +from .utils.analyzer_setup import launch_db_access from .utils.mock_heatmaps import create_empty_heatmaps_data from .utils.mock_memberactivities import create_empty_memberactivities_data -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.setup_platform import setup_platform def test_analyzer_40days_period_run_once_available_analytics_overlapping_period(): @@ -24,7 +24,7 @@ def test_analyzer_40days_period_run_once_available_analytics_overlapping_period( "user2", ] - setup_db_guild(db_access, platform_id, discordId_list=acc_id, days_ago_period=40) + analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=40) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") @@ -97,7 +97,6 @@ def test_analyzer_40days_period_run_once_available_analytics_overlapping_period( rawinfo_samples ) - analyzer = setup_analyzer(platform_id) analyzer.run_once() memberactivities_cursor = db_access.query_db_find( diff --git a/tests/integration/test_analyzer_period_3month_recompute_available_analytics.py b/tests/integration/test_analyzer_period_3month_recompute_available_analytics.py index eb4e149..8e842c0 100644 --- a/tests/integration/test_analyzer_period_3month_recompute_available_analytics.py +++ b/tests/integration/test_analyzer_period_3month_recompute_available_analytics.py @@ -3,10 +3,10 @@ import numpy as np -from .utils.analyzer_setup import launch_db_access, setup_analyzer +from .utils.analyzer_setup import launch_db_access from .utils.mock_heatmaps import create_empty_heatmaps_data from .utils.mock_memberactivities import create_empty_memberactivities_data -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.setup_platform import setup_platform def test_analyzer_three_month_period_recompute_available_analytics(): @@ -23,7 +23,7 @@ def test_analyzer_three_month_period_recompute_available_analytics(): "973993299281076286", ] - setup_db_guild(db_access, platform_id, discordId_list=acc_id, days_ago_period=90) + analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=90) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") @@ -95,8 +95,7 @@ def test_analyzer_three_month_period_recompute_available_analytics(): rawinfo_samples ) - analyzer = setup_analyzer(platform_id) - analyzer.recompute_analytics() + analyzer.recompute() memberactivities_cursor = db_access.query_db_find( "memberactivities", {}, sorting=("date", -1) diff --git a/tests/integration/test_analyzer_period_3month_recompute_empty_analytics.py b/tests/integration/test_analyzer_period_3month_recompute_empty_analytics.py index 7cd8f78..520a7ff 100644 --- a/tests/integration/test_analyzer_period_3month_recompute_empty_analytics.py +++ b/tests/integration/test_analyzer_period_3month_recompute_empty_analytics.py @@ -4,7 +4,7 @@ import numpy as np from .utils.analyzer_setup import launch_db_access, setup_analyzer -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.setup_platform import setup_platform def test_analyzer_three_month_period_recompute_empty_analytics(): @@ -21,7 +21,7 @@ def test_analyzer_three_month_period_recompute_empty_analytics(): "973993299281076286", ] - setup_db_guild(db_access, platform_id, discordId_list=acc_id, days_ago_period=90) + analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=90) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") @@ -75,8 +75,7 @@ def test_analyzer_three_month_period_recompute_empty_analytics(): rawinfo_samples ) - analyzer = setup_analyzer(platform_id) - analyzer.recompute_analytics() + analyzer.recompute() memberactivities_cursor = db_access.query_db_find( "memberactivities", {}, sorting=("date", -1) diff --git a/tests/integration/test_analyzer_period_3month_run_once_available_analytics.py b/tests/integration/test_analyzer_period_3month_run_once_available_analytics.py index 3e7e47d..7909168 100644 --- a/tests/integration/test_analyzer_period_3month_run_once_available_analytics.py +++ b/tests/integration/test_analyzer_period_3month_run_once_available_analytics.py @@ -6,7 +6,7 @@ from .utils.analyzer_setup import launch_db_access, setup_analyzer from .utils.mock_heatmaps import create_empty_heatmaps_data from .utils.mock_memberactivities import create_empty_memberactivities_data -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.setup_platform import setup_platform def test_analyzer_three_month_period_run_once_available_analytics(): @@ -23,7 +23,7 @@ def test_analyzer_three_month_period_run_once_available_analytics(): "973993299281076286", ] - setup_db_guild(db_access, platform_id, discordId_list=acc_id, days_ago_period=90) + analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=90) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") @@ -96,7 +96,6 @@ def test_analyzer_three_month_period_run_once_available_analytics(): rawinfo_samples ) - analyzer = setup_analyzer(platform_id) analyzer.run_once() memberactivities_cursor = db_access.query_db_find( diff --git a/tests/integration/test_analyzer_period_3month_run_once_empty_analytics.py b/tests/integration/test_analyzer_period_3month_run_once_empty_analytics.py index c26cd0c..f5f285f 100644 --- a/tests/integration/test_analyzer_period_3month_run_once_empty_analytics.py +++ b/tests/integration/test_analyzer_period_3month_run_once_empty_analytics.py @@ -3,8 +3,8 @@ import numpy as np -from .utils.analyzer_setup import launch_db_access, setup_analyzer -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.analyzer_setup import launch_db_access +from .utils.setup_platform import setup_platform def test_analyzer_three_month_period_run_once_empty_analytics(): @@ -21,7 +21,7 @@ def test_analyzer_three_month_period_run_once_empty_analytics(): "973993299281076286", ] - setup_db_guild(db_access, platform_id, discordId_list=acc_id, days_ago_period=90) + analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=90) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") @@ -75,7 +75,6 @@ def test_analyzer_three_month_period_run_once_empty_analytics(): rawinfo_samples ) - analyzer = setup_analyzer(platform_id) analyzer.run_once() memberactivities_cursor = db_access.query_db_find( diff --git a/tests/integration/test_analyzer_period_6month_recompute_available_analytics.py b/tests/integration/test_analyzer_period_6month_recompute_available_analytics.py index a7c9e75..c46b7d8 100644 --- a/tests/integration/test_analyzer_period_6month_recompute_available_analytics.py +++ b/tests/integration/test_analyzer_period_6month_recompute_available_analytics.py @@ -3,10 +3,10 @@ import numpy as np -from .utils.analyzer_setup import launch_db_access, setup_analyzer +from .utils.analyzer_setup import launch_db_access from .utils.mock_heatmaps import create_empty_heatmaps_data from .utils.mock_memberactivities import create_empty_memberactivities_data -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.setup_platform import setup_platform def test_analyzer_six_month_period_recompute_available_analytics(): @@ -23,7 +23,7 @@ def test_analyzer_six_month_period_recompute_available_analytics(): "973993299281076286", ] - setup_db_guild(db_access, platform_id, discordId_list=acc_id, days_ago_period=180) + analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=180) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") @@ -96,8 +96,7 @@ def test_analyzer_six_month_period_recompute_available_analytics(): rawinfo_samples ) - analyzer = setup_analyzer(platform_id) - analyzer.recompute_analytics() + analyzer.recompute() memberactivities_cursor = db_access.query_db_find( "memberactivities", {}, sorting=("date", -1) diff --git a/tests/integration/test_analyzer_period_6month_recompute_empty_analytics.py b/tests/integration/test_analyzer_period_6month_recompute_empty_analytics.py index 2373f4c..aec9e1e 100644 --- a/tests/integration/test_analyzer_period_6month_recompute_empty_analytics.py +++ b/tests/integration/test_analyzer_period_6month_recompute_empty_analytics.py @@ -4,7 +4,7 @@ import numpy as np from .utils.analyzer_setup import launch_db_access, setup_analyzer -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.setup_platform import setup_platform def test_analyzer_six_month_period_recompute_empty_analytics(): @@ -21,7 +21,7 @@ def test_analyzer_six_month_period_recompute_empty_analytics(): "973993299281076286", ] - setup_db_guild(db_access, platform_id, discordId_list=acc_id, days_ago_period=180) + analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=180) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") @@ -75,8 +75,7 @@ def test_analyzer_six_month_period_recompute_empty_analytics(): rawinfo_samples ) - analyzer = setup_analyzer(platform_id) - analyzer.recompute_analytics() + analyzer.recompute() memberactivities_cursor = db_access.query_db_find( "memberactivities", {}, sorting=("date", -1) diff --git a/tests/integration/test_analyzer_period_6month_run_once_available_analytics.py b/tests/integration/test_analyzer_period_6month_run_once_available_analytics.py index 790fc8c..f73e7a0 100644 --- a/tests/integration/test_analyzer_period_6month_run_once_available_analytics.py +++ b/tests/integration/test_analyzer_period_6month_run_once_available_analytics.py @@ -6,7 +6,7 @@ from .utils.analyzer_setup import launch_db_access, setup_analyzer from .utils.mock_heatmaps import create_empty_heatmaps_data from .utils.mock_memberactivities import create_empty_memberactivities_data -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.setup_platform import setup_platform def test_analyzer_six_month_period_run_once_available_analytics(): @@ -23,7 +23,7 @@ def test_analyzer_six_month_period_run_once_available_analytics(): "973993299281076286", ] - setup_db_guild(db_access, platform_id, discordId_list=acc_id, days_ago_period=180) + analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=180) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") @@ -96,7 +96,6 @@ def test_analyzer_six_month_period_run_once_available_analytics(): rawinfo_samples ) - analyzer = setup_analyzer(platform_id) analyzer.run_once() memberactivities_cursor = db_access.query_db_find( diff --git a/tests/integration/test_analyzer_period_6month_run_once_empty_analytics.py b/tests/integration/test_analyzer_period_6month_run_once_empty_analytics.py index e6f2b9c..d62387a 100644 --- a/tests/integration/test_analyzer_period_6month_run_once_empty_analytics.py +++ b/tests/integration/test_analyzer_period_6month_run_once_empty_analytics.py @@ -3,8 +3,8 @@ import numpy as np -from .utils.analyzer_setup import launch_db_access, setup_analyzer -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.analyzer_setup import launch_db_access +from .utils.setup_platform import setup_platform def test_analyzer_six_month_period_run_once_empty_analytics(): @@ -21,7 +21,7 @@ def test_analyzer_six_month_period_run_once_empty_analytics(): "973993299281076286", ] - setup_db_guild(db_access, platform_id, discordId_list=acc_id, days_ago_period=180) + analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=180) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") @@ -75,7 +75,6 @@ def test_analyzer_six_month_period_run_once_empty_analytics(): rawinfo_samples ) - analyzer = setup_analyzer(platform_id) analyzer.run_once() memberactivities_cursor = db_access.query_db_find( diff --git a/tests/integration/test_analyzer_period_month_recompute_available_analytics.py b/tests/integration/test_analyzer_period_month_recompute_available_analytics.py index 35a9119..e86ee19 100644 --- a/tests/integration/test_analyzer_period_month_recompute_available_analytics.py +++ b/tests/integration/test_analyzer_period_month_recompute_available_analytics.py @@ -3,10 +3,10 @@ import numpy as np -from .utils.analyzer_setup import launch_db_access, setup_analyzer +from .utils.analyzer_setup import launch_db_access from .utils.mock_heatmaps import create_empty_heatmaps_data from .utils.mock_memberactivities import create_empty_memberactivities_data -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.setup_platform import setup_platform def test_analyzer_month_period_recompute_available_analytics(): @@ -23,7 +23,7 @@ def test_analyzer_month_period_recompute_available_analytics(): "973993299281076286", ] - setup_db_guild(db_access, platform_id, discordId_list=acc_id, days_ago_period=30) + analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=30) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") @@ -95,8 +95,7 @@ def test_analyzer_month_period_recompute_available_analytics(): rawinfo_samples ) - analyzer = setup_analyzer(platform_id) - analyzer.recompute_analytics() + analyzer.recompute() memberactivities_cursor = db_access.query_db_find( "memberactivities", {}, sorting=("date", -1) diff --git a/tests/integration/test_analyzer_period_month_recompute_empty_analytics.py b/tests/integration/test_analyzer_period_month_recompute_empty_analytics.py index 6744034..cfe13fd 100644 --- a/tests/integration/test_analyzer_period_month_recompute_empty_analytics.py +++ b/tests/integration/test_analyzer_period_month_recompute_empty_analytics.py @@ -4,7 +4,7 @@ import numpy as np from .utils.analyzer_setup import launch_db_access, setup_analyzer -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.setup_platform import setup_platform def test_analyzer_month_period_recompute_empty_analytics(): @@ -21,7 +21,7 @@ def test_analyzer_month_period_recompute_empty_analytics(): "973993299281076286", ] - setup_db_guild(db_access, platform_id, discordId_list=acc_id, days_ago_period=30) + analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=30) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") @@ -74,8 +74,7 @@ def test_analyzer_month_period_recompute_empty_analytics(): rawinfo_samples ) - analyzer = setup_analyzer(platform_id) - analyzer.recompute_analytics() + analyzer.recompute() memberactivities_cursor = db_access.query_db_find( "memberactivities", {}, sorting=("date", -1) diff --git a/tests/integration/test_analyzer_period_month_run_once_available_analytics.py b/tests/integration/test_analyzer_period_month_run_once_available_analytics.py index 2e55ab8..2baa631 100644 --- a/tests/integration/test_analyzer_period_month_run_once_available_analytics.py +++ b/tests/integration/test_analyzer_period_month_run_once_available_analytics.py @@ -3,10 +3,10 @@ import numpy as np -from .utils.analyzer_setup import launch_db_access, setup_analyzer +from .utils.analyzer_setup import launch_db_access from .utils.mock_heatmaps import create_empty_heatmaps_data from .utils.mock_memberactivities import create_empty_memberactivities_data -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.setup_platform import setup_platform def test_analyzer_month_period_run_once_available_analytics(): @@ -23,7 +23,7 @@ def test_analyzer_month_period_run_once_available_analytics(): "973993299281076286", ] - setup_db_guild(db_access, platform_id, discordId_list=acc_id, days_ago_period=30) + analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=30) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") @@ -96,7 +96,6 @@ def test_analyzer_month_period_run_once_available_analytics(): rawinfo_samples ) - analyzer = setup_analyzer(platform_id) analyzer.run_once() memberactivities_cursor = db_access.query_db_find( diff --git a/tests/integration/test_analyzer_period_month_run_once_empty_analytics.py b/tests/integration/test_analyzer_period_month_run_once_empty_analytics.py index 82e8c46..bd21234 100644 --- a/tests/integration/test_analyzer_period_month_run_once_empty_analytics.py +++ b/tests/integration/test_analyzer_period_month_run_once_empty_analytics.py @@ -3,8 +3,8 @@ import numpy as np -from .utils.analyzer_setup import launch_db_access, setup_analyzer -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.analyzer_setup import launch_db_access +from .utils.setup_platform import setup_platform def test_analyzer_month_period_run_once_empty_analytics(): @@ -21,7 +21,7 @@ def test_analyzer_month_period_run_once_empty_analytics(): "973993299281076286", ] - setup_db_guild(db_access, platform_id, discordId_list=acc_id, days_ago_period=30) + analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=30) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") @@ -74,7 +74,6 @@ def test_analyzer_month_period_run_once_empty_analytics(): rawinfo_samples ) - analyzer = setup_analyzer(platform_id) analyzer.run_once() memberactivities_cursor = db_access.query_db_find( diff --git a/tests/integration/test_analyzer_period_week_recompute_available_analytics.py b/tests/integration/test_analyzer_period_week_recompute_available_analytics.py index 196499a..0168ed0 100644 --- a/tests/integration/test_analyzer_period_week_recompute_available_analytics.py +++ b/tests/integration/test_analyzer_period_week_recompute_available_analytics.py @@ -3,10 +3,10 @@ import numpy as np -from .utils.analyzer_setup import launch_db_access, setup_analyzer +from .utils.analyzer_setup import launch_db_access from .utils.mock_heatmaps import create_empty_heatmaps_data from .utils.mock_memberactivities import create_empty_memberactivities_data -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.setup_platform import setup_platform def test_analyzer_week_period_recompute_available_analytics(): @@ -23,7 +23,7 @@ def test_analyzer_week_period_recompute_available_analytics(): "user_1", "user_2", ] - setup_db_guild(db_access, platform_id, discordId_list=acc_id, days_ago_period=8) + analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=8) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") @@ -93,8 +93,7 @@ def test_analyzer_week_period_recompute_available_analytics(): rawinfo_samples ) - analyzer = setup_analyzer(platform_id) - analyzer.recompute_analytics() + analyzer.recompute() memberactivities_cursor = db_access.query_db_find("memberactivities", {}) memberactivities_data = list(memberactivities_cursor) diff --git a/tests/integration/test_analyzer_period_week_recompute_empty_analytics.py b/tests/integration/test_analyzer_period_week_recompute_empty_analytics.py index b215999..94421b2 100644 --- a/tests/integration/test_analyzer_period_week_recompute_empty_analytics.py +++ b/tests/integration/test_analyzer_period_week_recompute_empty_analytics.py @@ -3,8 +3,8 @@ import numpy as np -from .utils.analyzer_setup import launch_db_access, setup_analyzer -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.analyzer_setup import launch_db_access +from .utils.setup_platform import setup_platform def test_analyzer_week_period_recompute_empty_analytics(): @@ -21,7 +21,7 @@ def test_analyzer_week_period_recompute_empty_analytics(): "973993299281076286", ] - setup_db_guild(db_access, platform_id, discordId_list=acc_id, days_ago_period=7) + analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=7) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") @@ -74,8 +74,7 @@ def test_analyzer_week_period_recompute_empty_analytics(): rawinfo_samples ) - analyzer = setup_analyzer(platform_id) - analyzer.recompute_analytics() + analyzer.recompute() memberactivities_cursor = db_access.db_mongo_client[platform_id][ "memberactivities" diff --git a/tests/integration/test_analyzer_period_week_run_once_available_analytics.py b/tests/integration/test_analyzer_period_week_run_once_available_analytics.py index 9e71d7f..5b7f214 100644 --- a/tests/integration/test_analyzer_period_week_run_once_available_analytics.py +++ b/tests/integration/test_analyzer_period_week_run_once_available_analytics.py @@ -3,10 +3,10 @@ import numpy as np -from .utils.analyzer_setup import launch_db_access, setup_analyzer +from .utils.analyzer_setup import launch_db_access from .utils.mock_heatmaps import create_empty_heatmaps_data from .utils.mock_memberactivities import create_empty_memberactivities_data -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.setup_platform import setup_platform def test_analyzer_week_period_run_once_available_analytics(): @@ -23,7 +23,7 @@ def test_analyzer_week_period_run_once_available_analytics(): "973993299281076285", "973993299281076286", ] - setup_db_guild(db_access, platform_id, discordId_list=acc_id, days_ago_period=8) + analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=8) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") @@ -91,7 +91,6 @@ def test_analyzer_week_period_run_once_available_analytics(): rawinfo_samples ) - analyzer = setup_analyzer(platform_id) analyzer.run_once() memberactivities_cursor = db_access.query_db_find( diff --git a/tests/integration/test_analyzer_period_week_run_once_empty_analytics.py b/tests/integration/test_analyzer_period_week_run_once_empty_analytics.py index 449fa98..c141363 100644 --- a/tests/integration/test_analyzer_period_week_run_once_empty_analytics.py +++ b/tests/integration/test_analyzer_period_week_run_once_empty_analytics.py @@ -3,8 +3,8 @@ import numpy as np -from .utils.analyzer_setup import launch_db_access, setup_analyzer -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.analyzer_setup import launch_db_access +from .utils.setup_platform import setup_platform def test_analyzer_week_period_run_once_empty_analytics(): @@ -21,7 +21,7 @@ def test_analyzer_week_period_run_once_empty_analytics(): "user_1", ] - setup_db_guild(db_access, platform_id, discordId_list=acc_id, days_ago_period=7) + analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=7) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") @@ -73,7 +73,6 @@ def test_analyzer_week_period_run_once_empty_analytics(): rawinfo_samples ) - analyzer = setup_analyzer(platform_id) analyzer.run_once() memberactivities_cursor = db_access.query_db_find( diff --git a/tests/integration/test_assess_engagement_mention.py b/tests/integration/test_assess_engagement_mention.py index 1f752eb..6c69a3a 100644 --- a/tests/integration/test_assess_engagement_mention.py +++ b/tests/integration/test_assess_engagement_mention.py @@ -5,7 +5,7 @@ from discord_analyzer.metrics.utils.analyzer_db_manager import AnalyzerDBManager from .utils.analyzer_setup import launch_db_access -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.setup_platform import setup_platform from discord_analyzer.metrics.heatmaps import Heatmaps from discord_analyzer.schemas import GraphSchema from discord_analyzer.schemas.platform_configs import DiscordAnalyzerConfig @@ -75,7 +75,7 @@ def test_single_user_mention(self): } platform_id = "515151515151515151515151" - setup_db_guild( + setup_platform( self.db_access, platform_id, discordId_list=users_id_list, diff --git a/tests/integration/test_assess_engagement_reactions.py b/tests/integration/test_assess_engagement_reactions.py index 30d7948..97af4a4 100644 --- a/tests/integration/test_assess_engagement_reactions.py +++ b/tests/integration/test_assess_engagement_reactions.py @@ -5,7 +5,7 @@ from discord_analyzer.metrics.utils.analyzer_db_manager import AnalyzerDBManager from .utils.analyzer_setup import launch_db_access -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.setup_platform import setup_platform from discord_analyzer.metrics.heatmaps import Heatmaps from discord_analyzer.schemas import GraphSchema from discord_analyzer.schemas.platform_configs import DiscordAnalyzerConfig @@ -75,7 +75,7 @@ def test_single_user_reaction(self): } platform_id = "515151515151515151515151" - setup_db_guild( + setup_platform( self.db_access, platform_id, discordId_list=users_id_list, diff --git a/tests/integration/test_assess_engagement_replies.py b/tests/integration/test_assess_engagement_replies.py index 6d05135..f752d8c 100644 --- a/tests/integration/test_assess_engagement_replies.py +++ b/tests/integration/test_assess_engagement_replies.py @@ -5,7 +5,7 @@ from discord_analyzer.metrics.utils.analyzer_db_manager import AnalyzerDBManager from .utils.analyzer_setup import launch_db_access -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.setup_platform import setup_platform from discord_analyzer.metrics.heatmaps import Heatmaps from discord_analyzer.schemas import GraphSchema from discord_analyzer.schemas.platform_configs import DiscordAnalyzerConfig @@ -73,7 +73,7 @@ def test_single_user_reply(self): "DROP_H_THR": 2, "DROP_I_THR": 1, } - setup_db_guild( + setup_platform( self.db_access, self.heatmaps.platform_id, discordId_list=users_id_list, diff --git a/tests/integration/test_exclude_bots.py b/tests/integration/test_exclude_bots.py index a8ad929..7da1969 100644 --- a/tests/integration/test_exclude_bots.py +++ b/tests/integration/test_exclude_bots.py @@ -2,8 +2,8 @@ import numpy as np -from .utils.analyzer_setup import launch_db_access, setup_analyzer -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.analyzer_setup import launch_db_access +from .utils.setup_platform import setup_platform def test_excluding_bots_heatmaps(): @@ -26,7 +26,7 @@ def test_excluding_bots_heatmaps(): # A guild connected at 35 days ago connected_days_before = 35 - setup_db_guild( + analyzer = setup_platform( db_access, platform_id, discordId_list=acc_id, @@ -87,7 +87,6 @@ def test_excluding_bots_heatmaps(): rawinfo_samples ) - analyzer = setup_analyzer(platform_id) analyzer.run_once() db_access.db_mongo_client[platform_id] diff --git a/tests/integration/test_generated_graph_period_1_year_run_once.py b/tests/integration/test_generated_graph_period_1_year_run_once.py index ad74f40..9e87207 100644 --- a/tests/integration/test_generated_graph_period_1_year_run_once.py +++ b/tests/integration/test_generated_graph_period_1_year_run_once.py @@ -3,10 +3,10 @@ import numpy as np from tc_neo4j_lib.neo4j_ops import Neo4jOps -from .utils.analyzer_setup import launch_db_access, setup_analyzer +from .utils.analyzer_setup import launch_db_access from .utils.mock_heatmaps import create_empty_heatmaps_data from .utils.mock_memberactivities import create_empty_memberactivities_data -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.setup_platform import setup_platform def test_networkgraph_one_year_period_run_once_available_analytics(): @@ -33,7 +33,7 @@ def test_networkgraph_one_year_period_run_once_available_analytics(): "973993299281076286", ] - setup_db_guild( + analyzer = setup_platform( db_access, platform_id, discordId_list=acc_id, @@ -111,7 +111,6 @@ def test_networkgraph_one_year_period_run_once_available_analytics(): rawinfo_samples ) - analyzer = setup_analyzer(platform_id) analyzer.run_once() graph_schema = analyzer.graph_schema diff --git a/tests/integration/test_generated_graph_period_1year.py b/tests/integration/test_generated_graph_period_1year.py index 8707de9..e30cbe7 100644 --- a/tests/integration/test_generated_graph_period_1year.py +++ b/tests/integration/test_generated_graph_period_1year.py @@ -3,10 +3,10 @@ import numpy as np from tc_neo4j_lib.neo4j_ops import Neo4jOps -from .utils.analyzer_setup import launch_db_access, setup_analyzer +from .utils.analyzer_setup import launch_db_access from .utils.mock_heatmaps import create_empty_heatmaps_data from .utils.mock_memberactivities import create_empty_memberactivities_data -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.setup_platform import setup_platform def test_networkgraph_one_year_period_recompute_available_analytics(): @@ -33,7 +33,7 @@ def test_networkgraph_one_year_period_recompute_available_analytics(): "973993299281076286", ] - setup_db_guild( + analyzer = setup_platform( db_access, platform_id, discordId_list=acc_id, @@ -111,8 +111,7 @@ def test_networkgraph_one_year_period_recompute_available_analytics(): rawinfo_samples ) - analyzer = setup_analyzer(platform_id) - analyzer.recompute_analytics() + analyzer.recompute() graph_schema = analyzer.graph_schema platform_label = graph_schema.platform_label diff --git a/tests/integration/test_generated_graph_period_35_days.py b/tests/integration/test_generated_graph_period_35_days.py index eec7631..dcb9648 100644 --- a/tests/integration/test_generated_graph_period_35_days.py +++ b/tests/integration/test_generated_graph_period_35_days.py @@ -6,7 +6,7 @@ from .utils.analyzer_setup import launch_db_access, setup_analyzer from .utils.mock_heatmaps import create_empty_heatmaps_data from .utils.mock_memberactivities import create_empty_memberactivities_data -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.setup_platform import setup_platform def test_networkgraph_35_days_period_recompute_available_analytics(): @@ -33,7 +33,7 @@ def test_networkgraph_35_days_period_recompute_available_analytics(): "973993299281076286", ] - setup_db_guild( + analyzer = setup_platform( db_access, platform_id, discordId_list=acc_id, @@ -111,8 +111,7 @@ def test_networkgraph_35_days_period_recompute_available_analytics(): rawinfo_samples ) - analyzer = setup_analyzer(platform_id) - analyzer.recompute_analytics() + analyzer.recompute() graph_schema = analyzer.graph_schema platform_label = graph_schema.platform_label diff --git a/tests/integration/test_generated_graph_period_35_days_run_once.py b/tests/integration/test_generated_graph_period_35_days_run_once.py index c3c328f..10f56a0 100644 --- a/tests/integration/test_generated_graph_period_35_days_run_once.py +++ b/tests/integration/test_generated_graph_period_35_days_run_once.py @@ -3,10 +3,10 @@ import numpy as np from tc_neo4j_lib.neo4j_ops import Neo4jOps -from .utils.analyzer_setup import launch_db_access, setup_analyzer +from .utils.analyzer_setup import launch_db_access from .utils.mock_heatmaps import create_empty_heatmaps_data from .utils.mock_memberactivities import create_empty_memberactivities_data -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.setup_platform import setup_platform def test_networkgraph_35_days_period_run_once_available_analytics(): @@ -33,7 +33,7 @@ def test_networkgraph_35_days_period_run_once_available_analytics(): "973993299281076286", ] - setup_db_guild( + analyzer = setup_platform( db_access, platform_id, discordId_list=acc_id, @@ -111,7 +111,6 @@ def test_networkgraph_35_days_period_run_once_available_analytics(): rawinfo_samples ) - analyzer = setup_analyzer(platform_id) analyzer.run_once() graph_schema = analyzer.graph_schema diff --git a/tests/integration/test_generated_graph_period_3_months.py b/tests/integration/test_generated_graph_period_3_months.py index e6964d5..d39b965 100644 --- a/tests/integration/test_generated_graph_period_3_months.py +++ b/tests/integration/test_generated_graph_period_3_months.py @@ -3,10 +3,10 @@ import numpy as np from tc_neo4j_lib.neo4j_ops import Neo4jOps -from .utils.analyzer_setup import launch_db_access, setup_analyzer +from .utils.analyzer_setup import launch_db_access from .utils.mock_heatmaps import create_empty_heatmaps_data from .utils.mock_memberactivities import create_empty_memberactivities_data -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.setup_platform import setup_platform def test_networkgraph_three_months_period_recompute_available_analytics(): @@ -32,7 +32,7 @@ def test_networkgraph_three_months_period_recompute_available_analytics(): "973993299281076285", "973993299281076286", ] - setup_db_guild( + analyzer = setup_platform( db_access, platform_id, discordId_list=acc_id, @@ -110,8 +110,7 @@ def test_networkgraph_three_months_period_recompute_available_analytics(): rawinfo_samples ) - analyzer = setup_analyzer(platform_id) - analyzer.recompute_analytics() + analyzer.recompute() graph_schema = analyzer.graph_schema platform_label = graph_schema.platform_label diff --git a/tests/integration/test_generated_graph_period_3_months_run_once.py b/tests/integration/test_generated_graph_period_3_months_run_once.py index 60f7806..2947722 100644 --- a/tests/integration/test_generated_graph_period_3_months_run_once.py +++ b/tests/integration/test_generated_graph_period_3_months_run_once.py @@ -3,10 +3,10 @@ import numpy as np from tc_neo4j_lib.neo4j_ops import Neo4jOps -from .utils.analyzer_setup import launch_db_access, setup_analyzer +from .utils.analyzer_setup import launch_db_access from .utils.mock_heatmaps import create_empty_heatmaps_data from .utils.mock_memberactivities import create_empty_memberactivities_data -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.setup_platform import setup_platform def test_networkgraph_three_months_period_run_once_available_analytics(): @@ -33,7 +33,7 @@ def test_networkgraph_three_months_period_run_once_available_analytics(): "973993299281076286", ] - setup_db_guild( + analyzer = setup_platform( db_access, platform_id, discordId_list=acc_id, @@ -111,7 +111,6 @@ def test_networkgraph_three_months_period_run_once_available_analytics(): rawinfo_samples ) - analyzer = setup_analyzer(platform_id) analyzer.run_once() graph_schema = analyzer.graph_schema diff --git a/tests/integration/test_generated_graph_period_6_months.py b/tests/integration/test_generated_graph_period_6_months.py index ba1ee28..91f6402 100644 --- a/tests/integration/test_generated_graph_period_6_months.py +++ b/tests/integration/test_generated_graph_period_6_months.py @@ -3,10 +3,10 @@ import numpy as np from tc_neo4j_lib.neo4j_ops import Neo4jOps -from .utils.analyzer_setup import launch_db_access, setup_analyzer +from .utils.analyzer_setup import launch_db_access from .utils.mock_heatmaps import create_empty_heatmaps_data from .utils.mock_memberactivities import create_empty_memberactivities_data -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.setup_platform import setup_platform def test_networkgraph_six_months_period_recompute_available_analytics(): @@ -33,7 +33,7 @@ def test_networkgraph_six_months_period_recompute_available_analytics(): "973993299281076286", ] - setup_db_guild( + analyzer = setup_platform( db_access, platform_id, discordId_list=acc_id, @@ -111,8 +111,7 @@ def test_networkgraph_six_months_period_recompute_available_analytics(): rawinfo_samples ) - analyzer = setup_analyzer(platform_id) - analyzer.recompute_analytics() + analyzer.recompute() graph_schema = analyzer.graph_schema platform_label = graph_schema.platform_label diff --git a/tests/integration/test_generated_graph_period_6_months_run_once.py b/tests/integration/test_generated_graph_period_6_months_run_once.py index 4ad7011..4531220 100644 --- a/tests/integration/test_generated_graph_period_6_months_run_once.py +++ b/tests/integration/test_generated_graph_period_6_months_run_once.py @@ -3,10 +3,10 @@ import numpy as np from tc_neo4j_lib.neo4j_ops import Neo4jOps -from .utils.analyzer_setup import launch_db_access, setup_analyzer +from .utils.analyzer_setup import launch_db_access from .utils.mock_heatmaps import create_empty_heatmaps_data from .utils.mock_memberactivities import create_empty_memberactivities_data -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.setup_platform import setup_platform def test_networkgraph_six_months_period_run_once_available_analytics(): @@ -34,7 +34,7 @@ def test_networkgraph_six_months_period_run_once_available_analytics(): "973993299281076286", ] - setup_db_guild( + analyzer = setup_platform( db_access, platform_id, discordId_list=acc_id, @@ -112,7 +112,6 @@ def test_networkgraph_six_months_period_run_once_available_analytics(): rawinfo_samples ) - analyzer = setup_analyzer(platform_id) analyzer.run_once() graph_schema = analyzer.graph_schema diff --git a/tests/integration/test_member_activities_action_all_active.py b/tests/integration/test_member_activities_action_all_active.py index 6862a56..ec87057 100644 --- a/tests/integration/test_member_activities_action_all_active.py +++ b/tests/integration/test_member_activities_action_all_active.py @@ -1,8 +1,8 @@ from datetime import datetime, timedelta from unittest import TestCase -from .utils.analyzer_setup import launch_db_access, setup_analyzer -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.analyzer_setup import launch_db_access +from .utils.setup_platform import setup_platform class TestMemberActivitiesActionsAllActive(TestCase): @@ -13,7 +13,7 @@ def setUp(self) -> None: def test_single_user_action(self): self.db_access.db_mongo_client[self.platform_id].drop_collection("heatmaps") users_id_list = ["user1"] - setup_db_guild( + analyzer = analyzer = setup_platform( self.db_access, self.platform_id, discordId_list=users_id_list, @@ -40,8 +40,8 @@ def test_single_user_action(self): self.db_access.db_mongo_client[self.platform_id][ "rawmemberactivities" ].insert_many(rawinfo_samples) - analyzer = setup_analyzer(self.platform_id) - analyzer.recompute_analytics() + + analyzer.recompute() cursor = self.db_access.db_mongo_client[self.platform_id][ "memberactivities" ].find({}, {"_id": 0, "all_active": 1}) @@ -55,7 +55,7 @@ def test_single_user_action(self): def test_lone_msg_action(self): users_id_list = ["user1", "user2", "user3"] - setup_db_guild( + analyzer = setup_platform( self.db_access, self.platform_id, discordId_list=users_id_list, @@ -84,8 +84,8 @@ def test_lone_msg_action(self): self.db_access.db_mongo_client[self.platform_id][ "rawmemberactivities" ].insert_many(rawinfo_samples) - analyzer = setup_analyzer(self.platform_id) - analyzer.recompute_analytics() + + analyzer.recompute() cursor = self.db_access.db_mongo_client[self.platform_id][ "memberactivities" ].find({}, {"_id": 0, "all_active": 1}) @@ -98,7 +98,7 @@ def test_lone_msg_action(self): def test_thr_message_action(self): users_id_list = ["user1", "user2", "user3", "user4"] - setup_db_guild( + analyzer = setup_platform( self.db_access, self.platform_id, discordId_list=users_id_list, @@ -127,8 +127,8 @@ def test_thr_message_action(self): self.db_access.db_mongo_client[self.platform_id][ "rawmemberactivities" ].insert_many(rawinfo_samples) - analyzer = setup_analyzer(self.platform_id) - analyzer.recompute_analytics() + + analyzer.recompute() cursor = self.db_access.db_mongo_client[self.platform_id][ "memberactivities" ].find({}, {"_id": 0, "all_active": 1, "date": 1}) diff --git a/tests/integration/test_member_activities_action_all_activities.py b/tests/integration/test_member_activities_action_all_activities.py index 8e13791..08bc936 100644 --- a/tests/integration/test_member_activities_action_all_activities.py +++ b/tests/integration/test_member_activities_action_all_activities.py @@ -1,8 +1,8 @@ from datetime import datetime, timedelta from unittest import TestCase -from .utils.analyzer_setup import launch_db_access, setup_analyzer -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.analyzer_setup import launch_db_access +from .utils.setup_platform import setup_platform class TestMemberActivitiesActionsAllActivities(TestCase): @@ -32,7 +32,7 @@ def test_single_user_action(self): } platform_id = "515151515151515151515151" - setup_db_guild( + analyzer = setup_platform( self.db_access, platform_id, discordId_list=users_id_list, @@ -62,8 +62,8 @@ def test_single_user_action(self): self.db_access.db_mongo_client[platform_id]["rawmemberactivities"].insert_many( rawinfo_samples ) - analyzer = setup_analyzer(platform_id) - analyzer.recompute_analytics() + + analyzer.recompute() cursor = self.db_access.db_mongo_client[platform_id]["memberactivities"].find( {}, { diff --git a/tests/integration/test_member_activity_from_start_no_past_data.py b/tests/integration/test_member_activity_from_start_no_past_data.py index abbf2da..17c9f2f 100644 --- a/tests/integration/test_member_activity_from_start_no_past_data.py +++ b/tests/integration/test_member_activity_from_start_no_past_data.py @@ -3,7 +3,8 @@ from bson.objectid import ObjectId -from .utils.analyzer_setup import launch_db_access, setup_analyzer +from .utils.analyzer_setup import launch_db_access +from .utils.setup_platform import setup_platform def test_analyzer_member_activities_from_start_empty_memberactivities(): @@ -19,42 +20,12 @@ def test_analyzer_member_activities_from_start_empty_memberactivities(): db_access.db_mongo_client["Core"].drop_collection("platforms") db_access.db_mongo_client.drop_database(platform_id) - action = { - "INT_THR": 1, - "UW_DEG_THR": 1, - "PAUSED_T_THR": 1, - "CON_T_THR": 4, - "CON_O_THR": 3, - "EDGE_STR_THR": 5, - "UW_THR_DEG_THR": 5, - "VITAL_T_THR": 4, - "VITAL_O_THR": 3, - "STILL_T_THR": 2, - "STILL_O_THR": 2, - "DROP_H_THR": 2, - "DROP_I_THR": 1, - } - - db_access.db_mongo_client["Core"]["platforms"].insert_one( - { - "_id": ObjectId(platform_id), - "name": "discord", - "metadata": { - "id": guildId, - "icon": "111111111111111111111111", - "name": "A guild", - "resources": ["1020707129214111827"], - "window": {"period_size": 7, "step_size": 1}, - "action": action, - "period": datetime.now() - timedelta(days=30), - }, - "community": ObjectId("aabbccddeeff001122334455"), - "disconnectedAt": None, - "connectedAt": (datetime.now() - timedelta(days=40)), - "isInProgress": True, - "createdAt": datetime(2023, 11, 1), - "updatedAt": datetime(2023, 11, 1), - } + analyzer = setup_platform( + db_access, + platform_id, + discordId_list=["3451791"], + days_ago_period=30, + community_id="aabbccddeeff001122334455", ) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") @@ -93,8 +64,7 @@ def test_analyzer_member_activities_from_start_empty_memberactivities(): rawinfo_samples ) - analyzer = setup_analyzer(platform_id) - analyzer.recompute_analytics() + analyzer.recompute() memberactivities_data = db_access.db_mongo_client[platform_id][ "memberactivities" diff --git a/tests/integration/test_member_activity_from_start_with_guild_heatmaps_available.py b/tests/integration/test_member_activity_from_start_with_guild_heatmaps_available.py index bc838c1..081f39d 100644 --- a/tests/integration/test_member_activity_from_start_with_guild_heatmaps_available.py +++ b/tests/integration/test_member_activity_from_start_with_guild_heatmaps_available.py @@ -1,10 +1,10 @@ # test analyzing memberactivities from datetime import datetime, timedelta -from .utils.analyzer_setup import launch_db_access, setup_analyzer +from .utils.analyzer_setup import launch_db_access from .utils.mock_heatmaps import create_empty_heatmaps_data from .utils.mock_memberactivities import create_empty_memberactivities_data -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.setup_platform import setup_platform def test_analyzer_member_activities_from_start_available_heatmaps(): @@ -17,7 +17,7 @@ def test_analyzer_member_activities_from_start_available_heatmaps(): platform_id = "515151515151515151515151" db_access = launch_db_access(platform_id) - setup_db_guild(db_access, platform_id, discordId_list=["user_0"]) + analyzer = setup_platform(db_access, platform_id, discordId_list=["user_0"]) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") @@ -56,8 +56,7 @@ def test_analyzer_member_activities_from_start_available_heatmaps(): rawinfo_samples ) - analyzer = setup_analyzer(platform_id) - analyzer.recompute_analytics() + analyzer.recompute() memberactivities_data = db_access.db_mongo_client[platform_id][ "memberactivities" diff --git a/tests/integration/test_member_activity_from_start_with_guild_memberactivities_available.py b/tests/integration/test_member_activity_from_start_with_guild_memberactivities_available.py index 2e9b923..0614da6 100644 --- a/tests/integration/test_member_activity_from_start_with_guild_memberactivities_available.py +++ b/tests/integration/test_member_activity_from_start_with_guild_memberactivities_available.py @@ -1,9 +1,9 @@ # test analyzing memberactivities from datetime import datetime, timedelta -from .utils.analyzer_setup import launch_db_access, setup_analyzer +from .utils.analyzer_setup import launch_db_access from .utils.mock_memberactivities import create_empty_memberactivities_data -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.setup_platform import setup_platform def test_analyzer_member_activities_from_start_available_member_activity(): @@ -16,7 +16,7 @@ def test_analyzer_member_activities_from_start_available_member_activity(): platform_id = "515151515151515151515151" db_access = launch_db_access(platform_id) - setup_db_guild(db_access, platform_id, discordId_list=["user_0"]) + analyzer = setup_platform(db_access, platform_id, discordId_list=["user_0"]) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") @@ -50,8 +50,7 @@ def test_analyzer_member_activities_from_start_available_member_activity(): rawinfo_samples ) - analyzer = setup_analyzer(platform_id) - analyzer.recompute_analytics() + analyzer.recompute() memberactivities_data = db_access.db_mongo_client[platform_id][ "memberactivities" diff --git a/tests/integration/test_member_activity_from_start_with_one_interval.py b/tests/integration/test_member_activity_from_start_with_one_interval.py index c224650..55e95a7 100644 --- a/tests/integration/test_member_activity_from_start_with_one_interval.py +++ b/tests/integration/test_member_activity_from_start_with_one_interval.py @@ -1,8 +1,8 @@ # test analyzing memberactivities from datetime import datetime, timedelta -from .utils.analyzer_setup import launch_db_access, setup_analyzer -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.analyzer_setup import launch_db_access +from .utils.setup_platform import setup_platform def test_analyzer_from_start_one_interval(): @@ -14,7 +14,7 @@ def test_analyzer_from_start_one_interval(): guildId = "1234" db_access = launch_db_access(platform_id) - setup_db_guild(db_access, platform_id, discordId_list=["user_0"]) + analyzer = setup_platform(db_access, platform_id, discordId_list=["user_0"]) rawinfo_samples = [] @@ -41,8 +41,7 @@ def test_analyzer_from_start_one_interval(): db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") - analyzer = setup_analyzer(platform_id) - analyzer.recompute_analytics() + analyzer.recompute() memberactivities_data = db_access.db_mongo_client[platform_id][ "memberactivities" diff --git a/tests/integration/test_member_activity_utils.py b/tests/integration/test_member_activity_utils.py index 43554d6..22e0bf3 100644 --- a/tests/integration/test_member_activity_utils.py +++ b/tests/integration/test_member_activity_utils.py @@ -2,17 +2,15 @@ from discord_analyzer.metrics.memberactivity_utils import MemberActivityUtils -from .utils.analyzer_setup import launch_db_access, setup_analyzer -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.analyzer_setup import launch_db_access +from .utils.setup_platform import setup_platform def test_utils_get_members(): platform_id = "515151515151515151515151" - guildId = "1012430565959553145" users = ["user_0"] db_access = launch_db_access(platform_id) - setup_db_guild(db_access, platform_id, discordId_list=users, days_ago_period=7) - analyzer = setup_analyzer(platform_id) + _ = setup_platform(db_access, platform_id, discordId_list=users, days_ago_period=7) rawinfo_samples = [] for i in range(150): diff --git a/tests/integration/test_memberactivities_mentions.py b/tests/integration/test_memberactivities_mentions.py index 8c9849c..96eceb6 100644 --- a/tests/integration/test_memberactivities_mentions.py +++ b/tests/integration/test_memberactivities_mentions.py @@ -1,8 +1,8 @@ from datetime import datetime, timedelta from unittest import TestCase -from .utils.analyzer_setup import launch_db_access, setup_analyzer -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.analyzer_setup import launch_db_access +from .utils.setup_platform import setup_platform class TestMemberActivitiesReply(TestCase): @@ -28,7 +28,7 @@ def test_single_user_interaction(self): "DROP_I_THR": 1, } - setup_db_guild( + analyzer = setup_platform( self.db_access, self.platform_id, discordId_list=users_id_list, @@ -85,8 +85,7 @@ def test_single_user_interaction(self): self.db_access.db_mongo_client[self.platform_id][ "rawmemberactivities" ].insert_many(rawinfo_samples) - analyzer = setup_analyzer(self.platform_id) - analyzer.recompute_analytics() + analyzer.recompute() cursor = self.db_access.db_mongo_client[self.platform_id][ "memberactivities" ].find( diff --git a/tests/integration/test_memberactivities_reaction.py b/tests/integration/test_memberactivities_reaction.py index 9d8e0f5..da47a47 100644 --- a/tests/integration/test_memberactivities_reaction.py +++ b/tests/integration/test_memberactivities_reaction.py @@ -1,8 +1,8 @@ from datetime import datetime, timedelta from unittest import TestCase -from .utils.analyzer_setup import launch_db_access, setup_analyzer -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.analyzer_setup import launch_db_access +from .utils.setup_platform import setup_platform class TestMemberActivitiesReactions(TestCase): @@ -31,7 +31,7 @@ def test_single_user_action(self): "DROP_I_THR": 1, } - setup_db_guild( + analyzer = setup_platform( self.db_access, self.platform_id, discordId_list=users_id_list, @@ -90,8 +90,8 @@ def test_single_user_action(self): self.db_access.db_mongo_client[self.platform_id][ "rawmemberactivities" ].insert_many(rawinfo_samples) - analyzer = setup_analyzer(self.platform_id) - analyzer.recompute_analytics() + + analyzer.recompute() cursor = self.db_access.db_mongo_client[self.platform_id][ "memberactivities" ].find( diff --git a/tests/integration/test_memberactivities_reply.py b/tests/integration/test_memberactivities_reply.py index ad94875..ff5a400 100644 --- a/tests/integration/test_memberactivities_reply.py +++ b/tests/integration/test_memberactivities_reply.py @@ -1,8 +1,8 @@ from datetime import datetime, timedelta from unittest import TestCase -from .utils.analyzer_setup import launch_db_access, setup_analyzer -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.analyzer_setup import launch_db_access +from .utils.setup_platform import setup_platform class TestMemberActivitiesReply(TestCase): @@ -28,7 +28,7 @@ def test_single_user_interaction(self): "DROP_H_THR": 2, "DROP_I_THR": 1, } - setup_db_guild( + analyzer = setup_platform( self.db_access, self.platform_id, discordId_list=users_id_list, @@ -88,8 +88,7 @@ def test_single_user_interaction(self): self.db_access.db_mongo_client[self.platform_id][ "rawmemberactivities" ].insert_many(rawinfo_samples) - analyzer = setup_analyzer(self.platform_id) - analyzer.recompute_analytics() + analyzer.recompute() cursor = self.db_access.db_mongo_client[self.platform_id][ "memberactivities" ].find( diff --git a/tests/integration/test_mentioned_active_members_from_message.py b/tests/integration/test_mentioned_active_members_from_message.py index 47a862e..046db0f 100644 --- a/tests/integration/test_mentioned_active_members_from_message.py +++ b/tests/integration/test_mentioned_active_members_from_message.py @@ -1,7 +1,7 @@ from datetime import datetime, timedelta -from .utils.analyzer_setup import launch_db_access, setup_analyzer -from .utils.remove_and_setup_guild import setup_db_guild +from .utils.analyzer_setup import launch_db_access +from .utils.setup_platform import setup_platform def test_mention_active_members_from_rawinfo(): @@ -18,7 +18,7 @@ def test_mention_active_members_from_rawinfo(): "user1", "user2", ] - setup_db_guild( + analyzer = setup_platform( db_access=db_access, platform_id=platform_id, discordId_list=acc_id, @@ -80,7 +80,6 @@ def test_mention_active_members_from_rawinfo(): rawinfo_samples ) - analyzer = setup_analyzer(platform_id) analyzer.run_once() memberactivities_cursor = db_access.query_db_find( diff --git a/tests/integration/utils/analyzer_setup.py b/tests/integration/utils/analyzer_setup.py index 914049c..3c8d7bb 100644 --- a/tests/integration/utils/analyzer_setup.py +++ b/tests/integration/utils/analyzer_setup.py @@ -1,21 +1,9 @@ import os from discord_analyzer.DB_operations.mongodb_access import DB_access -from discord_analyzer.tc_analyzer import TCAnalyzer from dotenv import load_dotenv -def setup_analyzer( - platform_id: str, -) -> TCAnalyzer: - load_dotenv() - - analyzer = TCAnalyzer(platform_id) - analyzer.database_connect() - - return analyzer - - def launch_db_access(platform_id: str): load_dotenv() db_access = DB_access(platform_id) diff --git a/tests/integration/utils/remove_and_setup_guild.py b/tests/integration/utils/setup_platform.py similarity index 84% rename from tests/integration/utils/remove_and_setup_guild.py rename to tests/integration/utils/setup_platform.py index 7470913..b7be425 100644 --- a/tests/integration/utils/remove_and_setup_guild.py +++ b/tests/integration/utils/setup_platform.py @@ -4,9 +4,10 @@ import numpy as np from bson.objectid import ObjectId from discord_analyzer.DB_operations.mongodb_access import DB_access +from discord_analyzer.tc_analyzer import TCAnalyzer -def setup_db_guild( +def setup_platform( db_access: DB_access, platform_id: str, discordId_list: list[str] = ["973993299281076285"], @@ -14,7 +15,7 @@ def setup_db_guild( dates: Optional[list[datetime]] = None, days_ago_period: int = 30, **kwargs, -): +) -> TCAnalyzer: """ Remove the guild from Core databse and then insert it there also drop the guildId database and re-create @@ -30,6 +31,14 @@ def setup_db_guild( ) db_access.db_mongo_client.drop_database(platform_id) + period = (datetime.now() - timedelta(days=days_ago_period)).replace( + hour=0, minute=0, second=0, microsecond=0 + ) + window = kwargs.get( + "window", + {"period_size": 7, "step_size": 1}, + ) + action = kwargs.get( "action", { @@ -59,11 +68,9 @@ def setup_db_guild( "icon": "111111111111111111111111", "name": "A guild", "resources": resources, - "window": {"period_size": 7, "step_size": 1}, + "window": window, "action": action, - "period": (datetime.now() - timedelta(days=days_ago_period)).replace( - hour=0, minute=0, second=0, microsecond=0 - ), + "period": period, }, "community": ObjectId(community_id), "disconnectedAt": None, @@ -74,6 +81,14 @@ def setup_db_guild( } ) + analyzer = TCAnalyzer( + platform_id, + resources=resources, + period=period, + action=action, + window=window, + ) + if dates is None: dates_using = np.repeat( datetime.now() - timedelta(days=10), len(discordId_list) @@ -101,3 +116,6 @@ def setup_db_guild( "options": {}, } ) + + + return analyzer \ No newline at end of file diff --git a/worker.py b/worker.py deleted file mode 100644 index d756fd7..0000000 --- a/worker.py +++ /dev/null @@ -1,28 +0,0 @@ -import logging - -from rq import Worker -from utils.redis import RedisSingleton - - -def worker_exception_handler(job, exc_type, exc_value, traceback): - logging.error(" ========= RQ Exception =========") - logging.error(f"JOB: {job}") - logging.error(f"exc_type: {exc_type}") - logging.error(f"exc_value: {exc_value}") - logging.error(f"traceback: {traceback}") - - -if __name__ == "__main__": - logging.basicConfig() - logging.getLogger().setLevel(logging.INFO) - - r = RedisSingleton.get_instance().get_client() - worker = Worker( - queues=["default"], connection=r, exception_handlers=worker_exception_handler - ) - logging.info("Registered the worker!") - try: - worker.work(with_scheduler=True, max_jobs=1) - except KeyboardInterrupt: - worker.clean_registries() - worker.stop_scheduler() From a98e658ae1cc95ebd3e64d5a00ca62ae33d5257a Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Mon, 1 Jul 2024 16:51:22 +0330 Subject: [PATCH 02/23] fix: removed unused files! --- server.py | 74 --------------- tests/integration/test_analyzer_init.py | 109 ---------------------- tests/integration/utils/analyzer_setup.py | 2 - utils/sentryio_service.py | 14 --- 4 files changed, 199 deletions(-) delete mode 100644 server.py delete mode 100644 tests/integration/test_analyzer_init.py delete mode 100644 utils/sentryio_service.py diff --git a/server.py b/server.py deleted file mode 100644 index 830e01f..0000000 --- a/server.py +++ /dev/null @@ -1,74 +0,0 @@ -""" -start the project using rabbitMQ -""" - -import functools -import logging -from typing import Any - -import backoff -from discord_utils import analyzer_recompute, analyzer_run_once, publish_on_success -from pika.exceptions import AMQPConnectionError, ConnectionClosedByBroker -from rq import Queue as RQ_Queue -from tc_messageBroker.rabbit_mq.event import Event -from tc_messageBroker.rabbit_mq.queue import Queue -from utils.rabbitmq import RabbitMQSingleton -from utils.redis import RedisSingleton -from utils.sentryio_service import set_up_sentryio - - -@backoff.on_exception( - wait_gen=backoff.expo, - exception=(ConnectionClosedByBroker, ConnectionError, AMQPConnectionError), - # waiting for 3 hours - max_time=60 * 60 * 3, -) -def analyzer(): - # sentryio service - set_up_sentryio() - rabbit_mq = RabbitMQSingleton.get_instance().get_client() - redis = RedisSingleton.get_instance().get_client() - - # 24 hours equal to 86400 seconds - rq_queue = RQ_Queue(connection=redis, default_timeout=86400) - - analyzer_recompute = functools.partial(recompute_wrapper, redis_queue=rq_queue) - analyzer_run_once = functools.partial(run_once_wrapper, redis_queue=rq_queue) - - rabbit_mq.connect(Queue.DISCORD_ANALYZER, heartbeat=60) - - rabbit_mq.on_event(Event.DISCORD_ANALYZER.RUN, analyzer_recompute) - rabbit_mq.on_event(Event.DISCORD_ANALYZER.RUN_ONCE, analyzer_run_once) - - if rabbit_mq.channel is None: - raise ConnectionError("Couldn't connect to rmq server!") - else: - logging.info("Started Consuming!") - rabbit_mq.channel.start_consuming() - - -def recompute_wrapper(body: dict[str, Any], redis_queue: RQ_Queue): - sagaId = body["content"]["uuid"] - logging.info(f"SAGAID:{sagaId} recompute job Adding to queue") - - redis_queue.enqueue( - analyzer_recompute, - sagaId=sagaId, - on_success=publish_on_success, - ) - - -def run_once_wrapper(body: dict[str, Any], redis_queue: RQ_Queue): - sagaId = body["content"]["uuid"] - logging.info(f"SAGAID:{sagaId} run_once job Adding to queue") - redis_queue.enqueue( - analyzer_run_once, - sagaId=sagaId, - on_success=publish_on_success, - ) - - -if __name__ == "__main__": - logging.basicConfig() - logging.getLogger().setLevel(logging.INFO) - analyzer() diff --git a/tests/integration/test_analyzer_init.py b/tests/integration/test_analyzer_init.py deleted file mode 100644 index 0007f14..0000000 --- a/tests/integration/test_analyzer_init.py +++ /dev/null @@ -1,109 +0,0 @@ -from datetime import datetime, timedelta - -import pytest -from bson.objectid import ObjectId -from utils.mongo import MongoSingleton - - -@pytest.mark.skip("To be removed! " "Analyzer will be a library.") -def test_analyzer_init(): - from analyzer_init import AnalyzerInit - - platform_id = "515151515151515151515151" - days_ago_period = 30 - community_id = "aabbccddeeff001122334455" - guildId = "1234" - - mongo_client = MongoSingleton.get_instance().get_client() - mongo_client["Core"]["platforms"].delete_one({"metadata.id": guildId}) - mongo_client.drop_database(guildId) - - act_param = { - "INT_THR": 1, - "UW_DEG_THR": 1, - "PAUSED_T_THR": 1, - "CON_T_THR": 4, - "CON_O_THR": 3, - "EDGE_STR_THR": 5, - "UW_THR_DEG_THR": 5, - "VITAL_T_THR": 4, - "VITAL_O_THR": 3, - "STILL_T_THR": 2, - "STILL_O_THR": 2, - "DROP_H_THR": 2, - "DROP_I_THR": 1, - } - window = { - "period_size": 7, - "step_size": 1, - } - - mongo_client["Core"]["platforms"].insert_one( - { - "_id": ObjectId(platform_id), - "name": "discord", - "metadata": { - "id": guildId, - "icon": "111111111111111111111111", - "name": "A guild", - "resources": ["1020707129214111827"], - "window": window, - "action": act_param, - "period": datetime.now() - timedelta(days=days_ago_period), - }, - "community": ObjectId(community_id), - "disconnectedAt": None, - "connectedAt": (datetime.now() - timedelta(days=days_ago_period + 10)), - "isInProgress": True, - "createdAt": datetime(2023, 11, 1), - "updatedAt": datetime(2023, 11, 1), - } - ) - - analyzer = AnalyzerInit(guildId) - - mongo_client[guildId]["rawmembers"].insert_one( - { - "id": "user1", - "joined_At": datetime.now() - timedelta(days=5), - "left_at": None, - "is_bot": False, - } - ) - mongo_client[guildId].create_collection("heatmaps") - mongo_client[guildId].create_collection("memberactivities") - - # generating random rawinfo data - # 24 hours - # 90 days - rawinfo_samples = [] - for i in range(24 * days_ago_period): - sample = { - "type": 19, - "author": "user1", - "content": f"test{i}", - "user_mentions": [], - "role_mentions": [], - "reactions": [], - "replied_user": "user2", - "createdDate": (datetime.now() - timedelta(hours=i)), - "messageId": f"11188143219343360{i}", - "channelId": "1020707129214111827", - "channelName": "general", - "threadId": None, - "threadName": None, - "isGeneratedByWebhook": False, - } - rawinfo_samples.append(sample) - - mongo_client[guildId]["rawmemberactivities"].insert_many(rawinfo_samples) - - tc_discord_analyzer = analyzer.get_analyzer() - - tc_discord_analyzer.recompute() - - heatmaps_data = mongo_client[guildId]["heatmaps"].find_one({}) - assert heatmaps_data is not None - - memberactivities_data = mongo_client[guildId]["memberactivities"].find_one({}) - assert memberactivities_data is not None diff --git a/tests/integration/utils/analyzer_setup.py b/tests/integration/utils/analyzer_setup.py index 3c8d7bb..b1bb25f 100644 --- a/tests/integration/utils/analyzer_setup.py +++ b/tests/integration/utils/analyzer_setup.py @@ -1,5 +1,3 @@ -import os - from discord_analyzer.DB_operations.mongodb_access import DB_access from dotenv import load_dotenv diff --git a/utils/sentryio_service.py b/utils/sentryio_service.py deleted file mode 100644 index bf4da9e..0000000 --- a/utils/sentryio_service.py +++ /dev/null @@ -1,14 +0,0 @@ -import sentry_sdk -from utils.credentials import get_sentryio_service_creds - - -def set_up_sentryio(sample_rate=1.0): - sentry_creds = get_sentryio_service_creds() - sentry_sdk.init( - dsn=sentry_creds["dsn"], - environment=sentry_creds["env"], - # Set traces_sample_rate to 1.0 to capture 100% - # of transactions for performance monitoring. - # We recommend adjusting this value in production. - traces_sample_rate=sample_rate, - ) From 58b4416836f3928716540f7f7cd5a657f9a3bad7 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Mon, 1 Jul 2024 17:17:35 +0330 Subject: [PATCH 03/23] fix: removing unused functions! --- discord_utils.py | 122 +++++++++++++---------------------------------- 1 file changed, 34 insertions(+), 88 deletions(-) diff --git a/discord_utils.py b/discord_utils.py index 69e0ca1..88b1f2f 100644 --- a/discord_utils.py +++ b/discord_utils.py @@ -1,67 +1,10 @@ import logging -from analyzer_init import AnalyzerInit from automation.automation_workflow import AutomationWorkflow from tc_messageBroker.rabbit_mq.saga.saga_base import get_saga from utils.credentials import get_mongo_credentials from utils.get_guild_utils import get_platform_guild_id, get_platform_name from utils.rabbitmq import RabbitMQSingleton -from utils.transactions_ordering import sort_transactions - - -def analyzer_recompute(sagaId: str): - saga = get_saga_instance(sagaId=sagaId) - if saga is None: - logging.warn( - f"Warn: Saga not found!, stopping the recompute for sagaId: {sagaId}" - ) - else: - platform_id = saga.data["platformId"] - guildId = get_platform_guild_id(platform_id) - - logging.info("Initializing the analyzer") - analyzer_init = AnalyzerInit(guildId) - analyzer = analyzer_init.get_analyzer() - logging.info("Analyzer initialized") - - def recompute_wrapper(**kwargs): - logging.info("recompute wrapper") - analyzer.recompute() - - def publish_wrapper(**kwargs): - pass - - logging.info("Calling the saga.next()") - saga.next( - publish_method=publish_wrapper, - call_function=recompute_wrapper, - ) - - return sagaId - - -def analyzer_run_once(sagaId: str): - saga = get_saga_instance(sagaId=sagaId) - if saga is None: - logging.warn(f"Saga not found!, stopping the run_once for sagaId: {sagaId}") - else: - platform_id = saga.data["platformId"] - guildId = get_platform_guild_id(platform_id) - - analyzer_init = AnalyzerInit(guildId) - analyzer = analyzer_init.get_analyzer() - - def run_once_wrapper(**kwargs): - analyzer.run_once() - - def publish_wrapper(**kwargs): - pass - - saga.next( - publish_method=publish_wrapper, - call_function=run_once_wrapper, - ) - return sagaId def get_saga_instance(sagaId: str): @@ -79,39 +22,42 @@ def get_saga_instance(sagaId: str): return saga -def publish_on_success(connection, result, *args, **kwargs): - try: - sagaId = args[0] - logging.info(f"SAGAID: {sagaId}: ON_SUCCESS callback!") - - saga = get_saga_instance(sagaId=sagaId) - rabbitmq = RabbitMQSingleton.get_instance().get_client() - - transactions = saga.choreography.transactions - - (transactions_ordered, tx_not_started_count) = sort_transactions(transactions) +def publish_on_success(platform_id: str): + """ + publish a message to discord platform for a specific platform + telling the Community Manager the work is finished - platform_id = saga.data["platformId"] + Note: this shuold always send message in case of recompute equal to `True` - msg = f"PLATFORMID: {platform_id}: " - if tx_not_started_count != 0: - tx = transactions_ordered[0] + Parameters + ------------ + platform_id : str + the discord platform to send message to + """ - logging.info(f"{msg}Publishing for {tx.queue}") + msg = f"PLATFORMID: {platform_id}: " + logging.info(f"{msg}publishing task done to CM") - rabbitmq.connect(tx.queue) - rabbitmq.publish( - queue_name=tx.queue, - event=tx.event, - content={"uuid": sagaId, "data": saga.data}, - ) - - guildId = get_platform_guild_id(platform_id) - platform_name = get_platform_name(platform_id) - # working specifically for discord - if platform_name == "discord": - automation_workflow = AutomationWorkflow() - automation_workflow.start(guild_id=guildId, platform_id=platform_id) + guildId = get_platform_guild_id(platform_id) + platform_name = get_platform_name(platform_id) + # working specifically for discord + if platform_name == "discord": + rabbitmq = RabbitMQSingleton.get_instance().get_client() + automation_workflow = AutomationWorkflow() - except Exception as exp: - logging.info(f"Exception occured in job on_success callback: {exp}") + message = ( + "Your data import into TogetherCrew is complete! " + "See your insights on your dashboard https://app.togethercrew.com/." + " If you have questions send a DM to katerinabc (Discord) or k_bc0 (Telegram)." + ) + data = { + "platformId": platform_id, + "created": False, + "discordId": "user_id", # TODO: get the CM id + "message": message, # the message to send + "userFallback": True, + } + + automation_workflow._create_manual_saga() + + automation_workflow.start(guild_id=guildId, platform_id=platform_id) From 9717d8b537a14fff217f030bf9bf98fc6efadcf1 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Mon, 1 Jul 2024 17:25:02 +0330 Subject: [PATCH 04/23] fix: remove wrong imports! the function setup_analyzer was deleted and no longer needed. --- .../test_analyzer_period_1year_recompute_empty_analytics.py | 2 +- .../test_analyzer_period_1year_run_once_empty_analytics.py | 2 +- .../test_analyzer_period_3month_recompute_empty_analytics.py | 2 +- .../test_analyzer_period_3month_run_once_available_analytics.py | 2 +- .../test_analyzer_period_6month_recompute_empty_analytics.py | 2 +- .../test_analyzer_period_6month_run_once_available_analytics.py | 2 +- .../test_analyzer_period_month_recompute_empty_analytics.py | 2 +- tests/integration/test_generated_graph_period_35_days.py | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/integration/test_analyzer_period_1year_recompute_empty_analytics.py b/tests/integration/test_analyzer_period_1year_recompute_empty_analytics.py index 1403899..396ada1 100644 --- a/tests/integration/test_analyzer_period_1year_recompute_empty_analytics.py +++ b/tests/integration/test_analyzer_period_1year_recompute_empty_analytics.py @@ -3,7 +3,7 @@ import numpy as np -from .utils.analyzer_setup import launch_db_access, setup_analyzer +from .utils.analyzer_setup import launch_db_access from .utils.setup_platform import setup_platform diff --git a/tests/integration/test_analyzer_period_1year_run_once_empty_analytics.py b/tests/integration/test_analyzer_period_1year_run_once_empty_analytics.py index c8d8ef9..0341d09 100644 --- a/tests/integration/test_analyzer_period_1year_run_once_empty_analytics.py +++ b/tests/integration/test_analyzer_period_1year_run_once_empty_analytics.py @@ -3,7 +3,7 @@ import numpy as np -from .utils.analyzer_setup import launch_db_access, setup_analyzer +from .utils.analyzer_setup import launch_db_access from .utils.setup_platform import setup_platform diff --git a/tests/integration/test_analyzer_period_3month_recompute_empty_analytics.py b/tests/integration/test_analyzer_period_3month_recompute_empty_analytics.py index 520a7ff..33a5d31 100644 --- a/tests/integration/test_analyzer_period_3month_recompute_empty_analytics.py +++ b/tests/integration/test_analyzer_period_3month_recompute_empty_analytics.py @@ -3,7 +3,7 @@ import numpy as np -from .utils.analyzer_setup import launch_db_access, setup_analyzer +from .utils.analyzer_setup import launch_db_access from .utils.setup_platform import setup_platform diff --git a/tests/integration/test_analyzer_period_3month_run_once_available_analytics.py b/tests/integration/test_analyzer_period_3month_run_once_available_analytics.py index 7909168..89acd68 100644 --- a/tests/integration/test_analyzer_period_3month_run_once_available_analytics.py +++ b/tests/integration/test_analyzer_period_3month_run_once_available_analytics.py @@ -3,7 +3,7 @@ import numpy as np -from .utils.analyzer_setup import launch_db_access, setup_analyzer +from .utils.analyzer_setup import launch_db_access from .utils.mock_heatmaps import create_empty_heatmaps_data from .utils.mock_memberactivities import create_empty_memberactivities_data from .utils.setup_platform import setup_platform diff --git a/tests/integration/test_analyzer_period_6month_recompute_empty_analytics.py b/tests/integration/test_analyzer_period_6month_recompute_empty_analytics.py index aec9e1e..70d3025 100644 --- a/tests/integration/test_analyzer_period_6month_recompute_empty_analytics.py +++ b/tests/integration/test_analyzer_period_6month_recompute_empty_analytics.py @@ -3,7 +3,7 @@ import numpy as np -from .utils.analyzer_setup import launch_db_access, setup_analyzer +from .utils.analyzer_setup import launch_db_access from .utils.setup_platform import setup_platform diff --git a/tests/integration/test_analyzer_period_6month_run_once_available_analytics.py b/tests/integration/test_analyzer_period_6month_run_once_available_analytics.py index f73e7a0..3b77713 100644 --- a/tests/integration/test_analyzer_period_6month_run_once_available_analytics.py +++ b/tests/integration/test_analyzer_period_6month_run_once_available_analytics.py @@ -3,7 +3,7 @@ import numpy as np -from .utils.analyzer_setup import launch_db_access, setup_analyzer +from .utils.analyzer_setup import launch_db_access from .utils.mock_heatmaps import create_empty_heatmaps_data from .utils.mock_memberactivities import create_empty_memberactivities_data from .utils.setup_platform import setup_platform diff --git a/tests/integration/test_analyzer_period_month_recompute_empty_analytics.py b/tests/integration/test_analyzer_period_month_recompute_empty_analytics.py index cfe13fd..f91df20 100644 --- a/tests/integration/test_analyzer_period_month_recompute_empty_analytics.py +++ b/tests/integration/test_analyzer_period_month_recompute_empty_analytics.py @@ -3,7 +3,7 @@ import numpy as np -from .utils.analyzer_setup import launch_db_access, setup_analyzer +from .utils.analyzer_setup import launch_db_access from .utils.setup_platform import setup_platform diff --git a/tests/integration/test_generated_graph_period_35_days.py b/tests/integration/test_generated_graph_period_35_days.py index dcb9648..3e1722b 100644 --- a/tests/integration/test_generated_graph_period_35_days.py +++ b/tests/integration/test_generated_graph_period_35_days.py @@ -3,7 +3,7 @@ import numpy as np from tc_neo4j_lib.neo4j_ops import Neo4jOps -from .utils.analyzer_setup import launch_db_access, setup_analyzer +from .utils.analyzer_setup import launch_db_access from .utils.mock_heatmaps import create_empty_heatmaps_data from .utils.mock_memberactivities import create_empty_memberactivities_data from .utils.setup_platform import setup_platform From d40441b4f57be9f2a3b538a107edd0a43ab91fcc Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Tue, 2 Jul 2024 10:27:31 +0330 Subject: [PATCH 05/23] feat: update publish on success to handle different cases! --- discord_utils.py | 40 +- ...est_publish_on_success_recompute_false.py} | 5 +- .../test_publish_on_success_recompute_true.py | 341 ++++++++++++++++++ 3 files changed, 374 insertions(+), 12 deletions(-) rename tests/integration/{test_publish_on_success.py => test_publish_on_success_recompute_false.py} (98%) create mode 100644 tests/integration/test_publish_on_success_recompute_true.py diff --git a/discord_utils.py b/discord_utils.py index 88b1f2f..2f3969a 100644 --- a/discord_utils.py +++ b/discord_utils.py @@ -5,6 +5,8 @@ from utils.credentials import get_mongo_credentials from utils.get_guild_utils import get_platform_guild_id, get_platform_name from utils.rabbitmq import RabbitMQSingleton +from tc_messageBroker.rabbit_mq.event import Event +from tc_messageBroker.rabbit_mq.queue import Queue def get_saga_instance(sagaId: str): @@ -22,28 +24,33 @@ def get_saga_instance(sagaId: str): return saga -def publish_on_success(platform_id: str): +def publish_on_success(platform_id: str, recompute: bool) -> None: """ publish a message to discord platform for a specific platform - telling the Community Manager the work is finished + telling the Community Manager (CM) the work is finished - Note: this shuold always send message in case of recompute equal to `True` + Note: this will work just for discord platform! Parameters ------------ platform_id : str the discord platform to send message to + recompute : bool + if recompute equal to `True` then publish the job finished message for CM + else, just run the automation """ msg = f"PLATFORMID: {platform_id}: " logging.info(f"{msg}publishing task done to CM") - guildId = get_platform_guild_id(platform_id) + guild_id = get_platform_guild_id(platform_id) platform_name = get_platform_name(platform_id) + + automation_workflow = AutomationWorkflow() # working specifically for discord - if platform_name == "discord": + if platform_name == "discord" and recompute: + logging.info(f"{msg}Sending job finished message & starting automation!") rabbitmq = RabbitMQSingleton.get_instance().get_client() - automation_workflow = AutomationWorkflow() message = ( "Your data import into TogetherCrew is complete! " @@ -58,6 +65,21 @@ def publish_on_success(platform_id: str): "userFallback": True, } - automation_workflow._create_manual_saga() - - automation_workflow.start(guild_id=guildId, platform_id=platform_id) + # creating the discord notify saga + saga_id = automation_workflow._create_manual_saga(data=data) + + rabbitmq.publish( + Queue.DISCORD_BOT, + event=Event.DISCORD_BOT.SEND_MESSAGE, + content={"uuid": saga_id}, + ) + automation_workflow.start(platform_id, guild_id) + + elif recompute is False: + logging.info(f"{msg}Just running the automation!") + automation_workflow.start(platform_id, guild_id) + else: + logging.info( + f"{msg}platform was not discord! given platform: {platform_name}" + "No automation or job finished message will be fired" + ) diff --git a/tests/integration/test_publish_on_success.py b/tests/integration/test_publish_on_success_recompute_false.py similarity index 98% rename from tests/integration/test_publish_on_success.py rename to tests/integration/test_publish_on_success_recompute_false.py index 20e4cc0..12aa8ef 100644 --- a/tests/integration/test_publish_on_success.py +++ b/tests/integration/test_publish_on_success_recompute_false.py @@ -14,7 +14,7 @@ from .utils.analyzer_setup import launch_db_access -def test_publish_on_success_check_notification_choreographies(): +def test_publish_on_success_recompute_false_check_notification_choreographies(): """ test the publish on success functions we want to check the database if the notify choreographies are created @@ -299,8 +299,7 @@ def test_publish_on_success_check_notification_choreographies(): ] ) - sample_args_data = saga_id - publish_on_success(None, None, sample_args_data) + publish_on_success(platform_id, recompute=False) notification_count = db_access.db_mongo_client["Saga"]["sagas"].count_documents( {"choreography.name": "DISCORD_NOTIFY_USERS"} diff --git a/tests/integration/test_publish_on_success_recompute_true.py b/tests/integration/test_publish_on_success_recompute_true.py new file mode 100644 index 0000000..002cd3b --- /dev/null +++ b/tests/integration/test_publish_on_success_recompute_true.py @@ -0,0 +1,341 @@ +import os +from datetime import datetime, timedelta + +from automation.utils.interfaces import ( + Automation, + AutomationAction, + AutomationReport, + AutomationTrigger, +) +from bson.objectid import ObjectId +from discord_utils import publish_on_success +from dotenv import load_dotenv + +from .utils.analyzer_setup import launch_db_access + + +def test_publish_on_success_recompute_true_check_notification_choreographies(): + """ + test the publish on success functions + we want to check the database if the notify choreographies are created + """ + load_dotenv() + platform_id = "515151515151515151515151" + guild_id = "1234" + saga_id = "000000011111113333377777ie0w" + expected_owner_id = "334461287892" + db_access = launch_db_access(guild_id) + at_db = os.getenv("AUTOMATION_DB_NAME") + at_collection = os.getenv("AUTOMATION_DB_COLLECTION") + + db_access.db_mongo_client["Core"]["platforms"].delete_one( + {"_id": ObjectId(platform_id)} + ) + + db_access.db_mongo_client.drop_database(platform_id) + db_access.db_mongo_client.drop_database(guild_id) + db_access.db_mongo_client["Saga"].drop_collection("sagas") + db_access.db_mongo_client[at_db].drop_collection(at_collection) + + act_param = { + "INT_THR": 1, + "UW_DEG_THR": 1, + "PAUSED_T_THR": 1, + "CON_T_THR": 4, + "CON_O_THR": 3, + "EDGE_STR_THR": 5, + "UW_THR_DEG_THR": 5, + "VITAL_T_THR": 4, + "VITAL_O_THR": 3, + "STILL_T_THR": 2, + "STILL_O_THR": 2, + "DROP_H_THR": 2, + "DROP_I_THR": 1, + } + window = { + "period_size": 7, + "step_size": 1, + } + + db_access.db_mongo_client["Core"]["platforms"].insert_one( + { + "_id": ObjectId(platform_id), + "name": "discord", + "metadata": { + "id": guild_id, + "icon": "111111111111111111111111", + "name": "A guild", + "resources": ["4455178"], + "window": window, + "action": act_param, + "period": datetime.now() - timedelta(days=10), + }, + "community": ObjectId("aabbccddeeff001122334455"), + "disconnectedAt": None, + "connectedAt": (datetime.now() - timedelta(days=10)), + "isInProgress": True, + "createdAt": datetime(2023, 11, 1), + "updatedAt": datetime(2023, 11, 1), + } + ) + + db_access.db_mongo_client["Saga"]["sagas"].insert_one( + { + "choreography": { + "name": "DISCORD_UPDATE_CHANNELS", + "transactions": [ + { + "queue": "DISCORD_BOT", + "event": "FETCH", + "order": 1, + "status": "SUCCESS", + "start": datetime.now(), + "end": datetime.now(), + "runtime": 1, + }, + { + "queue": "DISCORD_ANALYZER", + "event": "RUN", + "order": 2, + "status": "SUCCESS", + "start": datetime.now(), + "end": datetime.now(), + "runtime": 1, + }, + ], + }, + "status": "IN_PROGRESS", + "data": { + "platformId": platform_id, + "created": False, + "discordId": expected_owner_id, + "message": "data is ready", + "useFallback": True, + }, + "sagaId": saga_id, + "createdAt": datetime.now(), + "updatedAt": datetime.now(), + } + ) + + db_access.db_mongo_client[guild_id]["guildmembers"].insert_many( + [ + { + "discordId": "1111", + "username": "user1", + "roles": [], + "joinedAt": datetime.now() - timedelta(days=10), + "avatar": None, + "isBot": False, + "discriminator": "0", + "permissions": "6677", + "deletedAt": None, + "globalName": "User1GlobalName", + "nickname": "User1NickName", # this will be used for the message + }, + { + "discordId": "1112", + "username": "user2", + "roles": [], + "joinedAt": datetime.now() - timedelta(days=10), + "avatar": None, + "isBot": False, + "discriminator": "0", + "permissions": "6677", + "deletedAt": None, + "globalName": "User2GlobalName", # this will be used for the message + "nickname": None, + }, + { + "discordId": "1113", + "username": "user3", # this will be used for the message + "roles": [], + "joinedAt": datetime.now() - timedelta(days=10), + "avatar": None, + "isBot": False, + "discriminator": "0", + "permissions": "6677", + "deletedAt": None, + "globalName": None, + "nickname": None, + }, + { + "discordId": "1116", + "username": "user6", + "roles": [], + "joinedAt": datetime.now() - timedelta(days=10), + "avatar": None, + "isBot": False, + "discriminator": "0", + "permissions": "6677", + "deletedAt": None, + "globalName": "User6GlobalName", + "nickname": "User6NickName", + }, + { + "discordId": "1119", + "username": "user9", + "roles": [], + "joinedAt": datetime.now() - timedelta(days=10), + "avatar": None, + "isBot": False, + "discriminator": "0", + "permissions": "6677", + "deletedAt": None, + "globalName": "User9GlobalName", + "nickname": None, + }, + { + "discordId": "999", + "username": "community_manager", + "roles": [], + "joinedAt": datetime.now() - timedelta(days=10), + "avatar": None, + "isBot": False, + "discriminator": "0", + "permissions": "6677", + "deletedAt": None, + "globalName": "User9GlobalName", + "nickname": None, + }, + ] + ) + + triggers = [ + AutomationTrigger(options={"category": "all_new_disengaged"}, enabled=True), + AutomationTrigger(options={"category": "all_new_active"}, enabled=False), + ] + actions = [ + AutomationAction( + template="hey {{ngu}}! please get back to us!", + options={}, + enabled=True, + ), + AutomationAction( + template="hey {{ngu}}! please get back to us2!", + options={}, + enabled=False, + ), + ] + + report = AutomationReport( + recipientIds=["999"], + template="hey body! This users were messaged:\n{{#each usernames}}{{this}}{{/each}}", + options={}, + enabled=True, + ) + today_time = datetime.now() + + automation = Automation( + guild_id, + triggers, + actions, + report, + enabled=True, + createdAt=today_time, + updatedAt=today_time, + ) + + db_access.db_mongo_client[at_db][at_collection].insert_one(automation.to_dict()) + + date_yesterday = ( + (datetime.now() - timedelta(days=1)) + .replace(hour=0, minute=0, second=0, microsecond=0) + ) + + date_two_past_days = ( + (datetime.now() - timedelta(days=2)) + .replace(hour=0, minute=0, second=0, microsecond=0) + ) + + db_access.db_mongo_client[platform_id]["memberactivities"].insert_many( + [ + { + "date": date_yesterday, + "all_joined": [], + "all_joined_day": [], + "all_consistent": [], + "all_vital": [], + "all_active": [], + "all_connected": [], + "all_paused": [], + "all_new_disengaged": ["1111", "1112", "1113"], + "all_disengaged": [], + "all_unpaused": [], + "all_returned": [], + "all_new_active": [], + "all_still_active": [], + "all_dropped": [], + "all_disengaged_were_newly_active": [], + "all_disengaged_were_consistently_active": [], + "all_disengaged_were_vital": [], + "all_lurker": [], + "all_about_to_disengage": [], + "all_disengaged_in_past": [], + }, + { + "date": date_two_past_days, + "all_joined": [], + "all_joined_day": [], + "all_consistent": [], + "all_vital": [], + "all_active": [], + "all_connected": [], + "all_paused": [], + "all_new_disengaged": ["1116", "1119"], + "all_disengaged": [], + "all_unpaused": [], + "all_returned": [], + "all_new_active": [], + "all_still_active": [], + "all_dropped": [], + "all_disengaged_were_newly_active": [], + "all_disengaged_were_consistently_active": [], + "all_disengaged_were_vital": [], + "all_lurker": [], + "all_about_to_disengage": [], + "all_disengaged_in_past": [], + }, + ] + ) + + publish_on_success(platform_id, recompute=True) + + notification_count = db_access.db_mongo_client["Saga"]["sagas"].count_documents( + {"choreography.name": "DISCORD_NOTIFY_USERS"} + ) + + assert notification_count == 5 + + user1_doc = db_access.db_mongo_client["Saga"]["sagas"].find_one( + {"data.discordId": "1111"} + ) + assert user1_doc["data"]["message"] == ("hey User1NickName! please get back to us!") + + user2_doc = db_access.db_mongo_client["Saga"]["sagas"].find_one( + {"data.discordId": "1112"} + ) + assert user2_doc["data"]["message"] == ( + "hey User2GlobalName! please get back to us!" + ) + + user3_doc = db_access.db_mongo_client["Saga"]["sagas"].find_one( + {"data.discordId": "1113"} + ) + assert user3_doc["data"]["message"] == ("hey user3! please get back to us!") + + user_cm_doc = db_access.db_mongo_client["Saga"]["sagas"].find_one( + {"data.discordId": "999"} + ) + expected_msg = "hey body! This users were messaged:\n" + expected_msg += "- User1NickName\n- User2GlobalName\n- user3\n" + assert user_cm_doc["data"]["message"] == expected_msg + + job_finished_saga = db_access.db_mongo_client["Saga"]["sagas"].find_one( + {"data.discordId": "user_id"} + ) + assert job_finished_saga["data"]["message"] == ( + "Your data import into TogetherCrew is complete! " + "See your insights on your dashboard https://app.togethercrew.com/." + " If you have questions send a DM to katerinabc (Discord) or k_bc0 (Telegram)." + ) From 43cf727364e020e5287f167108ea1417a09ab969 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Tue, 2 Jul 2024 14:19:31 +0330 Subject: [PATCH 06/23] feat: getting the owner discord id for finish job discord message! --- discord_utils.py | 5 +- tests/integration/test_get_guild_owner.py | 218 ++++++++++++++++++ .../test_publish_on_success_recompute_true.py | 24 +- utils/get_guild_utils.py | 41 ++++ 4 files changed, 280 insertions(+), 8 deletions(-) create mode 100644 tests/integration/test_get_guild_owner.py diff --git a/discord_utils.py b/discord_utils.py index 2f3969a..5dee3fe 100644 --- a/discord_utils.py +++ b/discord_utils.py @@ -3,7 +3,7 @@ from automation.automation_workflow import AutomationWorkflow from tc_messageBroker.rabbit_mq.saga.saga_base import get_saga from utils.credentials import get_mongo_credentials -from utils.get_guild_utils import get_platform_guild_id, get_platform_name +from utils.get_guild_utils import get_platform_guild_id, get_platform_name, get_platform_community_owner from utils.rabbitmq import RabbitMQSingleton from tc_messageBroker.rabbit_mq.event import Event from tc_messageBroker.rabbit_mq.queue import Queue @@ -57,10 +57,11 @@ def publish_on_success(platform_id: str, recompute: bool) -> None: "See your insights on your dashboard https://app.togethercrew.com/." " If you have questions send a DM to katerinabc (Discord) or k_bc0 (Telegram)." ) + owner_discord_id = get_platform_community_owner(platform_id) data = { "platformId": platform_id, "created": False, - "discordId": "user_id", # TODO: get the CM id + "discordId": owner_discord_id, "message": message, # the message to send "userFallback": True, } diff --git a/tests/integration/test_get_guild_owner.py b/tests/integration/test_get_guild_owner.py new file mode 100644 index 0000000..417423d --- /dev/null +++ b/tests/integration/test_get_guild_owner.py @@ -0,0 +1,218 @@ +from bson import ObjectId +from unittest import TestCase +from datetime import datetime, timedelta + +from utils.mongo import MongoSingleton +from utils.get_guild_utils import get_platform_community_owner + + +class TestGetGuildOwner(TestCase): + def setUp(self) -> None: + self.client = MongoSingleton.get_instance().get_client() + self.client["Core"].drop_collection("platforms") + self.client["Core"].drop_collection("users") + self.platform_id = "515151515151515151515151" + self.community_id = "aabbccddeeff001122334455" + self.guild_id = "1234" + self.client.drop_database(self.guild_id) + self.client.drop_database(self.platform_id) + + def tearDown(self) -> None: + self.client["Core"].drop_collection("platforms") + self.client["Core"].drop_collection("users") + self.client.drop_database(self.guild_id) + self.client.drop_database(self.platform_id) + + def test_no_platform_available(self): + with self.assertRaises(AttributeError): + _ = get_platform_community_owner(self.platform_id) + + def test_no_community_available(self): + self.client["Core"]["platforms"].insert_one( + { + "_id": ObjectId(self.platform_id), + "name": "discord", + "metadata": { + "id": self.guild_id, + "icon": "111111111111111111111111", + "name": "A guild", + "resources": ["1020707129214111827"], + "window": {"period_size": 7, "step_size": 1}, + "action": {"some_Values": 1}, + "period": datetime.now() - timedelta(days=30), + }, + "community": ObjectId(self.community_id), + "disconnectedAt": None, + "connectedAt": (datetime.now() - timedelta(days=40)), + "isInProgress": True, + "createdAt": datetime(2023, 11, 1), + "updatedAt": datetime(2023, 11, 1), + } + ) + with self.assertRaises(AttributeError): + _ = get_platform_community_owner(self.platform_id) + + def test_single_platform(self): + expected_owner_discord_id = "1234567890" + + self.client["Core"]["platforms"].insert_one( + { + "_id": ObjectId(self.platform_id), + "name": "discord", + "metadata": { + "id": self.guild_id, + "icon": "111111111111111111111111", + "name": "A guild", + "resources": ["1020707129214111827"], + "window": {"period_size": 7, "step_size": 1}, + "action": {"some_Values": 1}, + "period": datetime.now() - timedelta(days=30), + }, + "community": ObjectId(self.community_id), + "disconnectedAt": None, + "connectedAt": (datetime.now() - timedelta(days=40)), + "isInProgress": True, + "createdAt": datetime(2023, 11, 1), + "updatedAt": datetime(2023, 11, 1), + } + ) + self.client["Core"]["users"].insert_one( + { + "_id": ObjectId(self.platform_id), + "discordId": expected_owner_discord_id, + "communities": [ObjectId(self.community_id)], + "createdAt": datetime(2023, 12, 1), + "updatedAt": datetime(2023, 12, 1), + "tcaAt": datetime(2023, 12, 2), + } + ) + + owner = get_platform_community_owner(platform_id=self.platform_id) + + self.assertEqual( + owner, expected_owner_discord_id, + ) + + def test_multiple_platforms(self): + expected_owner_discord_id = "1234567890" + + self.client["Core"]["platforms"].insert_one( + { + "_id": ObjectId(self.platform_id), + "name": "discord", + "metadata": { + "id": self.guild_id, + "icon": "111111111111111111111111", + "name": "A guild", + "resources": ["1020707129214111827"], + "window": {"period_size": 7, "step_size": 1}, + "action": {"some_Values": 1}, + "period": datetime.now() - timedelta(days=30), + }, + "community": ObjectId(self.community_id), + "disconnectedAt": None, + "connectedAt": (datetime.now() - timedelta(days=40)), + "isInProgress": True, + "createdAt": datetime(2023, 11, 1), + "updatedAt": datetime(2023, 11, 1), + } + ) + self.client["Core"]["users"].insert_one( + { + "_id": ObjectId(self.platform_id), + "discordId": expected_owner_discord_id, + "communities": [ObjectId(self.community_id)], + "createdAt": datetime(2023, 12, 1), + "updatedAt": datetime(2023, 12, 1), + "tcaAt": datetime(2023, 12, 2), + } + ) + + owner = get_platform_community_owner(platform_id=self.platform_id) + + self.assertEqual( + owner, expected_owner_discord_id + ) + + def test_multiple_platforms_available(self): + expected_owner_discord_id = "1234567891" + platform_id2 = "515151515151515151515152" + platform_id3 = "515151515151515151515153" + + self.client["Core"]["platforms"].insert_many( + [ + { + "_id": ObjectId(self.platform_id), + "name": "discord", + "metadata": { + "id": self.guild_id, + "icon": "111111111111111111111111", + "name": "A guild", + "resources": ["1020707129214111827"], + "window": {"period_size": 7, "step_size": 1}, + "action": {"some_Values": 1}, + "period": datetime.now() - timedelta(days=30), + }, + "community": ObjectId(self.community_id), + "disconnectedAt": None, + "connectedAt": (datetime.now() - timedelta(days=40)), + "isInProgress": True, + "createdAt": datetime(2023, 11, 1), + "updatedAt": datetime(2023, 11, 1), + }, + { + "_id": ObjectId(platform_id2), + "name": "discord", + "metadata": { + "id": self.guild_id, + "icon": "111111111111111111111111", + "name": "A guild", + "resources": ["1020707129214111827"], + "window": {"period_size": 7, "step_size": 1}, + "action": {"some_Values": 1}, + "period": datetime.now() - timedelta(days=30), + }, + "community": ObjectId("aabbccddeeff001122334456"), + "disconnectedAt": None, + "connectedAt": (datetime.now() - timedelta(days=40)), + "isInProgress": True, + "createdAt": datetime(2023, 11, 1), + "updatedAt": datetime(2023, 11, 1), + }, + { + "_id": ObjectId(platform_id3), + "name": "discord", + "metadata": { + "id": self.guild_id, + "icon": "111111111111111111111111", + "name": "A guild", + "resources": ["1020707129214111827"], + "window": {"period_size": 7, "step_size": 1}, + "action": {"some_Values": 1}, + "period": datetime.now() - timedelta(days=30), + }, + "community": ObjectId("aabbccddeeff001122334457"), + "disconnectedAt": None, + "connectedAt": (datetime.now() - timedelta(days=40)), + "isInProgress": True, + "createdAt": datetime(2023, 11, 1), + "updatedAt": datetime(2023, 11, 1), + }, + ] + ) + self.client["Core"]["users"].insert_one( + { + "_id": ObjectId(self.platform_id), + "discordId": expected_owner_discord_id, + "communities": [ObjectId(self.community_id)], + "createdAt": datetime(2023, 12, 1), + "updatedAt": datetime(2023, 12, 1), + "tcaAt": datetime(2023, 12, 2), + } + ) + + owner = get_platform_community_owner(platform_id=self.platform_id) + + self.assertEqual( + owner, expected_owner_discord_id + ) diff --git a/tests/integration/test_publish_on_success_recompute_true.py b/tests/integration/test_publish_on_success_recompute_true.py index 002cd3b..399665b 100644 --- a/tests/integration/test_publish_on_success_recompute_true.py +++ b/tests/integration/test_publish_on_success_recompute_true.py @@ -28,10 +28,8 @@ def test_publish_on_success_recompute_true_check_notification_choreographies(): at_db = os.getenv("AUTOMATION_DB_NAME") at_collection = os.getenv("AUTOMATION_DB_COLLECTION") - db_access.db_mongo_client["Core"]["platforms"].delete_one( - {"_id": ObjectId(platform_id)} - ) - + db_access.db_mongo_client["Core"].drop_collection("platforms") + db_access.db_mongo_client["Core"].drop_collection("users") db_access.db_mongo_client.drop_database(platform_id) db_access.db_mongo_client.drop_database(guild_id) db_access.db_mongo_client["Saga"].drop_collection("sagas") @@ -56,6 +54,8 @@ def test_publish_on_success_recompute_true_check_notification_choreographies(): "period_size": 7, "step_size": 1, } + community_id = "aabbccddeeff001122334455" + owner_discord_id = "123487878912" db_access.db_mongo_client["Core"]["platforms"].insert_one( { @@ -70,7 +70,7 @@ def test_publish_on_success_recompute_true_check_notification_choreographies(): "action": act_param, "period": datetime.now() - timedelta(days=10), }, - "community": ObjectId("aabbccddeeff001122334455"), + "community": ObjectId(community_id), "disconnectedAt": None, "connectedAt": (datetime.now() - timedelta(days=10)), "isInProgress": True, @@ -79,6 +79,18 @@ def test_publish_on_success_recompute_true_check_notification_choreographies(): } ) + db_access.db_mongo_client["Core"]["users"].insert_one( + { + "_id": ObjectId(platform_id), + "discordId": owner_discord_id, + "communities": [ObjectId(community_id)], + "createdAt": datetime(2023, 12, 1), + "updatedAt": datetime(2023, 12, 1), + "tcaAt": datetime(2023, 12, 2), + } + ) + + db_access.db_mongo_client["Saga"]["sagas"].insert_one( { "choreography": { @@ -332,7 +344,7 @@ def test_publish_on_success_recompute_true_check_notification_choreographies(): assert user_cm_doc["data"]["message"] == expected_msg job_finished_saga = db_access.db_mongo_client["Saga"]["sagas"].find_one( - {"data.discordId": "user_id"} + {"data.discordId": owner_discord_id} ) assert job_finished_saga["data"]["message"] == ( "Your data import into TogetherCrew is complete! " diff --git a/utils/get_guild_utils.py b/utils/get_guild_utils.py index 4a65175..7de3b6b 100644 --- a/utils/get_guild_utils.py +++ b/utils/get_guild_utils.py @@ -64,6 +64,11 @@ def get_platform_name(platform_id: str) -> str: ------------- platform_id : str the platform id related to a platform + + Returns + -------- + platform_name : str + the platform name i.e.: `discord`, `telegram`, etc """ client = MongoSingleton.get_instance().client @@ -74,3 +79,39 @@ def get_platform_name(platform_id: str) -> str: raise AttributeError(f"platform with given platform_id: {platform_id} not found!") return platform["name"] + +def get_platform_community_owner(platform_id: str) -> str: + """ + get the community owener discord id using the platform id + + Parameters + ------------- + platform_id : str + the platform id related to a platform + + Returns + -------- + owner_discord_id : str + the owner discord id + """ + client = MongoSingleton.get_instance().client + + platform = client["Core"]["platforms"].find_one( + {"_id": ObjectId(platform_id)}, {"community": True} + ) + + if platform is None: + raise AttributeError(f"platform with given platform_id: {platform_id} not found!") + + community_id = platform["community"] + community = client["Core"]["users"].find_one( + {"communities": community_id}, {"discordId": True} + ) + if community is None: + raise AttributeError( + f"Community user with given community id: {community_id} not found!" + ) + + owner_discord_id = community["discordId"] + + return owner_discord_id From aaec0274128d657cab8f8236a36834d657fca0e3 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Tue, 2 Jul 2024 15:14:24 +0330 Subject: [PATCH 07/23] feat: update package locations! As we're moving the analyzer to be a library, we're trying to wrap up all the codes in one package. --- .../publish_on_success.py | 27 +++++-------------- ...test_publish_on_success_recompute_false.py | 2 +- .../test_publish_on_success_recompute_true.py | 2 +- 3 files changed, 9 insertions(+), 22 deletions(-) rename discord_utils.py => discord_analyzer/publish_on_success.py (79%) diff --git a/discord_utils.py b/discord_analyzer/publish_on_success.py similarity index 79% rename from discord_utils.py rename to discord_analyzer/publish_on_success.py index 5dee3fe..55c20b6 100644 --- a/discord_utils.py +++ b/discord_analyzer/publish_on_success.py @@ -1,33 +1,20 @@ import logging from automation.automation_workflow import AutomationWorkflow -from tc_messageBroker.rabbit_mq.saga.saga_base import get_saga -from utils.credentials import get_mongo_credentials -from utils.get_guild_utils import get_platform_guild_id, get_platform_name, get_platform_community_owner -from utils.rabbitmq import RabbitMQSingleton from tc_messageBroker.rabbit_mq.event import Event from tc_messageBroker.rabbit_mq.queue import Queue - - -def get_saga_instance(sagaId: str): - mongo_creds = get_mongo_credentials() - - saga = get_saga( - sagaId=sagaId, - connection_url=mongo_creds["connection_str"], - db_name="Saga", - collection="sagas", - ) - if saga is None: - raise ValueError(f"Saga with sagaId: {sagaId} not found!") - - return saga +from utils.get_guild_utils import ( + get_platform_guild_id, + get_platform_name, + get_platform_community_owner +) +from utils.rabbitmq import RabbitMQSingleton def publish_on_success(platform_id: str, recompute: bool) -> None: """ publish a message to discord platform for a specific platform - telling the Community Manager (CM) the work is finished + telling the Community Manager (CM) the work is finished and run automation Note: this will work just for discord platform! diff --git a/tests/integration/test_publish_on_success_recompute_false.py b/tests/integration/test_publish_on_success_recompute_false.py index 12aa8ef..ebc0979 100644 --- a/tests/integration/test_publish_on_success_recompute_false.py +++ b/tests/integration/test_publish_on_success_recompute_false.py @@ -8,7 +8,7 @@ AutomationTrigger, ) from bson.objectid import ObjectId -from discord_utils import publish_on_success +from discord_analyzer.publish_on_success import publish_on_success from dotenv import load_dotenv from .utils.analyzer_setup import launch_db_access diff --git a/tests/integration/test_publish_on_success_recompute_true.py b/tests/integration/test_publish_on_success_recompute_true.py index 399665b..13b5d70 100644 --- a/tests/integration/test_publish_on_success_recompute_true.py +++ b/tests/integration/test_publish_on_success_recompute_true.py @@ -8,7 +8,7 @@ AutomationTrigger, ) from bson.objectid import ObjectId -from discord_utils import publish_on_success +from discord_analyzer.publish_on_success import publish_on_success from dotenv import load_dotenv from .utils.analyzer_setup import launch_db_access From 5cb3fa7dadf97c8d674086cfc6dc49648d194dbb Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Tue, 2 Jul 2024 15:15:23 +0330 Subject: [PATCH 08/23] feat: Added restart option! on test cases rabbitMQ is becoming down and it is always making some test cases to fail. --- docker-compose.test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docker-compose.test.yml b/docker-compose.test.yml index 3bd3a37..6c70063 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -42,6 +42,7 @@ services: condition: service_healthy mongo: image: "mongo:6.0.8" + restart: always attach: false environment: - MONGO_INITDB_ROOT_USERNAME=root @@ -54,6 +55,7 @@ services: start_period: 40s neo4j: image: "neo4j:5.9.0" + restart: always attach: false environment: - NEO4J_AUTH=neo4j/password @@ -67,6 +69,7 @@ services: start_period: 40s rabbitmq: image: "rabbitmq:3-management-alpine" + restart: always environment: - RABBITMQ_DEFAULT_USER=root - RABBITMQ_DEFAULT_PASS=pass From 917ffbcd135b5c200b9cfc90f382ed83ef45ef15 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Tue, 2 Jul 2024 15:21:50 +0330 Subject: [PATCH 09/23] feat: moved utility package to discord_analyzer! --- automation/utils/automation_base.py | 4 +- automation/utils/model.py | 4 +- .../DB_operations/mongodb_access.py | 2 +- .../compute_interaction_matrix_discord.py | 2 +- .../metrics/analyzer_memberactivities.py | 2 +- .../metrics/heatmaps/analytics_hourly.py | 2 +- .../metrics/heatmaps/analytics_raw.py | 2 +- discord_analyzer/metrics/heatmaps/heatmaps.py | 2 +- .../metrics/heatmaps/heatmaps_utils.py | 2 +- .../metrics/memberactivity_utils.py | 2 +- discord_analyzer/metrics/utils/platform.py | 2 +- .../models/raw_member_activities.py | 2 +- discord_analyzer/publish_on_success.py | 4 +- {utils => discord_analyzer/utils}/__init__.py | 0 .../utils}/credentials.py | 0 .../utils}/get_automation_env.py | 0 .../utils}/get_guild_utils.py | 2 +- {utils => discord_analyzer/utils}/mongo.py | 2 +- {utils => discord_analyzer/utils}/rabbitmq.py | 2 +- {utils => discord_analyzer/utils}/redis.py | 2 +- .../test_analyzer_platform_fetch_period.py | 2 +- .../test_analyzer_platform_fetch_resources.py | 2 +- .../test_analyzer_utils_platform.py | 2 +- ...test_analyzer_utils_platform_parameters.py | 2 +- .../test_automation_db_load_from_db.py | 2 +- .../test_automation_db_save_to_db.py | 2 +- .../test_get_guild_community_ids.py | 4 +- tests/integration/test_get_guild_owner.py | 4 +- .../integration/test_get_guild_platform_id.py | 4 +- tests/integration/test_heatmaps_analytics.py | 2 +- .../test_heatmaps_analytics_base.py | 2 +- ...est_heatmaps_analytics_different_source.py | 2 +- ...est_heatmaps_analytics_hourly_no_filter.py | 2 +- .../test_heatmaps_analytics_raw.py | 2 +- ...atmaps_hourly_analytics_actions_vectors.py | 2 +- ...ps_hourly_analytics_interaction_vectors.py | 2 +- .../test_heatmaps_hourly_lone_message.py | 2 +- .../test_heatmaps_hourly_mentions.py | 2 +- ...test_heatmaps_process_hourly_single_day.py | 2 +- .../test_heatmaps_process_raw_analytics.py | 2 +- tests/integration/test_heatmaps_reactions.py | 2 +- tests/integration/test_heatmaps_replier.py | 2 +- tests/integration/test_heatmaps_thread_msg.py | 2 +- tests/integration/test_heatmaps_utils.py | 2 +- .../test_rawinfo_webhook_fetching.py | 2 +- tests/integration/test_service_connection.py | 2 +- tests/unit/test_creds_loading.py | 2 +- tests/unit/test_mongo_singleton.py | 2 +- utils/transactions_ordering.py | 61 ------------------- 49 files changed, 51 insertions(+), 112 deletions(-) rename {utils => discord_analyzer/utils}/__init__.py (100%) rename {utils => discord_analyzer/utils}/credentials.py (100%) rename {utils => discord_analyzer/utils}/get_automation_env.py (100%) rename {utils => discord_analyzer/utils}/get_guild_utils.py (98%) rename {utils => discord_analyzer/utils}/mongo.py (93%) rename {utils => discord_analyzer/utils}/rabbitmq.py (94%) rename {utils => discord_analyzer/utils}/redis.py (94%) delete mode 100644 utils/transactions_ordering.py diff --git a/automation/utils/automation_base.py b/automation/utils/automation_base.py index bfd0d34..8527340 100644 --- a/automation/utils/automation_base.py +++ b/automation/utils/automation_base.py @@ -2,8 +2,8 @@ from typing import Any from uuid import uuid1 -from utils.mongo import MongoSingleton -from utils.rabbitmq import RabbitMQSingleton +from discord_analyzer.utils.mongo import MongoSingleton +from discord_analyzer.utils.rabbitmq import RabbitMQSingleton class AutomationBase: diff --git a/automation/utils/model.py b/automation/utils/model.py index 1f4dc09..a2420ff 100644 --- a/automation/utils/model.py +++ b/automation/utils/model.py @@ -1,5 +1,5 @@ -from utils.get_automation_env import get_automations_env -from utils.mongo import MongoSingleton +from discord_analyzer.utils.get_automation_env import get_automations_env +from discord_analyzer.utils.mongo import MongoSingleton from .interfaces import Automation diff --git a/discord_analyzer/DB_operations/mongodb_access.py b/discord_analyzer/DB_operations/mongodb_access.py index 2427159..afab4b4 100644 --- a/discord_analyzer/DB_operations/mongodb_access.py +++ b/discord_analyzer/DB_operations/mongodb_access.py @@ -1,4 +1,4 @@ -from utils.mongo import MongoSingleton +from discord_analyzer.utils.mongo import MongoSingleton class DB_access: diff --git a/discord_analyzer/algorithms/compute_interaction_matrix_discord.py b/discord_analyzer/algorithms/compute_interaction_matrix_discord.py index 8a1e805..d86abf5 100644 --- a/discord_analyzer/algorithms/compute_interaction_matrix_discord.py +++ b/discord_analyzer/algorithms/compute_interaction_matrix_discord.py @@ -4,7 +4,7 @@ from numpy import diag_indices_from, ndarray -from utils.mongo import MongoSingleton +from discord_analyzer.utils.mongo import MongoSingleton from .utils.compute_interaction_mtx_utils import ( generate_interaction_matrix, prepare_per_account, diff --git a/discord_analyzer/metrics/analyzer_memberactivities.py b/discord_analyzer/metrics/analyzer_memberactivities.py index a61a580..ae8eecd 100644 --- a/discord_analyzer/metrics/analyzer_memberactivities.py +++ b/discord_analyzer/metrics/analyzer_memberactivities.py @@ -6,7 +6,7 @@ from discord_analyzer.models.MemberActivityModel import MemberActivityModel from discord_analyzer.models.RawInfoModel import RawInfoModel from discord_analyzer.schemas.platform_configs.config_base import PlatformConfigBase -from utils.mongo import MongoSingleton +from discord_analyzer.utils.mongo import MongoSingleton class MemberActivities: diff --git a/discord_analyzer/metrics/heatmaps/analytics_hourly.py b/discord_analyzer/metrics/heatmaps/analytics_hourly.py index a8eaf41..260ff9c 100644 --- a/discord_analyzer/metrics/heatmaps/analytics_hourly.py +++ b/discord_analyzer/metrics/heatmaps/analytics_hourly.py @@ -2,7 +2,7 @@ from typing import Any import numpy as np -from utils.mongo import MongoSingleton +from discord_analyzer.utils.mongo import MongoSingleton class AnalyticsHourly: diff --git a/discord_analyzer/metrics/heatmaps/analytics_raw.py b/discord_analyzer/metrics/heatmaps/analytics_raw.py index 729babd..fbcaa91 100644 --- a/discord_analyzer/metrics/heatmaps/analytics_raw.py +++ b/discord_analyzer/metrics/heatmaps/analytics_raw.py @@ -3,7 +3,7 @@ from typing import Any from discord_analyzer.schemas import RawAnalyticsItem -from utils.mongo import MongoSingleton +from discord_analyzer.utils.mongo import MongoSingleton class AnalyticsRaw: diff --git a/discord_analyzer/metrics/heatmaps/heatmaps.py b/discord_analyzer/metrics/heatmaps/heatmaps.py index ed46333..aa694e0 100644 --- a/discord_analyzer/metrics/heatmaps/heatmaps.py +++ b/discord_analyzer/metrics/heatmaps/heatmaps.py @@ -4,7 +4,7 @@ from discord_analyzer.metrics.heatmaps import AnalyticsHourly, AnalyticsRaw from discord_analyzer.metrics.heatmaps.heatmaps_utils import HeatmapsUtils from discord_analyzer.schemas.platform_configs.config_base import PlatformConfigBase -from utils.mongo import MongoSingleton +from discord_analyzer.utils.mongo import MongoSingleton class Heatmaps: diff --git a/discord_analyzer/metrics/heatmaps/heatmaps_utils.py b/discord_analyzer/metrics/heatmaps/heatmaps_utils.py index 26cb34d..922011e 100644 --- a/discord_analyzer/metrics/heatmaps/heatmaps_utils.py +++ b/discord_analyzer/metrics/heatmaps/heatmaps_utils.py @@ -1,7 +1,7 @@ from datetime import datetime from pymongo.cursor import Cursor -from utils.mongo import MongoSingleton +from discord_analyzer.utils.mongo import MongoSingleton class HeatmapsUtils: diff --git a/discord_analyzer/metrics/memberactivity_utils.py b/discord_analyzer/metrics/memberactivity_utils.py index 5d74cc1..daf86da 100644 --- a/discord_analyzer/metrics/memberactivity_utils.py +++ b/discord_analyzer/metrics/memberactivity_utils.py @@ -1,7 +1,7 @@ import logging from dateutil import parser -from utils.mongo import MongoSingleton +from discord_analyzer.utils.mongo import MongoSingleton class MemberActivityUtils: diff --git a/discord_analyzer/metrics/utils/platform.py b/discord_analyzer/metrics/utils/platform.py index fde2f6c..c91668c 100644 --- a/discord_analyzer/metrics/utils/platform.py +++ b/discord_analyzer/metrics/utils/platform.py @@ -1,7 +1,7 @@ from bson import ObjectId from datetime import datetime -from utils.mongo import MongoSingleton +from discord_analyzer.utils.mongo import MongoSingleton class Platform: diff --git a/discord_analyzer/models/raw_member_activities.py b/discord_analyzer/models/raw_member_activities.py index 8b5b537..e0a55af 100644 --- a/discord_analyzer/models/raw_member_activities.py +++ b/discord_analyzer/models/raw_member_activities.py @@ -4,7 +4,7 @@ import numpy as np from discord_analyzer.models.BaseModel import BaseModel -from utils.mongo import MongoSingleton +from discord_analyzer.utils.mongo import MongoSingleton class RawMemberActivities(BaseModel): diff --git a/discord_analyzer/publish_on_success.py b/discord_analyzer/publish_on_success.py index 55c20b6..fd7d45c 100644 --- a/discord_analyzer/publish_on_success.py +++ b/discord_analyzer/publish_on_success.py @@ -3,12 +3,12 @@ from automation.automation_workflow import AutomationWorkflow from tc_messageBroker.rabbit_mq.event import Event from tc_messageBroker.rabbit_mq.queue import Queue -from utils.get_guild_utils import ( +from discord_analyzer.utils.get_guild_utils import ( get_platform_guild_id, get_platform_name, get_platform_community_owner ) -from utils.rabbitmq import RabbitMQSingleton +from discord_analyzer.utils.rabbitmq import RabbitMQSingleton def publish_on_success(platform_id: str, recompute: bool) -> None: diff --git a/utils/__init__.py b/discord_analyzer/utils/__init__.py similarity index 100% rename from utils/__init__.py rename to discord_analyzer/utils/__init__.py diff --git a/utils/credentials.py b/discord_analyzer/utils/credentials.py similarity index 100% rename from utils/credentials.py rename to discord_analyzer/utils/credentials.py diff --git a/utils/get_automation_env.py b/discord_analyzer/utils/get_automation_env.py similarity index 100% rename from utils/get_automation_env.py rename to discord_analyzer/utils/get_automation_env.py diff --git a/utils/get_guild_utils.py b/discord_analyzer/utils/get_guild_utils.py similarity index 98% rename from utils/get_guild_utils.py rename to discord_analyzer/utils/get_guild_utils.py index 7de3b6b..9af4050 100644 --- a/utils/get_guild_utils.py +++ b/discord_analyzer/utils/get_guild_utils.py @@ -1,5 +1,5 @@ from bson.objectid import ObjectId -from utils.mongo import MongoSingleton +from discord_analyzer.utils.mongo import MongoSingleton def get_platform_guild_id(platform_id: str) -> str: diff --git a/utils/mongo.py b/discord_analyzer/utils/mongo.py similarity index 93% rename from utils/mongo.py rename to discord_analyzer/utils/mongo.py index 9d67566..b04ba45 100644 --- a/utils/mongo.py +++ b/discord_analyzer/utils/mongo.py @@ -2,7 +2,7 @@ from typing import Any from pymongo import MongoClient -from utils.credentials import get_mongo_credentials +from discord_analyzer.utils.credentials import get_mongo_credentials class MongoSingleton: diff --git a/utils/rabbitmq.py b/discord_analyzer/utils/rabbitmq.py similarity index 94% rename from utils/rabbitmq.py rename to discord_analyzer/utils/rabbitmq.py index 452c69a..a33a84d 100644 --- a/utils/rabbitmq.py +++ b/discord_analyzer/utils/rabbitmq.py @@ -2,7 +2,7 @@ from tc_messageBroker import RabbitMQ from tc_messageBroker.rabbit_mq.queue import Queue -from utils.credentials import get_rabbit_mq_credentials +from discord_analyzer.utils.credentials import get_rabbit_mq_credentials class RabbitMQSingleton: diff --git a/utils/redis.py b/discord_analyzer/utils/redis.py similarity index 94% rename from utils/redis.py rename to discord_analyzer/utils/redis.py index c8224ed..45793d3 100644 --- a/utils/redis.py +++ b/discord_analyzer/utils/redis.py @@ -1,7 +1,7 @@ import logging import redis -from utils.credentials import get_redis_credentials +from discord_analyzer.utils.credentials import get_redis_credentials class RedisSingleton: diff --git a/tests/integration/test_analyzer_platform_fetch_period.py b/tests/integration/test_analyzer_platform_fetch_period.py index afc9bf9..1190f0f 100644 --- a/tests/integration/test_analyzer_platform_fetch_period.py +++ b/tests/integration/test_analyzer_platform_fetch_period.py @@ -2,7 +2,7 @@ from datetime import datetime from unittest import TestCase -from utils.mongo import MongoSingleton +from discord_analyzer.utils.mongo import MongoSingleton from discord_analyzer.metrics.utils import Platform diff --git a/tests/integration/test_analyzer_platform_fetch_resources.py b/tests/integration/test_analyzer_platform_fetch_resources.py index 7a7d146..593b182 100644 --- a/tests/integration/test_analyzer_platform_fetch_resources.py +++ b/tests/integration/test_analyzer_platform_fetch_resources.py @@ -2,7 +2,7 @@ from datetime import datetime from unittest import TestCase -from utils.mongo import MongoSingleton +from discord_analyzer.utils.mongo import MongoSingleton from discord_analyzer.metrics.utils import Platform diff --git a/tests/integration/test_analyzer_utils_platform.py b/tests/integration/test_analyzer_utils_platform.py index 6a576c0..51e5dbc 100644 --- a/tests/integration/test_analyzer_utils_platform.py +++ b/tests/integration/test_analyzer_utils_platform.py @@ -2,7 +2,7 @@ from unittest import TestCase from discord_analyzer.metrics.utils import Platform -from utils.mongo import MongoSingleton +from discord_analyzer.utils.mongo import MongoSingleton class TestAnalyzerUtilsPlatform(TestCase): diff --git a/tests/integration/test_analyzer_utils_platform_parameters.py b/tests/integration/test_analyzer_utils_platform_parameters.py index 257097e..c439592 100644 --- a/tests/integration/test_analyzer_utils_platform_parameters.py +++ b/tests/integration/test_analyzer_utils_platform_parameters.py @@ -3,7 +3,7 @@ from datetime import datetime, timedelta from discord_analyzer.metrics.utils import Platform -from utils.mongo import MongoSingleton +from discord_analyzer.utils.mongo import MongoSingleton class TestAnalyzerUtilsPlatform(TestCase): diff --git a/tests/integration/test_automation_db_load_from_db.py b/tests/integration/test_automation_db_load_from_db.py index 64fc96a..89a19b7 100644 --- a/tests/integration/test_automation_db_load_from_db.py +++ b/tests/integration/test_automation_db_load_from_db.py @@ -4,7 +4,7 @@ from automation.utils.model import AutomationDB from dotenv import load_dotenv -from utils.mongo import MongoSingleton +from discord_analyzer.utils.mongo import MongoSingleton class TestAutomationDBLoadFromDB(unittest.TestCase): diff --git a/tests/integration/test_automation_db_save_to_db.py b/tests/integration/test_automation_db_save_to_db.py index 607e772..7a62ccc 100644 --- a/tests/integration/test_automation_db_save_to_db.py +++ b/tests/integration/test_automation_db_save_to_db.py @@ -5,7 +5,7 @@ from automation.utils.interfaces import Automation from automation.utils.model import AutomationDB from dotenv import load_dotenv -from utils.mongo import MongoSingleton +from discord_analyzer.utils.mongo import MongoSingleton class TestAutomationDBSaveToDB(unittest.TestCase): diff --git a/tests/integration/test_get_guild_community_ids.py b/tests/integration/test_get_guild_community_ids.py index dd0c203..0ee257f 100644 --- a/tests/integration/test_get_guild_community_ids.py +++ b/tests/integration/test_get_guild_community_ids.py @@ -2,8 +2,8 @@ from unittest import TestCase from bson.objectid import ObjectId -from utils.get_guild_utils import get_platform_guild_id -from utils.mongo import MongoSingleton +from discord_analyzer.utils.get_guild_utils import get_platform_guild_id +from discord_analyzer.utils.mongo import MongoSingleton class TestGetGuildId(TestCase): diff --git a/tests/integration/test_get_guild_owner.py b/tests/integration/test_get_guild_owner.py index 417423d..9cc08a8 100644 --- a/tests/integration/test_get_guild_owner.py +++ b/tests/integration/test_get_guild_owner.py @@ -2,8 +2,8 @@ from unittest import TestCase from datetime import datetime, timedelta -from utils.mongo import MongoSingleton -from utils.get_guild_utils import get_platform_community_owner +from discord_analyzer.utils.mongo import MongoSingleton +from discord_analyzer.utils.get_guild_utils import get_platform_community_owner class TestGetGuildOwner(TestCase): diff --git a/tests/integration/test_get_guild_platform_id.py b/tests/integration/test_get_guild_platform_id.py index 5e4fa92..63966fc 100644 --- a/tests/integration/test_get_guild_platform_id.py +++ b/tests/integration/test_get_guild_platform_id.py @@ -2,8 +2,8 @@ from unittest import TestCase from bson.objectid import ObjectId -from utils.get_guild_utils import get_guild_platform_id -from utils.mongo import MongoSingleton +from discord_analyzer.utils.get_guild_utils import get_guild_platform_id +from discord_analyzer.utils.mongo import MongoSingleton class TestGetGuildId(TestCase): diff --git a/tests/integration/test_heatmaps_analytics.py b/tests/integration/test_heatmaps_analytics.py index fbc3d1d..770ec84 100644 --- a/tests/integration/test_heatmaps_analytics.py +++ b/tests/integration/test_heatmaps_analytics.py @@ -3,7 +3,7 @@ from discord_analyzer.metrics.heatmaps import Heatmaps from discord_analyzer.schemas.platform_configs import DiscordAnalyzerConfig -from utils.mongo import MongoSingleton +from discord_analyzer.utils.mongo import MongoSingleton class TestHeatmapsAnalytics(TestCase): diff --git a/tests/integration/test_heatmaps_analytics_base.py b/tests/integration/test_heatmaps_analytics_base.py index 4b09e55..a2f4baf 100644 --- a/tests/integration/test_heatmaps_analytics_base.py +++ b/tests/integration/test_heatmaps_analytics_base.py @@ -2,7 +2,7 @@ from unittest import TestCase from discord_analyzer.metrics.heatmaps.analytics_hourly import AnalyticsHourly -from utils.mongo import MongoSingleton +from discord_analyzer.utils.mongo import MongoSingleton class TestHeatmapsAnalyticsBaseWithFilter(TestCase): diff --git a/tests/integration/test_heatmaps_analytics_different_source.py b/tests/integration/test_heatmaps_analytics_different_source.py index d3e4296..cba667c 100644 --- a/tests/integration/test_heatmaps_analytics_different_source.py +++ b/tests/integration/test_heatmaps_analytics_different_source.py @@ -3,7 +3,7 @@ from discord_analyzer.metrics.heatmaps import Heatmaps from discord_analyzer.schemas.platform_configs import DiscordAnalyzerConfig -from utils.mongo import MongoSingleton +from discord_analyzer.utils.mongo import MongoSingleton class TestHeatmapsAnalyticsSingleDay(TestCase): diff --git a/tests/integration/test_heatmaps_analytics_hourly_no_filter.py b/tests/integration/test_heatmaps_analytics_hourly_no_filter.py index c484a40..1106763 100644 --- a/tests/integration/test_heatmaps_analytics_hourly_no_filter.py +++ b/tests/integration/test_heatmaps_analytics_hourly_no_filter.py @@ -2,7 +2,7 @@ from unittest import TestCase from discord_analyzer.metrics.heatmaps.analytics_hourly import AnalyticsHourly -from utils.mongo import MongoSingleton +from discord_analyzer.utils.mongo import MongoSingleton class TestHeatmapsAnalyticsBaseNoFilter(TestCase): diff --git a/tests/integration/test_heatmaps_analytics_raw.py b/tests/integration/test_heatmaps_analytics_raw.py index bcdf1f4..0ad8076 100644 --- a/tests/integration/test_heatmaps_analytics_raw.py +++ b/tests/integration/test_heatmaps_analytics_raw.py @@ -3,7 +3,7 @@ from discord_analyzer.metrics.heatmaps.analytics_raw import AnalyticsRaw from discord_analyzer.schemas import ActivityDirection, RawAnalyticsItem -from utils.mongo import MongoSingleton +from discord_analyzer.utils.mongo import MongoSingleton class TestHeatmapsRawAnalytics(TestCase): diff --git a/tests/integration/test_heatmaps_hourly_analytics_actions_vectors.py b/tests/integration/test_heatmaps_hourly_analytics_actions_vectors.py index 105c5df..2e65636 100644 --- a/tests/integration/test_heatmaps_hourly_analytics_actions_vectors.py +++ b/tests/integration/test_heatmaps_hourly_analytics_actions_vectors.py @@ -2,7 +2,7 @@ from unittest import TestCase from discord_analyzer.metrics.heatmaps.analytics_hourly import AnalyticsHourly -from utils.mongo import MongoSingleton +from discord_analyzer.utils.mongo import MongoSingleton class TestHeatmapsRawAnalyticsVectorsActions(TestCase): diff --git a/tests/integration/test_heatmaps_hourly_analytics_interaction_vectors.py b/tests/integration/test_heatmaps_hourly_analytics_interaction_vectors.py index 0ba1557..dfe3d88 100644 --- a/tests/integration/test_heatmaps_hourly_analytics_interaction_vectors.py +++ b/tests/integration/test_heatmaps_hourly_analytics_interaction_vectors.py @@ -2,7 +2,7 @@ from unittest import TestCase from discord_analyzer.metrics.heatmaps.analytics_hourly import AnalyticsHourly -from utils.mongo import MongoSingleton +from discord_analyzer.utils.mongo import MongoSingleton class TestHeatmapsRawAnalyticsVectorsInteractions(TestCase): diff --git a/tests/integration/test_heatmaps_hourly_lone_message.py b/tests/integration/test_heatmaps_hourly_lone_message.py index 0fd4254..c69b720 100644 --- a/tests/integration/test_heatmaps_hourly_lone_message.py +++ b/tests/integration/test_heatmaps_hourly_lone_message.py @@ -2,7 +2,7 @@ from discord_analyzer.metrics.heatmaps import Heatmaps from discord_analyzer.schemas.platform_configs import DiscordAnalyzerConfig -from utils.mongo import MongoSingleton +from discord_analyzer.utils.mongo import MongoSingleton def test_lone_messages(): diff --git a/tests/integration/test_heatmaps_hourly_mentions.py b/tests/integration/test_heatmaps_hourly_mentions.py index a47bf41..e663ebd 100644 --- a/tests/integration/test_heatmaps_hourly_mentions.py +++ b/tests/integration/test_heatmaps_hourly_mentions.py @@ -2,7 +2,7 @@ from discord_analyzer.metrics.heatmaps import Heatmaps from discord_analyzer.schemas.platform_configs import DiscordAnalyzerConfig -from utils.mongo import MongoSingleton +from discord_analyzer.utils.mongo import MongoSingleton def test_mentioned_messages(): diff --git a/tests/integration/test_heatmaps_process_hourly_single_day.py b/tests/integration/test_heatmaps_process_hourly_single_day.py index e41f0bf..d3434a6 100644 --- a/tests/integration/test_heatmaps_process_hourly_single_day.py +++ b/tests/integration/test_heatmaps_process_hourly_single_day.py @@ -3,7 +3,7 @@ from discord_analyzer.metrics.heatmaps import Heatmaps from discord_analyzer.schemas.platform_configs import DiscordAnalyzerConfig -from utils.mongo import MongoSingleton +from discord_analyzer.utils.mongo import MongoSingleton class TestHeatmapsProcessHourlySingleDay(TestCase): diff --git a/tests/integration/test_heatmaps_process_raw_analytics.py b/tests/integration/test_heatmaps_process_raw_analytics.py index 5bc86d5..51b9508 100644 --- a/tests/integration/test_heatmaps_process_raw_analytics.py +++ b/tests/integration/test_heatmaps_process_raw_analytics.py @@ -3,7 +3,7 @@ from discord_analyzer.metrics.heatmaps import Heatmaps from discord_analyzer.schemas.platform_configs import DiscordAnalyzerConfig -from utils.mongo import MongoSingleton +from discord_analyzer.utils.mongo import MongoSingleton class TestHeatmapsProcessRawAnalyticsSingleDay(TestCase): diff --git a/tests/integration/test_heatmaps_reactions.py b/tests/integration/test_heatmaps_reactions.py index a01d73e..e1e05f9 100644 --- a/tests/integration/test_heatmaps_reactions.py +++ b/tests/integration/test_heatmaps_reactions.py @@ -2,7 +2,7 @@ from discord_analyzer.metrics.heatmaps import Heatmaps from discord_analyzer.schemas.platform_configs import DiscordAnalyzerConfig -from utils.mongo import MongoSingleton +from discord_analyzer.utils.mongo import MongoSingleton def test_reacted_messages(): diff --git a/tests/integration/test_heatmaps_replier.py b/tests/integration/test_heatmaps_replier.py index f375603..4c46f80 100644 --- a/tests/integration/test_heatmaps_replier.py +++ b/tests/integration/test_heatmaps_replier.py @@ -2,7 +2,7 @@ from discord_analyzer.metrics.heatmaps import Heatmaps from discord_analyzer.schemas.platform_configs import DiscordAnalyzerConfig -from utils.mongo import MongoSingleton +from discord_analyzer.utils.mongo import MongoSingleton def test_reply_messages(): diff --git a/tests/integration/test_heatmaps_thread_msg.py b/tests/integration/test_heatmaps_thread_msg.py index db7573c..f354e6f 100644 --- a/tests/integration/test_heatmaps_thread_msg.py +++ b/tests/integration/test_heatmaps_thread_msg.py @@ -2,7 +2,7 @@ from discord_analyzer.metrics.heatmaps import Heatmaps from discord_analyzer.schemas.platform_configs import DiscordAnalyzerConfig -from utils.mongo import MongoSingleton +from discord_analyzer.utils.mongo import MongoSingleton def test_thread_messages(): diff --git a/tests/integration/test_heatmaps_utils.py b/tests/integration/test_heatmaps_utils.py index f1a90b4..6e74ecb 100644 --- a/tests/integration/test_heatmaps_utils.py +++ b/tests/integration/test_heatmaps_utils.py @@ -2,7 +2,7 @@ from unittest import TestCase from discord_analyzer.metrics.heatmaps.heatmaps_utils import HeatmapsUtils -from utils.mongo import MongoSingleton +from discord_analyzer.utils.mongo import MongoSingleton class TestHeatmapsUtils(TestCase): diff --git a/tests/integration/test_rawinfo_webhook_fetching.py b/tests/integration/test_rawinfo_webhook_fetching.py index 1f5aa11..a955aab 100644 --- a/tests/integration/test_rawinfo_webhook_fetching.py +++ b/tests/integration/test_rawinfo_webhook_fetching.py @@ -1,7 +1,7 @@ from datetime import datetime, timedelta from discord_analyzer.models.RawInfoModel import RawInfoModel -from utils.mongo import MongoSingleton +from discord_analyzer.utils.mongo import MongoSingleton def test_rawinfo_get_day_entry_empty_data(): diff --git a/tests/integration/test_service_connection.py b/tests/integration/test_service_connection.py index 1d4c4e7..378bf82 100644 --- a/tests/integration/test_service_connection.py +++ b/tests/integration/test_service_connection.py @@ -1,5 +1,5 @@ from tc_messageBroker.message_broker import RabbitMQ -from utils.credentials import get_rabbit_mq_credentials +from discord_analyzer.utils.credentials import get_rabbit_mq_credentials def test_rabbit_mq_connect(): diff --git a/tests/unit/test_creds_loading.py b/tests/unit/test_creds_loading.py index 2d35349..c28e412 100644 --- a/tests/unit/test_creds_loading.py +++ b/tests/unit/test_creds_loading.py @@ -1,4 +1,4 @@ -from utils.credentials import ( +from discord_analyzer.utils.credentials import ( get_mongo_credentials, get_rabbit_mq_credentials, get_redis_credentials, diff --git a/tests/unit/test_mongo_singleton.py b/tests/unit/test_mongo_singleton.py index 9734592..bc976f3 100644 --- a/tests/unit/test_mongo_singleton.py +++ b/tests/unit/test_mongo_singleton.py @@ -1,7 +1,7 @@ import unittest from pymongo import MongoClient -from utils.mongo import MongoSingleton +from discord_analyzer.utils.mongo import MongoSingleton class TestMongoSingleton(unittest.TestCase): diff --git a/utils/transactions_ordering.py b/utils/transactions_ordering.py deleted file mode 100644 index d806736..0000000 --- a/utils/transactions_ordering.py +++ /dev/null @@ -1,61 +0,0 @@ -import numpy as np -from tc_messageBroker.rabbit_mq.status import Status - - -def sort_transactions(transactions: list): - """ - sort transactions by their order and status - the NOT_STARTED ones would be at the first of the list - and they are ordered by `order` property - - Parameters: - ------------ - transactions : list[ITransaction] - the list of transactions to order - - Returns: - --------- - transactions_ordered : ndarray(ITransaction) - the transactions ordered by status - the `NOT_STARTED` ones are the firsts - it is actually a numpy array for us to be able to - change the properties in deep memory - tx_not_started_count : int - the not started transactions count - """ - tx_not_started = [] - tx_other = [] - - for tx in transactions: - if tx.status == Status.NOT_STARTED: - tx_not_started.append(tx) - else: - tx_other.append(tx) - - tx_not_started_count = len(tx_not_started) - tx_not_started_sorted = sort_transactions_orderly(tx_not_started) - - transactions_ordered = list(tx_not_started_sorted) - transactions_ordered.extend(tx_other) - - return np.array(transactions_ordered), tx_not_started_count - - -def sort_transactions_orderly(transactions: list): - """ - sort transactions by their `order` property - - Parameters: - ------------ - transactions : list[ITransaction] - the list of transactions to order - - Returns: - --------- - transactions_orderly_sorted : list[ITransaction] - transactions sorted by their order - """ - orders = [tx.order for tx in transactions] - sorted_indices = np.argsort(orders) - - return np.array(transactions)[sorted_indices] From 007acca1085d32e31243a875513bcf384dc716b4 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Tue, 2 Jul 2024 15:38:32 +0330 Subject: [PATCH 10/23] feat: trying to run the publish_on_success test case first! --- ...pute_false.py => test_A_publish_on_success_recompute_false.py} | 0 ...ompute_true.py => test_A_publish_on_success_recompute_true.py} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename tests/integration/{test_publish_on_success_recompute_false.py => test_A_publish_on_success_recompute_false.py} (100%) rename tests/integration/{test_publish_on_success_recompute_true.py => test_A_publish_on_success_recompute_true.py} (100%) diff --git a/tests/integration/test_publish_on_success_recompute_false.py b/tests/integration/test_A_publish_on_success_recompute_false.py similarity index 100% rename from tests/integration/test_publish_on_success_recompute_false.py rename to tests/integration/test_A_publish_on_success_recompute_false.py diff --git a/tests/integration/test_publish_on_success_recompute_true.py b/tests/integration/test_A_publish_on_success_recompute_true.py similarity index 100% rename from tests/integration/test_publish_on_success_recompute_true.py rename to tests/integration/test_A_publish_on_success_recompute_true.py From f41a7529a8581e6b8eed6e12420601e6c55d1a5b Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Tue, 2 Jul 2024 16:05:22 +0330 Subject: [PATCH 11/23] fix: disabling test cases for testing purposes! the AMQP connection is being closed for no specific reason. --- tests/integration/test_A_publish_on_success_recompute_false.py | 2 ++ tests/integration/test_A_publish_on_success_recompute_true.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tests/integration/test_A_publish_on_success_recompute_false.py b/tests/integration/test_A_publish_on_success_recompute_false.py index ebc0979..e30d0ba 100644 --- a/tests/integration/test_A_publish_on_success_recompute_false.py +++ b/tests/integration/test_A_publish_on_success_recompute_false.py @@ -10,10 +10,12 @@ from bson.objectid import ObjectId from discord_analyzer.publish_on_success import publish_on_success from dotenv import load_dotenv +import pytest from .utils.analyzer_setup import launch_db_access +@pytest.mark.skip("Disable for testing purposes!") def test_publish_on_success_recompute_false_check_notification_choreographies(): """ test the publish on success functions diff --git a/tests/integration/test_A_publish_on_success_recompute_true.py b/tests/integration/test_A_publish_on_success_recompute_true.py index 13b5d70..b437482 100644 --- a/tests/integration/test_A_publish_on_success_recompute_true.py +++ b/tests/integration/test_A_publish_on_success_recompute_true.py @@ -10,10 +10,12 @@ from bson.objectid import ObjectId from discord_analyzer.publish_on_success import publish_on_success from dotenv import load_dotenv +import pytest from .utils.analyzer_setup import launch_db_access +@pytest.mark.skip("Disable for testing purposes!") def test_publish_on_success_recompute_true_check_notification_choreographies(): """ test the publish on success functions From 523518a0182e34bb56a3b36bc36bd7b7f0e6d464 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Tue, 2 Jul 2024 16:12:00 +0330 Subject: [PATCH 12/23] fix: rabbitMQ stay alive was 60s, singleton class is not required! --- discord_analyzer/utils/rabbitmq.py | 24 +++++++++---------- ...est_publish_on_success_recompute_false.py} | 2 -- ...test_publish_on_success_recompute_true.py} | 2 -- 3 files changed, 12 insertions(+), 16 deletions(-) rename tests/integration/{test_A_publish_on_success_recompute_false.py => test_publish_on_success_recompute_false.py} (99%) rename tests/integration/{test_A_publish_on_success_recompute_true.py => test_publish_on_success_recompute_true.py} (99%) diff --git a/discord_analyzer/utils/rabbitmq.py b/discord_analyzer/utils/rabbitmq.py index a33a84d..909d7e9 100644 --- a/discord_analyzer/utils/rabbitmq.py +++ b/discord_analyzer/utils/rabbitmq.py @@ -9,21 +9,21 @@ class RabbitMQSingleton: __instance = None def __init__(self): - if RabbitMQSingleton.__instance is not None: - raise Exception("This class is a singleton!") - else: - creds = get_rabbit_mq_credentials() - self.client = self.create_rabbitmq_client(creds) - RabbitMQSingleton.__instance = self + # if RabbitMQSingleton.__instance is not None: + # raise Exception("This class is a singleton!") + # else: + creds = get_rabbit_mq_credentials() + self.client = self.create_rabbitmq_client(creds) + RabbitMQSingleton.__instance = self @staticmethod def get_instance(): - if RabbitMQSingleton.__instance is None: - try: - RabbitMQSingleton() - logging.info("RabbitMQ broker Connected Successfully!") - except Exception as exp: - logging.error(f"RabbitMQ broker not connected! exp: {exp}") + # if RabbitMQSingleton.__instance is None: + try: + RabbitMQSingleton() + logging.info("RabbitMQ broker Connected Successfully!") + except Exception as exp: + logging.error(f"RabbitMQ broker not connected! exp: {exp}") return RabbitMQSingleton.__instance diff --git a/tests/integration/test_A_publish_on_success_recompute_false.py b/tests/integration/test_publish_on_success_recompute_false.py similarity index 99% rename from tests/integration/test_A_publish_on_success_recompute_false.py rename to tests/integration/test_publish_on_success_recompute_false.py index e30d0ba..ebc0979 100644 --- a/tests/integration/test_A_publish_on_success_recompute_false.py +++ b/tests/integration/test_publish_on_success_recompute_false.py @@ -10,12 +10,10 @@ from bson.objectid import ObjectId from discord_analyzer.publish_on_success import publish_on_success from dotenv import load_dotenv -import pytest from .utils.analyzer_setup import launch_db_access -@pytest.mark.skip("Disable for testing purposes!") def test_publish_on_success_recompute_false_check_notification_choreographies(): """ test the publish on success functions diff --git a/tests/integration/test_A_publish_on_success_recompute_true.py b/tests/integration/test_publish_on_success_recompute_true.py similarity index 99% rename from tests/integration/test_A_publish_on_success_recompute_true.py rename to tests/integration/test_publish_on_success_recompute_true.py index b437482..13b5d70 100644 --- a/tests/integration/test_A_publish_on_success_recompute_true.py +++ b/tests/integration/test_publish_on_success_recompute_true.py @@ -10,12 +10,10 @@ from bson.objectid import ObjectId from discord_analyzer.publish_on_success import publish_on_success from dotenv import load_dotenv -import pytest from .utils.analyzer_setup import launch_db_access -@pytest.mark.skip("Disable for testing purposes!") def test_publish_on_success_recompute_true_check_notification_choreographies(): """ test the publish on success functions From 95726bac29d424178191f78f10eceb8d2bb20bb6 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Tue, 2 Jul 2024 16:36:16 +0330 Subject: [PATCH 13/23] feat: updating rabbitmq as it is no longer singleton! --- automation/utils/automation_base.py | 4 ++-- discord_analyzer/publish_on_success.py | 4 ++-- discord_analyzer/utils/rabbitmq.py | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/automation/utils/automation_base.py b/automation/utils/automation_base.py index 8527340..48246ea 100644 --- a/automation/utils/automation_base.py +++ b/automation/utils/automation_base.py @@ -3,7 +3,7 @@ from uuid import uuid1 from discord_analyzer.utils.mongo import MongoSingleton -from discord_analyzer.utils.rabbitmq import RabbitMQSingleton +from discord_analyzer.utils.rabbitmq import RabbitMQAccess class AutomationBase: @@ -12,7 +12,7 @@ def __init__(self) -> None: utilities for automation workflow """ self.mongo_client = MongoSingleton.get_instance().get_client() - self.rabbitmq = RabbitMQSingleton.get_instance().get_client() + self.rabbitmq = RabbitMQAccess.get_instance().get_client() def _get_users_from_guildmembers( self, guild_id: str, user_ids: list[str], strategy: str = "ngu" diff --git a/discord_analyzer/publish_on_success.py b/discord_analyzer/publish_on_success.py index fd7d45c..3726599 100644 --- a/discord_analyzer/publish_on_success.py +++ b/discord_analyzer/publish_on_success.py @@ -8,7 +8,7 @@ get_platform_name, get_platform_community_owner ) -from discord_analyzer.utils.rabbitmq import RabbitMQSingleton +from discord_analyzer.utils.rabbitmq import RabbitMQAccess def publish_on_success(platform_id: str, recompute: bool) -> None: @@ -37,7 +37,7 @@ def publish_on_success(platform_id: str, recompute: bool) -> None: # working specifically for discord if platform_name == "discord" and recompute: logging.info(f"{msg}Sending job finished message & starting automation!") - rabbitmq = RabbitMQSingleton.get_instance().get_client() + rabbitmq = RabbitMQAccess.get_instance().get_client() message = ( "Your data import into TogetherCrew is complete! " diff --git a/discord_analyzer/utils/rabbitmq.py b/discord_analyzer/utils/rabbitmq.py index 909d7e9..978e767 100644 --- a/discord_analyzer/utils/rabbitmq.py +++ b/discord_analyzer/utils/rabbitmq.py @@ -5,27 +5,27 @@ from discord_analyzer.utils.credentials import get_rabbit_mq_credentials -class RabbitMQSingleton: +class RabbitMQAccess: __instance = None def __init__(self): - # if RabbitMQSingleton.__instance is not None: + # if RabbitMQAccess.__instance is not None: # raise Exception("This class is a singleton!") # else: creds = get_rabbit_mq_credentials() self.client = self.create_rabbitmq_client(creds) - RabbitMQSingleton.__instance = self + RabbitMQAccess.__instance = self @staticmethod def get_instance(): - # if RabbitMQSingleton.__instance is None: + # if RabbitMQAccess.__instance is None: try: - RabbitMQSingleton() + RabbitMQAccess() logging.info("RabbitMQ broker Connected Successfully!") except Exception as exp: logging.error(f"RabbitMQ broker not connected! exp: {exp}") - return RabbitMQSingleton.__instance + return RabbitMQAccess.__instance def get_client(self): return self.client From af726058252bc308f7b6cb8c34f28136e959cfd3 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Tue, 2 Jul 2024 16:36:53 +0330 Subject: [PATCH 14/23] feat: adding library publishing workflow! --- .github/workflows/production.yml | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml index a1be27b..de44b12 100644 --- a/.github/workflows/production.yml +++ b/.github/workflows/production.yml @@ -9,4 +9,29 @@ jobs: ci: uses: TogetherCrew/operations/.github/workflows/ci.yml@main secrets: - CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} \ No newline at end of file + CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} + package_publish: + needs: ci + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.10"] + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip setuptools wheel twine + - name: Build package + run: | + python setup.py sdist bdist_wheel + - name: Publish package to PyPI + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} + run: | + python -m twine upload dist/* \ No newline at end of file From 2c367cb1c43dc59df7ee36b2ff28c651d91ac837 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Tue, 2 Jul 2024 16:43:21 +0330 Subject: [PATCH 15/23] feat: moved automation into discord_analyzer package! --- {automation => discord_analyzer/automation}/__init__.py | 0 .../automation}/automation_workflow.py | 4 ++-- {automation => discord_analyzer/automation}/utils/__init__.py | 0 .../automation}/utils/automation_base.py | 0 .../automation}/utils/interfaces.py | 0 {automation => discord_analyzer/automation}/utils/model.py | 0 discord_analyzer/publish_on_success.py | 2 +- tests/integration/test_automation_base_create_manual_saga.py | 2 +- ...ion_base_get_users_from_memberactivities_empty_database.py | 2 +- ...on_base_get_users_from_memberactivities_filled_database.py | 2 +- .../test_automation_base_prepare_names_globalname.py | 2 +- tests/integration/test_automation_base_prepare_names_ngu.py | 2 +- .../test_automation_base_prepare_names_nickname.py | 2 +- .../test_automation_base_prepare_names_usernames.py | 2 +- tests/integration/test_automation_db_load_from_db.py | 2 +- tests/integration/test_automation_db_save_to_db.py | 4 ++-- ...utomation_fire_messages_mongo_saga_message_ngu_strategy.py | 4 ++-- ...tion_fire_messages_mongo_saga_message_nickname_strategy.py | 4 ++-- ...utomation_fire_messages_mongo_saga_message_no_handlebar.py | 4 ++-- ...tion_fire_messages_mongo_saga_message_username_strategy.py | 4 ++-- tests/integration/test_publish_on_success_recompute_false.py | 2 +- tests/integration/test_publish_on_success_recompute_true.py | 2 +- tests/unit/test_automation_class.py | 2 +- tests/unit/test_automation_get_handler_type.py | 2 +- tests/unit/test_automation_trigger_action_report.py | 2 +- tests/unit/test_compile_message.py | 2 +- tests/unit/test_engagement_notifier_subtract_users.py | 2 +- 27 files changed, 28 insertions(+), 28 deletions(-) rename {automation => discord_analyzer/automation}/__init__.py (100%) rename {automation => discord_analyzer/automation}/automation_workflow.py (98%) rename {automation => discord_analyzer/automation}/utils/__init__.py (100%) rename {automation => discord_analyzer/automation}/utils/automation_base.py (100%) rename {automation => discord_analyzer/automation}/utils/interfaces.py (100%) rename {automation => discord_analyzer/automation}/utils/model.py (100%) diff --git a/automation/__init__.py b/discord_analyzer/automation/__init__.py similarity index 100% rename from automation/__init__.py rename to discord_analyzer/automation/__init__.py diff --git a/automation/automation_workflow.py b/discord_analyzer/automation/automation_workflow.py similarity index 98% rename from automation/automation_workflow.py rename to discord_analyzer/automation/automation_workflow.py index 1da733d..f4aed5b 100644 --- a/automation/automation_workflow.py +++ b/discord_analyzer/automation/automation_workflow.py @@ -1,8 +1,8 @@ import logging from typing import Any -from automation.utils.automation_base import AutomationBase -from automation.utils.model import AutomationDB +from discord_analyzer.automation.utils.automation_base import AutomationBase +from discord_analyzer.automation.utils.model import AutomationDB from pybars import Compiler from tc_messageBroker.rabbit_mq.event import Event from tc_messageBroker.rabbit_mq.queue import Queue diff --git a/automation/utils/__init__.py b/discord_analyzer/automation/utils/__init__.py similarity index 100% rename from automation/utils/__init__.py rename to discord_analyzer/automation/utils/__init__.py diff --git a/automation/utils/automation_base.py b/discord_analyzer/automation/utils/automation_base.py similarity index 100% rename from automation/utils/automation_base.py rename to discord_analyzer/automation/utils/automation_base.py diff --git a/automation/utils/interfaces.py b/discord_analyzer/automation/utils/interfaces.py similarity index 100% rename from automation/utils/interfaces.py rename to discord_analyzer/automation/utils/interfaces.py diff --git a/automation/utils/model.py b/discord_analyzer/automation/utils/model.py similarity index 100% rename from automation/utils/model.py rename to discord_analyzer/automation/utils/model.py diff --git a/discord_analyzer/publish_on_success.py b/discord_analyzer/publish_on_success.py index 3726599..7ee9a5a 100644 --- a/discord_analyzer/publish_on_success.py +++ b/discord_analyzer/publish_on_success.py @@ -1,6 +1,6 @@ import logging -from automation.automation_workflow import AutomationWorkflow +from discord_analyzer.automation.automation_workflow import AutomationWorkflow from tc_messageBroker.rabbit_mq.event import Event from tc_messageBroker.rabbit_mq.queue import Queue from discord_analyzer.utils.get_guild_utils import ( diff --git a/tests/integration/test_automation_base_create_manual_saga.py b/tests/integration/test_automation_base_create_manual_saga.py index 72f1c6b..8b7230d 100644 --- a/tests/integration/test_automation_base_create_manual_saga.py +++ b/tests/integration/test_automation_base_create_manual_saga.py @@ -1,6 +1,6 @@ import unittest -from automation.utils.automation_base import AutomationBase +from discord_analyzer.automation.utils.automation_base import AutomationBase from .utils.analyzer_setup import launch_db_access diff --git a/tests/integration/test_automation_base_get_users_from_memberactivities_empty_database.py b/tests/integration/test_automation_base_get_users_from_memberactivities_empty_database.py index a48502b..7560d5a 100644 --- a/tests/integration/test_automation_base_get_users_from_memberactivities_empty_database.py +++ b/tests/integration/test_automation_base_get_users_from_memberactivities_empty_database.py @@ -1,6 +1,6 @@ from datetime import datetime, timedelta -from automation.utils.automation_base import AutomationBase +from discord_analyzer.automation.utils.automation_base import AutomationBase from .utils.analyzer_setup import launch_db_access diff --git a/tests/integration/test_automation_base_get_users_from_memberactivities_filled_database.py b/tests/integration/test_automation_base_get_users_from_memberactivities_filled_database.py index 0096062..202d731 100644 --- a/tests/integration/test_automation_base_get_users_from_memberactivities_filled_database.py +++ b/tests/integration/test_automation_base_get_users_from_memberactivities_filled_database.py @@ -1,6 +1,6 @@ from datetime import datetime, timedelta -from automation.utils.automation_base import AutomationBase +from discord_analyzer.automation.utils.automation_base import AutomationBase from .utils.analyzer_setup import launch_db_access diff --git a/tests/integration/test_automation_base_prepare_names_globalname.py b/tests/integration/test_automation_base_prepare_names_globalname.py index 8623d04..904d58a 100644 --- a/tests/integration/test_automation_base_prepare_names_globalname.py +++ b/tests/integration/test_automation_base_prepare_names_globalname.py @@ -1,6 +1,6 @@ from datetime import datetime, timedelta -from automation.utils.automation_base import AutomationBase +from discord_analyzer.automation.utils.automation_base import AutomationBase from .utils.analyzer_setup import launch_db_access diff --git a/tests/integration/test_automation_base_prepare_names_ngu.py b/tests/integration/test_automation_base_prepare_names_ngu.py index 4166b37..69783a5 100644 --- a/tests/integration/test_automation_base_prepare_names_ngu.py +++ b/tests/integration/test_automation_base_prepare_names_ngu.py @@ -1,6 +1,6 @@ from datetime import datetime, timedelta -from automation.utils.automation_base import AutomationBase +from discord_analyzer.automation.utils.automation_base import AutomationBase from .utils.analyzer_setup import launch_db_access diff --git a/tests/integration/test_automation_base_prepare_names_nickname.py b/tests/integration/test_automation_base_prepare_names_nickname.py index 6bdfbef..f12bfe3 100644 --- a/tests/integration/test_automation_base_prepare_names_nickname.py +++ b/tests/integration/test_automation_base_prepare_names_nickname.py @@ -1,6 +1,6 @@ from datetime import datetime, timedelta -from automation.utils.automation_base import AutomationBase +from discord_analyzer.automation.utils.automation_base import AutomationBase from .utils.analyzer_setup import launch_db_access diff --git a/tests/integration/test_automation_base_prepare_names_usernames.py b/tests/integration/test_automation_base_prepare_names_usernames.py index 97c684d..53e2403 100644 --- a/tests/integration/test_automation_base_prepare_names_usernames.py +++ b/tests/integration/test_automation_base_prepare_names_usernames.py @@ -1,6 +1,6 @@ from datetime import datetime, timedelta -from automation.utils.automation_base import AutomationBase +from discord_analyzer.automation.utils.automation_base import AutomationBase from .utils.analyzer_setup import launch_db_access diff --git a/tests/integration/test_automation_db_load_from_db.py b/tests/integration/test_automation_db_load_from_db.py index 89a19b7..c0a2886 100644 --- a/tests/integration/test_automation_db_load_from_db.py +++ b/tests/integration/test_automation_db_load_from_db.py @@ -2,7 +2,7 @@ import unittest from datetime import datetime, timedelta -from automation.utils.model import AutomationDB +from discord_analyzer.automation.utils.model import AutomationDB from dotenv import load_dotenv from discord_analyzer.utils.mongo import MongoSingleton diff --git a/tests/integration/test_automation_db_save_to_db.py b/tests/integration/test_automation_db_save_to_db.py index 7a62ccc..25d41e8 100644 --- a/tests/integration/test_automation_db_save_to_db.py +++ b/tests/integration/test_automation_db_save_to_db.py @@ -2,8 +2,8 @@ import unittest from datetime import datetime, timezone -from automation.utils.interfaces import Automation -from automation.utils.model import AutomationDB +from discord_analyzer.automation.utils.interfaces import Automation +from discord_analyzer.automation.utils.model import AutomationDB from dotenv import load_dotenv from discord_analyzer.utils.mongo import MongoSingleton diff --git a/tests/integration/test_automation_fire_messages_mongo_saga_message_ngu_strategy.py b/tests/integration/test_automation_fire_messages_mongo_saga_message_ngu_strategy.py index dbbb19d..8bec35c 100644 --- a/tests/integration/test_automation_fire_messages_mongo_saga_message_ngu_strategy.py +++ b/tests/integration/test_automation_fire_messages_mongo_saga_message_ngu_strategy.py @@ -1,7 +1,7 @@ from datetime import datetime, timedelta -from automation.automation_workflow import AutomationWorkflow -from automation.utils.interfaces import ( +from discord_analyzer.automation.automation_workflow import AutomationWorkflow +from discord_analyzer.automation.utils.interfaces import ( Automation, AutomationAction, AutomationReport, diff --git a/tests/integration/test_automation_fire_messages_mongo_saga_message_nickname_strategy.py b/tests/integration/test_automation_fire_messages_mongo_saga_message_nickname_strategy.py index e834f7c..0908295 100644 --- a/tests/integration/test_automation_fire_messages_mongo_saga_message_nickname_strategy.py +++ b/tests/integration/test_automation_fire_messages_mongo_saga_message_nickname_strategy.py @@ -1,7 +1,7 @@ from datetime import datetime, timedelta -from automation.automation_workflow import AutomationWorkflow -from automation.utils.interfaces import ( +from discord_analyzer.automation.automation_workflow import AutomationWorkflow +from discord_analyzer.automation.utils.interfaces import ( Automation, AutomationAction, AutomationReport, diff --git a/tests/integration/test_automation_fire_messages_mongo_saga_message_no_handlebar.py b/tests/integration/test_automation_fire_messages_mongo_saga_message_no_handlebar.py index 85dc0ac..65120fb 100644 --- a/tests/integration/test_automation_fire_messages_mongo_saga_message_no_handlebar.py +++ b/tests/integration/test_automation_fire_messages_mongo_saga_message_no_handlebar.py @@ -1,7 +1,7 @@ from datetime import datetime, timedelta -from automation.automation_workflow import AutomationWorkflow -from automation.utils.interfaces import ( +from discord_analyzer.automation.automation_workflow import AutomationWorkflow +from discord_analyzer.automation.utils.interfaces import ( Automation, AutomationAction, AutomationReport, diff --git a/tests/integration/test_automation_fire_messages_mongo_saga_message_username_strategy.py b/tests/integration/test_automation_fire_messages_mongo_saga_message_username_strategy.py index 8cf791d..e3712c2 100644 --- a/tests/integration/test_automation_fire_messages_mongo_saga_message_username_strategy.py +++ b/tests/integration/test_automation_fire_messages_mongo_saga_message_username_strategy.py @@ -1,7 +1,7 @@ from datetime import datetime, timedelta -from automation.automation_workflow import AutomationWorkflow -from automation.utils.interfaces import ( +from discord_analyzer.automation.automation_workflow import AutomationWorkflow +from discord_analyzer.automation.utils.interfaces import ( Automation, AutomationAction, AutomationReport, diff --git a/tests/integration/test_publish_on_success_recompute_false.py b/tests/integration/test_publish_on_success_recompute_false.py index ebc0979..c82e89e 100644 --- a/tests/integration/test_publish_on_success_recompute_false.py +++ b/tests/integration/test_publish_on_success_recompute_false.py @@ -1,7 +1,7 @@ import os from datetime import datetime, timedelta -from automation.utils.interfaces import ( +from discord_analyzer.automation.utils.interfaces import ( Automation, AutomationAction, AutomationReport, diff --git a/tests/integration/test_publish_on_success_recompute_true.py b/tests/integration/test_publish_on_success_recompute_true.py index 13b5d70..e0bb8cf 100644 --- a/tests/integration/test_publish_on_success_recompute_true.py +++ b/tests/integration/test_publish_on_success_recompute_true.py @@ -1,7 +1,7 @@ import os from datetime import datetime, timedelta -from automation.utils.interfaces import ( +from discord_analyzer.automation.utils.interfaces import ( Automation, AutomationAction, AutomationReport, diff --git a/tests/unit/test_automation_class.py b/tests/unit/test_automation_class.py index b7e02d4..9243332 100644 --- a/tests/unit/test_automation_class.py +++ b/tests/unit/test_automation_class.py @@ -1,7 +1,7 @@ import unittest from datetime import datetime -from automation.utils.interfaces import ( +from discord_analyzer.automation.utils.interfaces import ( Automation, AutomationAction, AutomationReport, diff --git a/tests/unit/test_automation_get_handler_type.py b/tests/unit/test_automation_get_handler_type.py index ccbd8bd..17eaba0 100644 --- a/tests/unit/test_automation_get_handler_type.py +++ b/tests/unit/test_automation_get_handler_type.py @@ -1,6 +1,6 @@ import unittest -from automation.automation_workflow import AutomationWorkflow +from discord_analyzer.automation.automation_workflow import AutomationWorkflow class TestGetHandlerType(unittest.TestCase): diff --git a/tests/unit/test_automation_trigger_action_report.py b/tests/unit/test_automation_trigger_action_report.py index 4f2ec9f..e8f808a 100644 --- a/tests/unit/test_automation_trigger_action_report.py +++ b/tests/unit/test_automation_trigger_action_report.py @@ -1,6 +1,6 @@ import unittest -from automation.utils.interfaces import ( +from discord_analyzer.automation.utils.interfaces import ( AutomationAction, AutomationReport, AutomationTrigger, diff --git a/tests/unit/test_compile_message.py b/tests/unit/test_compile_message.py index 57dae41..4601501 100644 --- a/tests/unit/test_compile_message.py +++ b/tests/unit/test_compile_message.py @@ -1,6 +1,6 @@ import unittest -from automation.automation_workflow import AutomationWorkflow +from discord_analyzer.automation.automation_workflow import AutomationWorkflow class CompileTemplateMessage(unittest.TestCase): diff --git a/tests/unit/test_engagement_notifier_subtract_users.py b/tests/unit/test_engagement_notifier_subtract_users.py index 8140903..d4376f9 100644 --- a/tests/unit/test_engagement_notifier_subtract_users.py +++ b/tests/unit/test_engagement_notifier_subtract_users.py @@ -1,4 +1,4 @@ -from automation.utils.automation_base import AutomationBase +from discord_analyzer.automation.utils.automation_base import AutomationBase def test_subtract_users_empty_data(): From a5713de8926425b527dd7ca591694b9f933df30c Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Tue, 2 Jul 2024 16:47:34 +0330 Subject: [PATCH 16/23] feat: update discord_analyzer package name to tc_analyzer_lib! --- .../DB_operations/__init__.py | 0 .../DB_operations/mongo_neo4j_ops.py | 6 +++--- .../DB_operations/mongodb_access.py | 2 +- .../DB_operations/mongodb_interaction.py | 2 +- .../DB_operations/network_graph.py | 2 +- .../__init__.py | 0 .../algorithms/__init__.py | 0 .../analytics_interactions_script.py | 0 .../compute_interaction_matrix_discord.py | 2 +- .../algorithms/compute_member_activity.py | 10 +++++----- .../algorithms/member_activity_history.py | 4 ++-- .../algorithms/neo4j_analysis/__init__.py | 0 .../neo4j_analysis/analyzer_node_stats.py | 4 ++-- .../algorithms/neo4j_analysis/centrality.py | 4 ++-- .../local_clustering_coefficient.py | 4 ++-- .../algorithms/neo4j_analysis/louvain.py | 4 ++-- .../neo4j_analysis/utils/__init__.py | 0 .../neo4j_analysis/utils/neo4j_metrics.py | 0 .../neo4j_analysis/utils/projection_utils.py | 2 +- .../algorithms/utils/__init__.py | 0 .../algorithms/utils/activity.py | 0 .../utils/compute_interaction_mtx_utils.py | 2 +- .../utils/member_activity_history_utils.py | 2 +- .../algorithms/utils/member_activity_utils.py | 6 +++--- .../automation/__init__.py | 0 .../automation/automation_workflow.py | 4 ++-- .../automation/utils/__init__.py | 0 .../automation/utils/automation_base.py | 4 ++-- .../automation/utils/interfaces.py | 0 .../automation/utils/model.py | 4 ++-- .../metrics/__init__.py | 0 .../metrics/analyzer_memberactivities.py | 12 ++++++------ .../metrics/heatmaps/__init__.py | 0 .../metrics/heatmaps/analytics_hourly.py | 2 +- .../metrics/heatmaps/analytics_raw.py | 4 ++-- .../metrics/heatmaps/heatmaps.py | 8 ++++---- .../metrics/heatmaps/heatmaps_utils.py | 2 +- .../metrics/memberactivity_utils.py | 2 +- .../metrics/neo4j_analytics.py | 10 +++++----- .../metrics/utils/__init__.py | 0 .../metrics/utils/analyzer_db_manager.py | 2 +- .../metrics/utils/platform.py | 2 +- .../models/BaseModel.py | 0 .../models/GuildsRnDaoModel.py | 2 +- .../models/HeatMapModel.py | 2 +- .../models/MemberActivityModel.py | 2 +- .../models/RawInfoModel.py | 2 +- .../models/__init__.py | 0 .../models/raw_member_activities.py | 4 ++-- .../publish_on_success.py | 6 +++--- .../schemas/__init__.py | 0 .../schemas/activity_type.py | 0 .../schemas/graph.py | 0 .../schemas/hourly_analytics.py | 0 .../schemas/platform_configs/__init__.py | 0 .../schemas/platform_configs/config_base.py | 2 +- .../schemas/platform_configs/discord.py | 4 ++-- .../schemas/raw_analytics.py | 0 .../schemas/raw_analytics_item.py | 0 .../tc_analyzer.py | 18 +++++++++--------- .../utils/__init__.py | 0 .../utils/credentials.py | 0 .../utils/get_automation_env.py | 0 .../utils/get_guild_utils.py | 2 +- .../utils/mongo.py | 2 +- .../utils/rabbitmq.py | 2 +- .../utils/redis.py | 2 +- .../test_analyzer_platform_fetch_period.py | 4 ++-- .../test_analyzer_platform_fetch_resources.py | 4 ++-- .../test_analyzer_utils_platform.py | 4 ++-- .../test_analyzer_utils_platform_parameters.py | 4 ++-- .../test_assess_engagement_mention.py | 10 +++++----- .../test_assess_engagement_reactions.py | 10 +++++----- .../test_assess_engagement_replies.py | 10 +++++----- .../test_automation_base_create_manual_saga.py | 2 +- ...ers_from_memberactivities_empty_database.py | 2 +- ...rs_from_memberactivities_filled_database.py | 2 +- ...automation_base_prepare_names_globalname.py | 2 +- .../test_automation_base_prepare_names_ngu.py | 2 +- ...t_automation_base_prepare_names_nickname.py | 2 +- ..._automation_base_prepare_names_usernames.py | 2 +- .../test_automation_db_load_from_db.py | 4 ++-- .../test_automation_db_save_to_db.py | 6 +++--- ...messages_mongo_saga_message_ngu_strategy.py | 4 ++-- ...ges_mongo_saga_message_nickname_strategy.py | 4 ++-- ...messages_mongo_saga_message_no_handlebar.py | 4 ++-- ...ges_mongo_saga_message_username_strategy.py | 4 ++-- .../integration/test_decentralization_score.py | 4 ++-- .../test_degree_centrality_multiple_guilds.py | 4 ++-- ...rality_multiple_guilds_preserve_parallel.py | 4 ++-- ..._degree_centrality_parallel_preservation.py | 4 ++-- .../test_discord_heatmaps_config.py | 4 ++-- tests/integration/test_fragmentation_score.py | 4 ++-- .../test_fragmentation_score_exclude_past.py | 4 ++-- .../test_fragmentation_score_from_start.py | 4 ++-- .../test_fragmentation_score_rescaling.py | 4 ++-- .../test_get_guild_community_ids.py | 4 ++-- tests/integration/test_get_guild_owner.py | 4 ++-- .../integration/test_get_guild_platform_id.py | 4 ++-- .../test_get_past_7_days_heatmaps.py | 2 +- tests/integration/test_heatmaps_analytics.py | 6 +++--- .../test_heatmaps_analytics_base.py | 4 ++-- ...test_heatmaps_analytics_different_source.py | 6 +++--- ...test_heatmaps_analytics_hourly_no_filter.py | 4 ++-- .../integration/test_heatmaps_analytics_raw.py | 6 +++--- ...eatmaps_hourly_analytics_actions_vectors.py | 4 ++-- ...aps_hourly_analytics_interaction_vectors.py | 4 ++-- .../test_heatmaps_hourly_lone_message.py | 6 +++--- .../test_heatmaps_hourly_mentions.py | 6 +++--- .../test_heatmaps_process_hourly_single_day.py | 6 +++--- .../test_heatmaps_process_raw_analytics.py | 6 +++--- tests/integration/test_heatmaps_reactions.py | 6 +++--- tests/integration/test_heatmaps_replier.py | 6 +++--- tests/integration/test_heatmaps_thread_msg.py | 6 +++--- tests/integration/test_heatmaps_utils.py | 4 ++-- .../integration/test_interacted_in_deletion.py | 4 ++-- tests/integration/test_lcc_all_connected.py | 4 ++-- .../test_lcc_partially_connected.py | 4 ++-- .../test_louvain_algorithm_computation.py | 4 ++-- ...est_louvain_algorithm_get_computed_dates.py | 4 ++-- .../integration/test_member_activity_utils.py | 2 +- .../integration/test_neo4j_compute_metrics.py | 4 ++-- .../test_neo4j_compute_metrics_from_start.py | 4 ++-- ...st_neo4j_projection_utils_computed_dates.py | 4 ++-- .../integration/test_network_graph_creation.py | 2 +- tests/integration/test_node_stats.py | 4 ++-- .../integration/test_platforms_base_config.py | 4 ++-- .../test_publish_on_success_recompute_false.py | 4 ++-- .../test_publish_on_success_recompute_true.py | 4 ++-- .../test_rawinfo_webhook_fetching.py | 4 ++-- tests/integration/test_service_connection.py | 2 +- tests/integration/utils/analyzer_setup.py | 2 +- tests/integration/utils/mock_graph.py | 2 +- tests/integration/utils/setup_platform.py | 4 ++-- ...alyzer_heatmaps_compute_iteration_counts.py | 4 ++-- tests/unit/test_automation_class.py | 2 +- tests/unit/test_automation_get_handler_type.py | 2 +- .../test_automation_trigger_action_report.py | 2 +- tests/unit/test_compile_message.py | 2 +- tests/unit/test_converting_to_dict.py | 2 +- tests/unit/test_creds_loading.py | 2 +- .../test_engagement_notifier_subtract_users.py | 2 +- tests/unit/test_generate_interaction_mtx.py | 4 ++-- .../test_generate_interaction_mtx_mention.py | 4 ++-- .../test_generate_interaction_mtx_reaction.py | 4 ++-- .../test_generate_interaction_mtx_reply.py | 4 ++-- tests/unit/test_get_timestamp.py | 4 ++-- tests/unit/test_graph_schema.py | 2 +- ..._heatmaps_analytics_base_process_vectors.py | 2 +- tests/unit/test_member_activity_utils.py | 2 +- tests/unit/test_mongo_singleton.py | 2 +- tests/unit/test_per_account_interaction.py | 2 +- tests/unit/test_prepare_results_per_acc.py | 2 +- .../unit/test_process_non_reaction_heatmaps.py | 2 +- tests/unit/test_schema_hourly_analytics.py | 2 +- tests/unit/test_schema_raw_analytics.py | 4 ++-- 156 files changed, 251 insertions(+), 251 deletions(-) rename {discord_analyzer => tc_analyzer_lib}/DB_operations/__init__.py (100%) rename {discord_analyzer => tc_analyzer_lib}/DB_operations/mongo_neo4j_ops.py (96%) rename {discord_analyzer => tc_analyzer_lib}/DB_operations/mongodb_access.py (98%) rename {discord_analyzer => tc_analyzer_lib}/DB_operations/mongodb_interaction.py (99%) rename {discord_analyzer => tc_analyzer_lib}/DB_operations/network_graph.py (99%) rename {discord_analyzer => tc_analyzer_lib}/__init__.py (100%) rename {discord_analyzer => tc_analyzer_lib}/algorithms/__init__.py (100%) rename {discord_analyzer => tc_analyzer_lib}/algorithms/analytics_interactions_script.py (100%) rename {discord_analyzer => tc_analyzer_lib}/algorithms/compute_interaction_matrix_discord.py (95%) rename {discord_analyzer => tc_analyzer_lib}/algorithms/compute_member_activity.py (94%) rename {discord_analyzer => tc_analyzer_lib}/algorithms/member_activity_history.py (96%) rename {discord_analyzer => tc_analyzer_lib}/algorithms/neo4j_analysis/__init__.py (100%) rename {discord_analyzer => tc_analyzer_lib}/algorithms/neo4j_analysis/analyzer_node_stats.py (98%) rename {discord_analyzer => tc_analyzer_lib}/algorithms/neo4j_analysis/centrality.py (99%) rename {discord_analyzer => tc_analyzer_lib}/algorithms/neo4j_analysis/local_clustering_coefficient.py (97%) rename {discord_analyzer => tc_analyzer_lib}/algorithms/neo4j_analysis/louvain.py (97%) rename {discord_analyzer => tc_analyzer_lib}/algorithms/neo4j_analysis/utils/__init__.py (100%) rename {discord_analyzer => tc_analyzer_lib}/algorithms/neo4j_analysis/utils/neo4j_metrics.py (100%) rename {discord_analyzer => tc_analyzer_lib}/algorithms/neo4j_analysis/utils/projection_utils.py (99%) rename {discord_analyzer => tc_analyzer_lib}/algorithms/utils/__init__.py (100%) rename {discord_analyzer => tc_analyzer_lib}/algorithms/utils/activity.py (100%) rename {discord_analyzer => tc_analyzer_lib}/algorithms/utils/compute_interaction_mtx_utils.py (97%) rename {discord_analyzer => tc_analyzer_lib}/algorithms/utils/member_activity_history_utils.py (99%) rename {discord_analyzer => tc_analyzer_lib}/algorithms/utils/member_activity_utils.py (97%) rename {discord_analyzer => tc_analyzer_lib}/automation/__init__.py (100%) rename {discord_analyzer => tc_analyzer_lib}/automation/automation_workflow.py (98%) rename {discord_analyzer => tc_analyzer_lib}/automation/utils/__init__.py (100%) rename {discord_analyzer => tc_analyzer_lib}/automation/utils/automation_base.py (98%) rename {discord_analyzer => tc_analyzer_lib}/automation/utils/interfaces.py (100%) rename {discord_analyzer => tc_analyzer_lib}/automation/utils/model.py (93%) rename {discord_analyzer => tc_analyzer_lib}/metrics/__init__.py (100%) rename {discord_analyzer => tc_analyzer_lib}/metrics/analyzer_memberactivities.py (92%) rename {discord_analyzer => tc_analyzer_lib}/metrics/heatmaps/__init__.py (100%) rename {discord_analyzer => tc_analyzer_lib}/metrics/heatmaps/analytics_hourly.py (99%) rename {discord_analyzer => tc_analyzer_lib}/metrics/heatmaps/analytics_raw.py (98%) rename {discord_analyzer => tc_analyzer_lib}/metrics/heatmaps/heatmaps.py (96%) rename {discord_analyzer => tc_analyzer_lib}/metrics/heatmaps/heatmaps_utils.py (97%) rename {discord_analyzer => tc_analyzer_lib}/metrics/memberactivity_utils.py (98%) rename {discord_analyzer => tc_analyzer_lib}/metrics/neo4j_analytics.py (94%) rename {discord_analyzer => tc_analyzer_lib}/metrics/utils/__init__.py (100%) rename {discord_analyzer => tc_analyzer_lib}/metrics/utils/analyzer_db_manager.py (81%) rename {discord_analyzer => tc_analyzer_lib}/metrics/utils/platform.py (98%) rename {discord_analyzer => tc_analyzer_lib}/models/BaseModel.py (100%) rename {discord_analyzer => tc_analyzer_lib}/models/GuildsRnDaoModel.py (97%) rename {discord_analyzer => tc_analyzer_lib}/models/HeatMapModel.py (97%) rename {discord_analyzer => tc_analyzer_lib}/models/MemberActivityModel.py (96%) rename {discord_analyzer => tc_analyzer_lib}/models/RawInfoModel.py (97%) rename {discord_analyzer => tc_analyzer_lib}/models/__init__.py (100%) rename {discord_analyzer => tc_analyzer_lib}/models/raw_member_activities.py (97%) rename {discord_analyzer => tc_analyzer_lib}/publish_on_success.py (92%) rename {discord_analyzer => tc_analyzer_lib}/schemas/__init__.py (100%) rename {discord_analyzer => tc_analyzer_lib}/schemas/activity_type.py (100%) rename {discord_analyzer => tc_analyzer_lib}/schemas/graph.py (100%) rename {discord_analyzer => tc_analyzer_lib}/schemas/hourly_analytics.py (100%) rename {discord_analyzer => tc_analyzer_lib}/schemas/platform_configs/__init__.py (100%) rename {discord_analyzer => tc_analyzer_lib}/schemas/platform_configs/config_base.py (94%) rename {discord_analyzer => tc_analyzer_lib}/schemas/platform_configs/discord.py (96%) rename {discord_analyzer => tc_analyzer_lib}/schemas/raw_analytics.py (100%) rename {discord_analyzer => tc_analyzer_lib}/schemas/raw_analytics_item.py (100%) rename {discord_analyzer => tc_analyzer_lib}/tc_analyzer.py (91%) rename {discord_analyzer => tc_analyzer_lib}/utils/__init__.py (100%) rename {discord_analyzer => tc_analyzer_lib}/utils/credentials.py (100%) rename {discord_analyzer => tc_analyzer_lib}/utils/get_automation_env.py (100%) rename {discord_analyzer => tc_analyzer_lib}/utils/get_guild_utils.py (98%) rename {discord_analyzer => tc_analyzer_lib}/utils/mongo.py (93%) rename {discord_analyzer => tc_analyzer_lib}/utils/rabbitmq.py (94%) rename {discord_analyzer => tc_analyzer_lib}/utils/redis.py (94%) diff --git a/discord_analyzer/DB_operations/__init__.py b/tc_analyzer_lib/DB_operations/__init__.py similarity index 100% rename from discord_analyzer/DB_operations/__init__.py rename to tc_analyzer_lib/DB_operations/__init__.py diff --git a/discord_analyzer/DB_operations/mongo_neo4j_ops.py b/tc_analyzer_lib/DB_operations/mongo_neo4j_ops.py similarity index 96% rename from discord_analyzer/DB_operations/mongo_neo4j_ops.py rename to tc_analyzer_lib/DB_operations/mongo_neo4j_ops.py index 2232506..8876366 100644 --- a/discord_analyzer/DB_operations/mongo_neo4j_ops.py +++ b/tc_analyzer_lib/DB_operations/mongo_neo4j_ops.py @@ -1,9 +1,9 @@ import logging -from discord_analyzer.DB_operations.mongodb_interaction import MongoDBOps -from discord_analyzer.DB_operations.network_graph import NetworkGraph +from tc_analyzer_lib.DB_operations.mongodb_interaction import MongoDBOps +from tc_analyzer_lib.DB_operations.network_graph import NetworkGraph from tc_neo4j_lib.neo4j_ops import Neo4jOps, Query -from discord_analyzer.schemas import GraphSchema +from tc_analyzer_lib.schemas import GraphSchema class MongoNeo4jDB: diff --git a/discord_analyzer/DB_operations/mongodb_access.py b/tc_analyzer_lib/DB_operations/mongodb_access.py similarity index 98% rename from discord_analyzer/DB_operations/mongodb_access.py rename to tc_analyzer_lib/DB_operations/mongodb_access.py index afab4b4..4d1b440 100644 --- a/discord_analyzer/DB_operations/mongodb_access.py +++ b/tc_analyzer_lib/DB_operations/mongodb_access.py @@ -1,4 +1,4 @@ -from discord_analyzer.utils.mongo import MongoSingleton +from tc_analyzer_lib.utils.mongo import MongoSingleton class DB_access: diff --git a/discord_analyzer/DB_operations/mongodb_interaction.py b/tc_analyzer_lib/DB_operations/mongodb_interaction.py similarity index 99% rename from discord_analyzer/DB_operations/mongodb_interaction.py rename to tc_analyzer_lib/DB_operations/mongodb_interaction.py index f0d9ffe..659bfc8 100644 --- a/discord_analyzer/DB_operations/mongodb_interaction.py +++ b/tc_analyzer_lib/DB_operations/mongodb_interaction.py @@ -1,6 +1,6 @@ import logging -from discord_analyzer.DB_operations.mongodb_access import DB_access +from tc_analyzer_lib.DB_operations.mongodb_access import DB_access from pymongo.read_concern import ReadConcern from pymongo.write_concern import WriteConcern diff --git a/discord_analyzer/DB_operations/network_graph.py b/tc_analyzer_lib/DB_operations/network_graph.py similarity index 99% rename from discord_analyzer/DB_operations/network_graph.py rename to tc_analyzer_lib/DB_operations/network_graph.py index 11e5f62..6c118b0 100644 --- a/discord_analyzer/DB_operations/network_graph.py +++ b/tc_analyzer_lib/DB_operations/network_graph.py @@ -4,7 +4,7 @@ import networkx from tc_neo4j_lib import Query -from discord_analyzer.schemas import GraphSchema +from tc_analyzer_lib.schemas import GraphSchema class NetworkGraph: diff --git a/discord_analyzer/__init__.py b/tc_analyzer_lib/__init__.py similarity index 100% rename from discord_analyzer/__init__.py rename to tc_analyzer_lib/__init__.py diff --git a/discord_analyzer/algorithms/__init__.py b/tc_analyzer_lib/algorithms/__init__.py similarity index 100% rename from discord_analyzer/algorithms/__init__.py rename to tc_analyzer_lib/algorithms/__init__.py diff --git a/discord_analyzer/algorithms/analytics_interactions_script.py b/tc_analyzer_lib/algorithms/analytics_interactions_script.py similarity index 100% rename from discord_analyzer/algorithms/analytics_interactions_script.py rename to tc_analyzer_lib/algorithms/analytics_interactions_script.py diff --git a/discord_analyzer/algorithms/compute_interaction_matrix_discord.py b/tc_analyzer_lib/algorithms/compute_interaction_matrix_discord.py similarity index 95% rename from discord_analyzer/algorithms/compute_interaction_matrix_discord.py rename to tc_analyzer_lib/algorithms/compute_interaction_matrix_discord.py index d86abf5..43a6335 100644 --- a/discord_analyzer/algorithms/compute_interaction_matrix_discord.py +++ b/tc_analyzer_lib/algorithms/compute_interaction_matrix_discord.py @@ -4,7 +4,7 @@ from numpy import diag_indices_from, ndarray -from discord_analyzer.utils.mongo import MongoSingleton +from tc_analyzer_lib.utils.mongo import MongoSingleton from .utils.compute_interaction_mtx_utils import ( generate_interaction_matrix, prepare_per_account, diff --git a/discord_analyzer/algorithms/compute_member_activity.py b/tc_analyzer_lib/algorithms/compute_member_activity.py similarity index 94% rename from discord_analyzer/algorithms/compute_member_activity.py rename to tc_analyzer_lib/algorithms/compute_member_activity.py index 504e34c..574ebc1 100644 --- a/discord_analyzer/algorithms/compute_member_activity.py +++ b/tc_analyzer_lib/algorithms/compute_member_activity.py @@ -11,11 +11,11 @@ import networkx as nx import numpy as np from dateutil.relativedelta import relativedelta -from discord_analyzer.algorithms.member_activity_history import check_past_history -from discord_analyzer.algorithms.utils.member_activity_history_utils import ( +from tc_analyzer_lib.algorithms.member_activity_history import check_past_history +from tc_analyzer_lib.algorithms.utils.member_activity_history_utils import ( MemberActivityPastUtils, ) -from discord_analyzer.algorithms.utils.member_activity_utils import ( +from tc_analyzer_lib.algorithms.utils.member_activity_utils import ( assess_engagement, convert_to_dict, get_joined_accounts, @@ -24,8 +24,8 @@ store_based_date, update_activities, ) -from discord_analyzer.DB_operations.mongodb_access import DB_access -from discord_analyzer.schemas.platform_configs.config_base import PlatformConfigBase +from tc_analyzer_lib.DB_operations.mongodb_access import DB_access +from tc_analyzer_lib.schemas.platform_configs.config_base import PlatformConfigBase def compute_member_activity( diff --git a/discord_analyzer/algorithms/member_activity_history.py b/tc_analyzer_lib/algorithms/member_activity_history.py similarity index 96% rename from discord_analyzer/algorithms/member_activity_history.py rename to tc_analyzer_lib/algorithms/member_activity_history.py index 130a24e..c26486f 100644 --- a/discord_analyzer/algorithms/member_activity_history.py +++ b/tc_analyzer_lib/algorithms/member_activity_history.py @@ -2,10 +2,10 @@ from datetime import datetime, timedelta -from discord_analyzer.algorithms.utils.member_activity_history_utils import ( +from tc_analyzer_lib.algorithms.utils.member_activity_history_utils import ( MemberActivityPastUtils, ) -from discord_analyzer.DB_operations.mongodb_access import DB_access +from tc_analyzer_lib.DB_operations.mongodb_access import DB_access # the main script function diff --git a/discord_analyzer/algorithms/neo4j_analysis/__init__.py b/tc_analyzer_lib/algorithms/neo4j_analysis/__init__.py similarity index 100% rename from discord_analyzer/algorithms/neo4j_analysis/__init__.py rename to tc_analyzer_lib/algorithms/neo4j_analysis/__init__.py diff --git a/discord_analyzer/algorithms/neo4j_analysis/analyzer_node_stats.py b/tc_analyzer_lib/algorithms/neo4j_analysis/analyzer_node_stats.py similarity index 98% rename from discord_analyzer/algorithms/neo4j_analysis/analyzer_node_stats.py rename to tc_analyzer_lib/algorithms/neo4j_analysis/analyzer_node_stats.py index 2786894..65788eb 100644 --- a/discord_analyzer/algorithms/neo4j_analysis/analyzer_node_stats.py +++ b/tc_analyzer_lib/algorithms/neo4j_analysis/analyzer_node_stats.py @@ -3,8 +3,8 @@ from uuid import uuid1 import pandas as pd -from discord_analyzer.algorithms.neo4j_analysis.utils import ProjectionUtils -from discord_analyzer.schemas import GraphSchema +from tc_analyzer_lib.algorithms.neo4j_analysis.utils import ProjectionUtils +from tc_analyzer_lib.schemas import GraphSchema from tc_neo4j_lib.neo4j_ops import Neo4jOps diff --git a/discord_analyzer/algorithms/neo4j_analysis/centrality.py b/tc_analyzer_lib/algorithms/neo4j_analysis/centrality.py similarity index 99% rename from discord_analyzer/algorithms/neo4j_analysis/centrality.py rename to tc_analyzer_lib/algorithms/neo4j_analysis/centrality.py index 2b806d6..ede8762 100644 --- a/discord_analyzer/algorithms/neo4j_analysis/centrality.py +++ b/tc_analyzer_lib/algorithms/neo4j_analysis/centrality.py @@ -2,11 +2,11 @@ from typing import Literal import pandas as pd -from discord_analyzer.algorithms.neo4j_analysis.utils import ( +from tc_analyzer_lib.algorithms.neo4j_analysis.utils import ( Neo4JMetrics, ProjectionUtils, ) -from discord_analyzer.schemas import GraphSchema +from tc_analyzer_lib.schemas import GraphSchema from tc_neo4j_lib.neo4j_ops import Neo4jOps, Query diff --git a/discord_analyzer/algorithms/neo4j_analysis/local_clustering_coefficient.py b/tc_analyzer_lib/algorithms/neo4j_analysis/local_clustering_coefficient.py similarity index 97% rename from discord_analyzer/algorithms/neo4j_analysis/local_clustering_coefficient.py rename to tc_analyzer_lib/algorithms/neo4j_analysis/local_clustering_coefficient.py index dc6ae5d..2323851 100644 --- a/discord_analyzer/algorithms/neo4j_analysis/local_clustering_coefficient.py +++ b/tc_analyzer_lib/algorithms/neo4j_analysis/local_clustering_coefficient.py @@ -1,8 +1,8 @@ import logging from uuid import uuid1 -from discord_analyzer.algorithms.neo4j_analysis.utils import ProjectionUtils -from discord_analyzer.schemas import GraphSchema +from tc_analyzer_lib.algorithms.neo4j_analysis.utils import ProjectionUtils +from tc_analyzer_lib.schemas import GraphSchema from tc_neo4j_lib import Neo4jOps diff --git a/discord_analyzer/algorithms/neo4j_analysis/louvain.py b/tc_analyzer_lib/algorithms/neo4j_analysis/louvain.py similarity index 97% rename from discord_analyzer/algorithms/neo4j_analysis/louvain.py rename to tc_analyzer_lib/algorithms/neo4j_analysis/louvain.py index 8d72edc..8a00ddf 100644 --- a/discord_analyzer/algorithms/neo4j_analysis/louvain.py +++ b/tc_analyzer_lib/algorithms/neo4j_analysis/louvain.py @@ -1,8 +1,8 @@ import logging from uuid import uuid1 -from discord_analyzer.algorithms.neo4j_analysis.utils import ProjectionUtils -from discord_analyzer.schemas import GraphSchema +from tc_analyzer_lib.algorithms.neo4j_analysis.utils import ProjectionUtils +from tc_analyzer_lib.schemas import GraphSchema from tc_neo4j_lib.neo4j_ops import Neo4jOps diff --git a/discord_analyzer/algorithms/neo4j_analysis/utils/__init__.py b/tc_analyzer_lib/algorithms/neo4j_analysis/utils/__init__.py similarity index 100% rename from discord_analyzer/algorithms/neo4j_analysis/utils/__init__.py rename to tc_analyzer_lib/algorithms/neo4j_analysis/utils/__init__.py diff --git a/discord_analyzer/algorithms/neo4j_analysis/utils/neo4j_metrics.py b/tc_analyzer_lib/algorithms/neo4j_analysis/utils/neo4j_metrics.py similarity index 100% rename from discord_analyzer/algorithms/neo4j_analysis/utils/neo4j_metrics.py rename to tc_analyzer_lib/algorithms/neo4j_analysis/utils/neo4j_metrics.py diff --git a/discord_analyzer/algorithms/neo4j_analysis/utils/projection_utils.py b/tc_analyzer_lib/algorithms/neo4j_analysis/utils/projection_utils.py similarity index 99% rename from discord_analyzer/algorithms/neo4j_analysis/utils/projection_utils.py rename to tc_analyzer_lib/algorithms/neo4j_analysis/utils/projection_utils.py index 7378263..3f8bd9f 100644 --- a/discord_analyzer/algorithms/neo4j_analysis/utils/projection_utils.py +++ b/tc_analyzer_lib/algorithms/neo4j_analysis/utils/projection_utils.py @@ -1,6 +1,6 @@ import logging -from discord_analyzer.schemas import GraphSchema +from tc_analyzer_lib.schemas import GraphSchema from tc_neo4j_lib.neo4j_ops import Neo4jOps diff --git a/discord_analyzer/algorithms/utils/__init__.py b/tc_analyzer_lib/algorithms/utils/__init__.py similarity index 100% rename from discord_analyzer/algorithms/utils/__init__.py rename to tc_analyzer_lib/algorithms/utils/__init__.py diff --git a/discord_analyzer/algorithms/utils/activity.py b/tc_analyzer_lib/algorithms/utils/activity.py similarity index 100% rename from discord_analyzer/algorithms/utils/activity.py rename to tc_analyzer_lib/algorithms/utils/activity.py diff --git a/discord_analyzer/algorithms/utils/compute_interaction_mtx_utils.py b/tc_analyzer_lib/algorithms/utils/compute_interaction_mtx_utils.py similarity index 97% rename from discord_analyzer/algorithms/utils/compute_interaction_mtx_utils.py rename to tc_analyzer_lib/algorithms/utils/compute_interaction_mtx_utils.py index 540cd20..7cdd01b 100644 --- a/discord_analyzer/algorithms/utils/compute_interaction_mtx_utils.py +++ b/tc_analyzer_lib/algorithms/utils/compute_interaction_mtx_utils.py @@ -2,7 +2,7 @@ from typing import Any import numpy as np -from discord_analyzer.algorithms.analytics_interactions_script import ( +from tc_analyzer_lib.algorithms.analytics_interactions_script import ( per_account_interactions, ) diff --git a/discord_analyzer/algorithms/utils/member_activity_history_utils.py b/tc_analyzer_lib/algorithms/utils/member_activity_history_utils.py similarity index 99% rename from discord_analyzer/algorithms/utils/member_activity_history_utils.py rename to tc_analyzer_lib/algorithms/utils/member_activity_history_utils.py index 524f574..75c8313 100644 --- a/discord_analyzer/algorithms/utils/member_activity_history_utils.py +++ b/tc_analyzer_lib/algorithms/utils/member_activity_history_utils.py @@ -3,7 +3,7 @@ from typing import Any from dateutil import parser -from discord_analyzer.DB_operations.mongodb_access import DB_access +from tc_analyzer_lib.DB_operations.mongodb_access import DB_access from numpy import array diff --git a/discord_analyzer/algorithms/utils/member_activity_utils.py b/tc_analyzer_lib/algorithms/utils/member_activity_utils.py similarity index 97% rename from discord_analyzer/algorithms/utils/member_activity_utils.py rename to tc_analyzer_lib/algorithms/utils/member_activity_utils.py index e0a6ee9..29b05e5 100644 --- a/discord_analyzer/algorithms/utils/member_activity_utils.py +++ b/tc_analyzer_lib/algorithms/utils/member_activity_utils.py @@ -4,11 +4,11 @@ import numpy as np import pymongo -from discord_analyzer.algorithms.compute_interaction_matrix_discord import ( +from tc_analyzer_lib.algorithms.compute_interaction_matrix_discord import ( compute_interaction_matrix_discord, ) -from discord_analyzer.DB_operations.mongodb_access import DB_access -from discord_analyzer.schemas.platform_configs.config_base import PlatformConfigBase +from tc_analyzer_lib.DB_operations.mongodb_access import DB_access +from tc_analyzer_lib.schemas.platform_configs.config_base import PlatformConfigBase from networkx import DiGraph from tc_core_analyzer_lib.assess_engagement import EngagementAssessment diff --git a/discord_analyzer/automation/__init__.py b/tc_analyzer_lib/automation/__init__.py similarity index 100% rename from discord_analyzer/automation/__init__.py rename to tc_analyzer_lib/automation/__init__.py diff --git a/discord_analyzer/automation/automation_workflow.py b/tc_analyzer_lib/automation/automation_workflow.py similarity index 98% rename from discord_analyzer/automation/automation_workflow.py rename to tc_analyzer_lib/automation/automation_workflow.py index f4aed5b..0816494 100644 --- a/discord_analyzer/automation/automation_workflow.py +++ b/tc_analyzer_lib/automation/automation_workflow.py @@ -1,8 +1,8 @@ import logging from typing import Any -from discord_analyzer.automation.utils.automation_base import AutomationBase -from discord_analyzer.automation.utils.model import AutomationDB +from tc_analyzer_lib.automation.utils.automation_base import AutomationBase +from tc_analyzer_lib.automation.utils.model import AutomationDB from pybars import Compiler from tc_messageBroker.rabbit_mq.event import Event from tc_messageBroker.rabbit_mq.queue import Queue diff --git a/discord_analyzer/automation/utils/__init__.py b/tc_analyzer_lib/automation/utils/__init__.py similarity index 100% rename from discord_analyzer/automation/utils/__init__.py rename to tc_analyzer_lib/automation/utils/__init__.py diff --git a/discord_analyzer/automation/utils/automation_base.py b/tc_analyzer_lib/automation/utils/automation_base.py similarity index 98% rename from discord_analyzer/automation/utils/automation_base.py rename to tc_analyzer_lib/automation/utils/automation_base.py index 48246ea..54e2164 100644 --- a/discord_analyzer/automation/utils/automation_base.py +++ b/tc_analyzer_lib/automation/utils/automation_base.py @@ -2,8 +2,8 @@ from typing import Any from uuid import uuid1 -from discord_analyzer.utils.mongo import MongoSingleton -from discord_analyzer.utils.rabbitmq import RabbitMQAccess +from tc_analyzer_lib.utils.mongo import MongoSingleton +from tc_analyzer_lib.utils.rabbitmq import RabbitMQAccess class AutomationBase: diff --git a/discord_analyzer/automation/utils/interfaces.py b/tc_analyzer_lib/automation/utils/interfaces.py similarity index 100% rename from discord_analyzer/automation/utils/interfaces.py rename to tc_analyzer_lib/automation/utils/interfaces.py diff --git a/discord_analyzer/automation/utils/model.py b/tc_analyzer_lib/automation/utils/model.py similarity index 93% rename from discord_analyzer/automation/utils/model.py rename to tc_analyzer_lib/automation/utils/model.py index a2420ff..3eded62 100644 --- a/discord_analyzer/automation/utils/model.py +++ b/tc_analyzer_lib/automation/utils/model.py @@ -1,5 +1,5 @@ -from discord_analyzer.utils.get_automation_env import get_automations_env -from discord_analyzer.utils.mongo import MongoSingleton +from tc_analyzer_lib.utils.get_automation_env import get_automations_env +from tc_analyzer_lib.utils.mongo import MongoSingleton from .interfaces import Automation diff --git a/discord_analyzer/metrics/__init__.py b/tc_analyzer_lib/metrics/__init__.py similarity index 100% rename from discord_analyzer/metrics/__init__.py rename to tc_analyzer_lib/metrics/__init__.py diff --git a/discord_analyzer/metrics/analyzer_memberactivities.py b/tc_analyzer_lib/metrics/analyzer_memberactivities.py similarity index 92% rename from discord_analyzer/metrics/analyzer_memberactivities.py rename to tc_analyzer_lib/metrics/analyzer_memberactivities.py index ae8eecd..976ad10 100644 --- a/discord_analyzer/metrics/analyzer_memberactivities.py +++ b/tc_analyzer_lib/metrics/analyzer_memberactivities.py @@ -1,12 +1,12 @@ import logging from datetime import datetime, timedelta -from discord_analyzer.algorithms.compute_member_activity import compute_member_activity -from discord_analyzer.metrics.memberactivity_utils import MemberActivityUtils -from discord_analyzer.models.MemberActivityModel import MemberActivityModel -from discord_analyzer.models.RawInfoModel import RawInfoModel -from discord_analyzer.schemas.platform_configs.config_base import PlatformConfigBase -from discord_analyzer.utils.mongo import MongoSingleton +from tc_analyzer_lib.algorithms.compute_member_activity import compute_member_activity +from tc_analyzer_lib.metrics.memberactivity_utils import MemberActivityUtils +from tc_analyzer_lib.models.MemberActivityModel import MemberActivityModel +from tc_analyzer_lib.models.RawInfoModel import RawInfoModel +from tc_analyzer_lib.schemas.platform_configs.config_base import PlatformConfigBase +from tc_analyzer_lib.utils.mongo import MongoSingleton class MemberActivities: diff --git a/discord_analyzer/metrics/heatmaps/__init__.py b/tc_analyzer_lib/metrics/heatmaps/__init__.py similarity index 100% rename from discord_analyzer/metrics/heatmaps/__init__.py rename to tc_analyzer_lib/metrics/heatmaps/__init__.py diff --git a/discord_analyzer/metrics/heatmaps/analytics_hourly.py b/tc_analyzer_lib/metrics/heatmaps/analytics_hourly.py similarity index 99% rename from discord_analyzer/metrics/heatmaps/analytics_hourly.py rename to tc_analyzer_lib/metrics/heatmaps/analytics_hourly.py index 260ff9c..cb848f2 100644 --- a/discord_analyzer/metrics/heatmaps/analytics_hourly.py +++ b/tc_analyzer_lib/metrics/heatmaps/analytics_hourly.py @@ -2,7 +2,7 @@ from typing import Any import numpy as np -from discord_analyzer.utils.mongo import MongoSingleton +from tc_analyzer_lib.utils.mongo import MongoSingleton class AnalyticsHourly: diff --git a/discord_analyzer/metrics/heatmaps/analytics_raw.py b/tc_analyzer_lib/metrics/heatmaps/analytics_raw.py similarity index 98% rename from discord_analyzer/metrics/heatmaps/analytics_raw.py rename to tc_analyzer_lib/metrics/heatmaps/analytics_raw.py index fbcaa91..9f7f1da 100644 --- a/discord_analyzer/metrics/heatmaps/analytics_raw.py +++ b/tc_analyzer_lib/metrics/heatmaps/analytics_raw.py @@ -2,8 +2,8 @@ from datetime import date, datetime, time, timedelta from typing import Any -from discord_analyzer.schemas import RawAnalyticsItem -from discord_analyzer.utils.mongo import MongoSingleton +from tc_analyzer_lib.schemas import RawAnalyticsItem +from tc_analyzer_lib.utils.mongo import MongoSingleton class AnalyticsRaw: diff --git a/discord_analyzer/metrics/heatmaps/heatmaps.py b/tc_analyzer_lib/metrics/heatmaps/heatmaps.py similarity index 96% rename from discord_analyzer/metrics/heatmaps/heatmaps.py rename to tc_analyzer_lib/metrics/heatmaps/heatmaps.py index aa694e0..40a36f9 100644 --- a/discord_analyzer/metrics/heatmaps/heatmaps.py +++ b/tc_analyzer_lib/metrics/heatmaps/heatmaps.py @@ -1,10 +1,10 @@ import logging from datetime import date, datetime, timedelta -from discord_analyzer.metrics.heatmaps import AnalyticsHourly, AnalyticsRaw -from discord_analyzer.metrics.heatmaps.heatmaps_utils import HeatmapsUtils -from discord_analyzer.schemas.platform_configs.config_base import PlatformConfigBase -from discord_analyzer.utils.mongo import MongoSingleton +from tc_analyzer_lib.metrics.heatmaps import AnalyticsHourly, AnalyticsRaw +from tc_analyzer_lib.metrics.heatmaps.heatmaps_utils import HeatmapsUtils +from tc_analyzer_lib.schemas.platform_configs.config_base import PlatformConfigBase +from tc_analyzer_lib.utils.mongo import MongoSingleton class Heatmaps: diff --git a/discord_analyzer/metrics/heatmaps/heatmaps_utils.py b/tc_analyzer_lib/metrics/heatmaps/heatmaps_utils.py similarity index 97% rename from discord_analyzer/metrics/heatmaps/heatmaps_utils.py rename to tc_analyzer_lib/metrics/heatmaps/heatmaps_utils.py index 922011e..60abaf1 100644 --- a/discord_analyzer/metrics/heatmaps/heatmaps_utils.py +++ b/tc_analyzer_lib/metrics/heatmaps/heatmaps_utils.py @@ -1,7 +1,7 @@ from datetime import datetime from pymongo.cursor import Cursor -from discord_analyzer.utils.mongo import MongoSingleton +from tc_analyzer_lib.utils.mongo import MongoSingleton class HeatmapsUtils: diff --git a/discord_analyzer/metrics/memberactivity_utils.py b/tc_analyzer_lib/metrics/memberactivity_utils.py similarity index 98% rename from discord_analyzer/metrics/memberactivity_utils.py rename to tc_analyzer_lib/metrics/memberactivity_utils.py index daf86da..0f3a41b 100644 --- a/discord_analyzer/metrics/memberactivity_utils.py +++ b/tc_analyzer_lib/metrics/memberactivity_utils.py @@ -1,7 +1,7 @@ import logging from dateutil import parser -from discord_analyzer.utils.mongo import MongoSingleton +from tc_analyzer_lib.utils.mongo import MongoSingleton class MemberActivityUtils: diff --git a/discord_analyzer/metrics/neo4j_analytics.py b/tc_analyzer_lib/metrics/neo4j_analytics.py similarity index 94% rename from discord_analyzer/metrics/neo4j_analytics.py rename to tc_analyzer_lib/metrics/neo4j_analytics.py index eae76bb..451615d 100644 --- a/discord_analyzer/metrics/neo4j_analytics.py +++ b/tc_analyzer_lib/metrics/neo4j_analytics.py @@ -1,13 +1,13 @@ # A wrapper to compute the neo4j metrics in cron-job import logging -from discord_analyzer.algorithms.neo4j_analysis.analyzer_node_stats import NodeStats -from discord_analyzer.algorithms.neo4j_analysis.centrality import Centerality -from discord_analyzer.algorithms.neo4j_analysis.local_clustering_coefficient import ( +from tc_analyzer_lib.algorithms.neo4j_analysis.analyzer_node_stats import NodeStats +from tc_analyzer_lib.algorithms.neo4j_analysis.centrality import Centerality +from tc_analyzer_lib.algorithms.neo4j_analysis.local_clustering_coefficient import ( LocalClusteringCoeff, ) -from discord_analyzer.algorithms.neo4j_analysis.louvain import Louvain -from discord_analyzer.schemas import GraphSchema +from tc_analyzer_lib.algorithms.neo4j_analysis.louvain import Louvain +from tc_analyzer_lib.schemas import GraphSchema from tc_neo4j_lib.neo4j_ops import Neo4jOps diff --git a/discord_analyzer/metrics/utils/__init__.py b/tc_analyzer_lib/metrics/utils/__init__.py similarity index 100% rename from discord_analyzer/metrics/utils/__init__.py rename to tc_analyzer_lib/metrics/utils/__init__.py diff --git a/discord_analyzer/metrics/utils/analyzer_db_manager.py b/tc_analyzer_lib/metrics/utils/analyzer_db_manager.py similarity index 81% rename from discord_analyzer/metrics/utils/analyzer_db_manager.py rename to tc_analyzer_lib/metrics/utils/analyzer_db_manager.py index 475ee38..96394b2 100644 --- a/discord_analyzer/metrics/utils/analyzer_db_manager.py +++ b/tc_analyzer_lib/metrics/utils/analyzer_db_manager.py @@ -1,4 +1,4 @@ -from discord_analyzer.DB_operations.mongo_neo4j_ops import MongoNeo4jDB +from tc_analyzer_lib.DB_operations.mongo_neo4j_ops import MongoNeo4jDB class AnalyzerDBManager: diff --git a/discord_analyzer/metrics/utils/platform.py b/tc_analyzer_lib/metrics/utils/platform.py similarity index 98% rename from discord_analyzer/metrics/utils/platform.py rename to tc_analyzer_lib/metrics/utils/platform.py index c91668c..d8d2116 100644 --- a/discord_analyzer/metrics/utils/platform.py +++ b/tc_analyzer_lib/metrics/utils/platform.py @@ -1,7 +1,7 @@ from bson import ObjectId from datetime import datetime -from discord_analyzer.utils.mongo import MongoSingleton +from tc_analyzer_lib.utils.mongo import MongoSingleton class Platform: diff --git a/discord_analyzer/models/BaseModel.py b/tc_analyzer_lib/models/BaseModel.py similarity index 100% rename from discord_analyzer/models/BaseModel.py rename to tc_analyzer_lib/models/BaseModel.py diff --git a/discord_analyzer/models/GuildsRnDaoModel.py b/tc_analyzer_lib/models/GuildsRnDaoModel.py similarity index 97% rename from discord_analyzer/models/GuildsRnDaoModel.py rename to tc_analyzer_lib/models/GuildsRnDaoModel.py index a1f9557..e29199d 100644 --- a/discord_analyzer/models/GuildsRnDaoModel.py +++ b/tc_analyzer_lib/models/GuildsRnDaoModel.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -from discord_analyzer.models.BaseModel import BaseModel +from tc_analyzer_lib.models.BaseModel import BaseModel from pymongo.database import Database diff --git a/discord_analyzer/models/HeatMapModel.py b/tc_analyzer_lib/models/HeatMapModel.py similarity index 97% rename from discord_analyzer/models/HeatMapModel.py rename to tc_analyzer_lib/models/HeatMapModel.py index afcba0e..8f5b1bb 100644 --- a/discord_analyzer/models/HeatMapModel.py +++ b/tc_analyzer_lib/models/HeatMapModel.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 from datetime import datetime -from discord_analyzer.models.BaseModel import BaseModel +from tc_analyzer_lib.models.BaseModel import BaseModel from pymongo import DESCENDING from pymongo.database import Database diff --git a/discord_analyzer/models/MemberActivityModel.py b/tc_analyzer_lib/models/MemberActivityModel.py similarity index 96% rename from discord_analyzer/models/MemberActivityModel.py rename to tc_analyzer_lib/models/MemberActivityModel.py index 73f3234..c6f4121 100644 --- a/discord_analyzer/models/MemberActivityModel.py +++ b/tc_analyzer_lib/models/MemberActivityModel.py @@ -2,7 +2,7 @@ import logging import pymongo -from discord_analyzer.models.BaseModel import BaseModel +from tc_analyzer_lib.models.BaseModel import BaseModel class MemberActivityModel(BaseModel): diff --git a/discord_analyzer/models/RawInfoModel.py b/tc_analyzer_lib/models/RawInfoModel.py similarity index 97% rename from discord_analyzer/models/RawInfoModel.py rename to tc_analyzer_lib/models/RawInfoModel.py index 16e6a4a..afd86bb 100644 --- a/discord_analyzer/models/RawInfoModel.py +++ b/tc_analyzer_lib/models/RawInfoModel.py @@ -3,7 +3,7 @@ from datetime import datetime, timedelta from typing import Any -from discord_analyzer.models.BaseModel import BaseModel +from tc_analyzer_lib.models.BaseModel import BaseModel from pymongo import ASCENDING from pymongo.database import Database diff --git a/discord_analyzer/models/__init__.py b/tc_analyzer_lib/models/__init__.py similarity index 100% rename from discord_analyzer/models/__init__.py rename to tc_analyzer_lib/models/__init__.py diff --git a/discord_analyzer/models/raw_member_activities.py b/tc_analyzer_lib/models/raw_member_activities.py similarity index 97% rename from discord_analyzer/models/raw_member_activities.py rename to tc_analyzer_lib/models/raw_member_activities.py index e0a55af..7ada9e3 100644 --- a/discord_analyzer/models/raw_member_activities.py +++ b/tc_analyzer_lib/models/raw_member_activities.py @@ -3,8 +3,8 @@ from datetime import datetime, time, timedelta import numpy as np -from discord_analyzer.models.BaseModel import BaseModel -from discord_analyzer.utils.mongo import MongoSingleton +from tc_analyzer_lib.models.BaseModel import BaseModel +from tc_analyzer_lib.utils.mongo import MongoSingleton class RawMemberActivities(BaseModel): diff --git a/discord_analyzer/publish_on_success.py b/tc_analyzer_lib/publish_on_success.py similarity index 92% rename from discord_analyzer/publish_on_success.py rename to tc_analyzer_lib/publish_on_success.py index 7ee9a5a..22ffa05 100644 --- a/discord_analyzer/publish_on_success.py +++ b/tc_analyzer_lib/publish_on_success.py @@ -1,14 +1,14 @@ import logging -from discord_analyzer.automation.automation_workflow import AutomationWorkflow +from tc_analyzer_lib.automation.automation_workflow import AutomationWorkflow from tc_messageBroker.rabbit_mq.event import Event from tc_messageBroker.rabbit_mq.queue import Queue -from discord_analyzer.utils.get_guild_utils import ( +from tc_analyzer_lib.utils.get_guild_utils import ( get_platform_guild_id, get_platform_name, get_platform_community_owner ) -from discord_analyzer.utils.rabbitmq import RabbitMQAccess +from tc_analyzer_lib.utils.rabbitmq import RabbitMQAccess def publish_on_success(platform_id: str, recompute: bool) -> None: diff --git a/discord_analyzer/schemas/__init__.py b/tc_analyzer_lib/schemas/__init__.py similarity index 100% rename from discord_analyzer/schemas/__init__.py rename to tc_analyzer_lib/schemas/__init__.py diff --git a/discord_analyzer/schemas/activity_type.py b/tc_analyzer_lib/schemas/activity_type.py similarity index 100% rename from discord_analyzer/schemas/activity_type.py rename to tc_analyzer_lib/schemas/activity_type.py diff --git a/discord_analyzer/schemas/graph.py b/tc_analyzer_lib/schemas/graph.py similarity index 100% rename from discord_analyzer/schemas/graph.py rename to tc_analyzer_lib/schemas/graph.py diff --git a/discord_analyzer/schemas/hourly_analytics.py b/tc_analyzer_lib/schemas/hourly_analytics.py similarity index 100% rename from discord_analyzer/schemas/hourly_analytics.py rename to tc_analyzer_lib/schemas/hourly_analytics.py diff --git a/discord_analyzer/schemas/platform_configs/__init__.py b/tc_analyzer_lib/schemas/platform_configs/__init__.py similarity index 100% rename from discord_analyzer/schemas/platform_configs/__init__.py rename to tc_analyzer_lib/schemas/platform_configs/__init__.py diff --git a/discord_analyzer/schemas/platform_configs/config_base.py b/tc_analyzer_lib/schemas/platform_configs/config_base.py similarity index 94% rename from discord_analyzer/schemas/platform_configs/config_base.py rename to tc_analyzer_lib/schemas/platform_configs/config_base.py index bf3e62c..1e6aeef 100644 --- a/discord_analyzer/schemas/platform_configs/config_base.py +++ b/tc_analyzer_lib/schemas/platform_configs/config_base.py @@ -1,4 +1,4 @@ -from discord_analyzer.schemas import HourlyAnalytics, RawAnalytics +from tc_analyzer_lib.schemas import HourlyAnalytics, RawAnalytics class PlatformConfigBase: diff --git a/discord_analyzer/schemas/platform_configs/discord.py b/tc_analyzer_lib/schemas/platform_configs/discord.py similarity index 96% rename from discord_analyzer/schemas/platform_configs/discord.py rename to tc_analyzer_lib/schemas/platform_configs/discord.py index 7879e5e..effb904 100644 --- a/discord_analyzer/schemas/platform_configs/discord.py +++ b/tc_analyzer_lib/schemas/platform_configs/discord.py @@ -1,10 +1,10 @@ -from discord_analyzer.schemas import ( +from tc_analyzer_lib.schemas import ( ActivityDirection, ActivityType, HourlyAnalytics, RawAnalytics, ) -from discord_analyzer.schemas.platform_configs.config_base import PlatformConfigBase +from tc_analyzer_lib.schemas.platform_configs.config_base import PlatformConfigBase class DiscordAnalyzerConfig(PlatformConfigBase): diff --git a/discord_analyzer/schemas/raw_analytics.py b/tc_analyzer_lib/schemas/raw_analytics.py similarity index 100% rename from discord_analyzer/schemas/raw_analytics.py rename to tc_analyzer_lib/schemas/raw_analytics.py diff --git a/discord_analyzer/schemas/raw_analytics_item.py b/tc_analyzer_lib/schemas/raw_analytics_item.py similarity index 100% rename from discord_analyzer/schemas/raw_analytics_item.py rename to tc_analyzer_lib/schemas/raw_analytics_item.py diff --git a/discord_analyzer/tc_analyzer.py b/tc_analyzer_lib/tc_analyzer.py similarity index 91% rename from discord_analyzer/tc_analyzer.py rename to tc_analyzer_lib/tc_analyzer.py index 010bc86..f3f89b4 100644 --- a/discord_analyzer/tc_analyzer.py +++ b/tc_analyzer_lib/tc_analyzer.py @@ -1,15 +1,15 @@ import logging from datetime import datetime -from discord_analyzer.metrics.analyzer_memberactivities import MemberActivities -from discord_analyzer.metrics.heatmaps import Heatmaps -from discord_analyzer.metrics.neo4j_analytics import Neo4JAnalytics -from discord_analyzer.metrics.utils.analyzer_db_manager import AnalyzerDBManager -from discord_analyzer.metrics.utils.platform import Platform -from discord_analyzer.schemas import GraphSchema -from discord_analyzer.schemas.platform_configs import DiscordAnalyzerConfig -from discord_analyzer.schemas.platform_configs.config_base import PlatformConfigBase -from discord_analyzer.schemas.platform_configs import DiscordAnalyzerConfig +from tc_analyzer_lib.metrics.analyzer_memberactivities import MemberActivities +from tc_analyzer_lib.metrics.heatmaps import Heatmaps +from tc_analyzer_lib.metrics.neo4j_analytics import Neo4JAnalytics +from tc_analyzer_lib.metrics.utils.analyzer_db_manager import AnalyzerDBManager +from tc_analyzer_lib.metrics.utils.platform import Platform +from tc_analyzer_lib.schemas import GraphSchema +from tc_analyzer_lib.schemas.platform_configs import DiscordAnalyzerConfig +from tc_analyzer_lib.schemas.platform_configs.config_base import PlatformConfigBase +from tc_analyzer_lib.schemas.platform_configs import DiscordAnalyzerConfig class TCAnalyzer(AnalyzerDBManager): diff --git a/discord_analyzer/utils/__init__.py b/tc_analyzer_lib/utils/__init__.py similarity index 100% rename from discord_analyzer/utils/__init__.py rename to tc_analyzer_lib/utils/__init__.py diff --git a/discord_analyzer/utils/credentials.py b/tc_analyzer_lib/utils/credentials.py similarity index 100% rename from discord_analyzer/utils/credentials.py rename to tc_analyzer_lib/utils/credentials.py diff --git a/discord_analyzer/utils/get_automation_env.py b/tc_analyzer_lib/utils/get_automation_env.py similarity index 100% rename from discord_analyzer/utils/get_automation_env.py rename to tc_analyzer_lib/utils/get_automation_env.py diff --git a/discord_analyzer/utils/get_guild_utils.py b/tc_analyzer_lib/utils/get_guild_utils.py similarity index 98% rename from discord_analyzer/utils/get_guild_utils.py rename to tc_analyzer_lib/utils/get_guild_utils.py index 9af4050..2f2219c 100644 --- a/discord_analyzer/utils/get_guild_utils.py +++ b/tc_analyzer_lib/utils/get_guild_utils.py @@ -1,5 +1,5 @@ from bson.objectid import ObjectId -from discord_analyzer.utils.mongo import MongoSingleton +from tc_analyzer_lib.utils.mongo import MongoSingleton def get_platform_guild_id(platform_id: str) -> str: diff --git a/discord_analyzer/utils/mongo.py b/tc_analyzer_lib/utils/mongo.py similarity index 93% rename from discord_analyzer/utils/mongo.py rename to tc_analyzer_lib/utils/mongo.py index b04ba45..c40e36d 100644 --- a/discord_analyzer/utils/mongo.py +++ b/tc_analyzer_lib/utils/mongo.py @@ -2,7 +2,7 @@ from typing import Any from pymongo import MongoClient -from discord_analyzer.utils.credentials import get_mongo_credentials +from tc_analyzer_lib.utils.credentials import get_mongo_credentials class MongoSingleton: diff --git a/discord_analyzer/utils/rabbitmq.py b/tc_analyzer_lib/utils/rabbitmq.py similarity index 94% rename from discord_analyzer/utils/rabbitmq.py rename to tc_analyzer_lib/utils/rabbitmq.py index 978e767..c8dee69 100644 --- a/discord_analyzer/utils/rabbitmq.py +++ b/tc_analyzer_lib/utils/rabbitmq.py @@ -2,7 +2,7 @@ from tc_messageBroker import RabbitMQ from tc_messageBroker.rabbit_mq.queue import Queue -from discord_analyzer.utils.credentials import get_rabbit_mq_credentials +from tc_analyzer_lib.utils.credentials import get_rabbit_mq_credentials class RabbitMQAccess: diff --git a/discord_analyzer/utils/redis.py b/tc_analyzer_lib/utils/redis.py similarity index 94% rename from discord_analyzer/utils/redis.py rename to tc_analyzer_lib/utils/redis.py index 45793d3..e0cff89 100644 --- a/discord_analyzer/utils/redis.py +++ b/tc_analyzer_lib/utils/redis.py @@ -1,7 +1,7 @@ import logging import redis -from discord_analyzer.utils.credentials import get_redis_credentials +from tc_analyzer_lib.utils.credentials import get_redis_credentials class RedisSingleton: diff --git a/tests/integration/test_analyzer_platform_fetch_period.py b/tests/integration/test_analyzer_platform_fetch_period.py index 1190f0f..f041d25 100644 --- a/tests/integration/test_analyzer_platform_fetch_period.py +++ b/tests/integration/test_analyzer_platform_fetch_period.py @@ -2,8 +2,8 @@ from datetime import datetime from unittest import TestCase -from discord_analyzer.utils.mongo import MongoSingleton -from discord_analyzer.metrics.utils import Platform +from tc_analyzer_lib.utils.mongo import MongoSingleton +from tc_analyzer_lib.metrics.utils import Platform class TestPlatformUtilsFetchPeriod(TestCase): diff --git a/tests/integration/test_analyzer_platform_fetch_resources.py b/tests/integration/test_analyzer_platform_fetch_resources.py index 593b182..d693d5a 100644 --- a/tests/integration/test_analyzer_platform_fetch_resources.py +++ b/tests/integration/test_analyzer_platform_fetch_resources.py @@ -2,8 +2,8 @@ from datetime import datetime from unittest import TestCase -from discord_analyzer.utils.mongo import MongoSingleton -from discord_analyzer.metrics.utils import Platform +from tc_analyzer_lib.utils.mongo import MongoSingleton +from tc_analyzer_lib.metrics.utils import Platform class TestPlatformUtilsFetchResources(TestCase): diff --git a/tests/integration/test_analyzer_utils_platform.py b/tests/integration/test_analyzer_utils_platform.py index 51e5dbc..8cad941 100644 --- a/tests/integration/test_analyzer_utils_platform.py +++ b/tests/integration/test_analyzer_utils_platform.py @@ -1,8 +1,8 @@ from bson import ObjectId from unittest import TestCase -from discord_analyzer.metrics.utils import Platform -from discord_analyzer.utils.mongo import MongoSingleton +from tc_analyzer_lib.metrics.utils import Platform +from tc_analyzer_lib.utils.mongo import MongoSingleton class TestAnalyzerUtilsPlatform(TestCase): diff --git a/tests/integration/test_analyzer_utils_platform_parameters.py b/tests/integration/test_analyzer_utils_platform_parameters.py index c439592..49365e9 100644 --- a/tests/integration/test_analyzer_utils_platform_parameters.py +++ b/tests/integration/test_analyzer_utils_platform_parameters.py @@ -2,8 +2,8 @@ from unittest import TestCase from datetime import datetime, timedelta -from discord_analyzer.metrics.utils import Platform -from discord_analyzer.utils.mongo import MongoSingleton +from tc_analyzer_lib.metrics.utils import Platform +from tc_analyzer_lib.utils.mongo import MongoSingleton class TestAnalyzerUtilsPlatform(TestCase): diff --git a/tests/integration/test_assess_engagement_mention.py b/tests/integration/test_assess_engagement_mention.py index 6c69a3a..9a0f05e 100644 --- a/tests/integration/test_assess_engagement_mention.py +++ b/tests/integration/test_assess_engagement_mention.py @@ -1,14 +1,14 @@ from datetime import datetime, timedelta from unittest import TestCase -from discord_analyzer.algorithms.utils.member_activity_utils import assess_engagement -from discord_analyzer.metrics.utils.analyzer_db_manager import AnalyzerDBManager +from tc_analyzer_lib.algorithms.utils.member_activity_utils import assess_engagement +from tc_analyzer_lib.metrics.utils.analyzer_db_manager import AnalyzerDBManager from .utils.analyzer_setup import launch_db_access from .utils.setup_platform import setup_platform -from discord_analyzer.metrics.heatmaps import Heatmaps -from discord_analyzer.schemas import GraphSchema -from discord_analyzer.schemas.platform_configs import DiscordAnalyzerConfig +from tc_analyzer_lib.metrics.heatmaps import Heatmaps +from tc_analyzer_lib.schemas import GraphSchema +from tc_analyzer_lib.schemas.platform_configs import DiscordAnalyzerConfig class TestAssessEngagementMentions(TestCase): diff --git a/tests/integration/test_assess_engagement_reactions.py b/tests/integration/test_assess_engagement_reactions.py index 97af4a4..4ac59f7 100644 --- a/tests/integration/test_assess_engagement_reactions.py +++ b/tests/integration/test_assess_engagement_reactions.py @@ -1,14 +1,14 @@ from datetime import datetime, timedelta from unittest import TestCase -from discord_analyzer.algorithms.utils.member_activity_utils import assess_engagement -from discord_analyzer.metrics.utils.analyzer_db_manager import AnalyzerDBManager +from tc_analyzer_lib.algorithms.utils.member_activity_utils import assess_engagement +from tc_analyzer_lib.metrics.utils.analyzer_db_manager import AnalyzerDBManager from .utils.analyzer_setup import launch_db_access from .utils.setup_platform import setup_platform -from discord_analyzer.metrics.heatmaps import Heatmaps -from discord_analyzer.schemas import GraphSchema -from discord_analyzer.schemas.platform_configs import DiscordAnalyzerConfig +from tc_analyzer_lib.metrics.heatmaps import Heatmaps +from tc_analyzer_lib.schemas import GraphSchema +from tc_analyzer_lib.schemas.platform_configs import DiscordAnalyzerConfig class TestAssessEngagementReactions(TestCase): diff --git a/tests/integration/test_assess_engagement_replies.py b/tests/integration/test_assess_engagement_replies.py index f752d8c..eff015b 100644 --- a/tests/integration/test_assess_engagement_replies.py +++ b/tests/integration/test_assess_engagement_replies.py @@ -1,14 +1,14 @@ from datetime import datetime, timedelta from unittest import TestCase -from discord_analyzer.algorithms.utils.member_activity_utils import assess_engagement -from discord_analyzer.metrics.utils.analyzer_db_manager import AnalyzerDBManager +from tc_analyzer_lib.algorithms.utils.member_activity_utils import assess_engagement +from tc_analyzer_lib.metrics.utils.analyzer_db_manager import AnalyzerDBManager from .utils.analyzer_setup import launch_db_access from .utils.setup_platform import setup_platform -from discord_analyzer.metrics.heatmaps import Heatmaps -from discord_analyzer.schemas import GraphSchema -from discord_analyzer.schemas.platform_configs import DiscordAnalyzerConfig +from tc_analyzer_lib.metrics.heatmaps import Heatmaps +from tc_analyzer_lib.schemas import GraphSchema +from tc_analyzer_lib.schemas.platform_configs import DiscordAnalyzerConfig class TestAssessEngagementReplies(TestCase): diff --git a/tests/integration/test_automation_base_create_manual_saga.py b/tests/integration/test_automation_base_create_manual_saga.py index 8b7230d..ab3de7a 100644 --- a/tests/integration/test_automation_base_create_manual_saga.py +++ b/tests/integration/test_automation_base_create_manual_saga.py @@ -1,6 +1,6 @@ import unittest -from discord_analyzer.automation.utils.automation_base import AutomationBase +from tc_analyzer_lib.automation.utils.automation_base import AutomationBase from .utils.analyzer_setup import launch_db_access diff --git a/tests/integration/test_automation_base_get_users_from_memberactivities_empty_database.py b/tests/integration/test_automation_base_get_users_from_memberactivities_empty_database.py index 7560d5a..8a59bfc 100644 --- a/tests/integration/test_automation_base_get_users_from_memberactivities_empty_database.py +++ b/tests/integration/test_automation_base_get_users_from_memberactivities_empty_database.py @@ -1,6 +1,6 @@ from datetime import datetime, timedelta -from discord_analyzer.automation.utils.automation_base import AutomationBase +from tc_analyzer_lib.automation.utils.automation_base import AutomationBase from .utils.analyzer_setup import launch_db_access diff --git a/tests/integration/test_automation_base_get_users_from_memberactivities_filled_database.py b/tests/integration/test_automation_base_get_users_from_memberactivities_filled_database.py index 202d731..8797173 100644 --- a/tests/integration/test_automation_base_get_users_from_memberactivities_filled_database.py +++ b/tests/integration/test_automation_base_get_users_from_memberactivities_filled_database.py @@ -1,6 +1,6 @@ from datetime import datetime, timedelta -from discord_analyzer.automation.utils.automation_base import AutomationBase +from tc_analyzer_lib.automation.utils.automation_base import AutomationBase from .utils.analyzer_setup import launch_db_access diff --git a/tests/integration/test_automation_base_prepare_names_globalname.py b/tests/integration/test_automation_base_prepare_names_globalname.py index 904d58a..4a83ed8 100644 --- a/tests/integration/test_automation_base_prepare_names_globalname.py +++ b/tests/integration/test_automation_base_prepare_names_globalname.py @@ -1,6 +1,6 @@ from datetime import datetime, timedelta -from discord_analyzer.automation.utils.automation_base import AutomationBase +from tc_analyzer_lib.automation.utils.automation_base import AutomationBase from .utils.analyzer_setup import launch_db_access diff --git a/tests/integration/test_automation_base_prepare_names_ngu.py b/tests/integration/test_automation_base_prepare_names_ngu.py index 69783a5..70c695f 100644 --- a/tests/integration/test_automation_base_prepare_names_ngu.py +++ b/tests/integration/test_automation_base_prepare_names_ngu.py @@ -1,6 +1,6 @@ from datetime import datetime, timedelta -from discord_analyzer.automation.utils.automation_base import AutomationBase +from tc_analyzer_lib.automation.utils.automation_base import AutomationBase from .utils.analyzer_setup import launch_db_access diff --git a/tests/integration/test_automation_base_prepare_names_nickname.py b/tests/integration/test_automation_base_prepare_names_nickname.py index f12bfe3..d516001 100644 --- a/tests/integration/test_automation_base_prepare_names_nickname.py +++ b/tests/integration/test_automation_base_prepare_names_nickname.py @@ -1,6 +1,6 @@ from datetime import datetime, timedelta -from discord_analyzer.automation.utils.automation_base import AutomationBase +from tc_analyzer_lib.automation.utils.automation_base import AutomationBase from .utils.analyzer_setup import launch_db_access diff --git a/tests/integration/test_automation_base_prepare_names_usernames.py b/tests/integration/test_automation_base_prepare_names_usernames.py index 53e2403..89edf25 100644 --- a/tests/integration/test_automation_base_prepare_names_usernames.py +++ b/tests/integration/test_automation_base_prepare_names_usernames.py @@ -1,6 +1,6 @@ from datetime import datetime, timedelta -from discord_analyzer.automation.utils.automation_base import AutomationBase +from tc_analyzer_lib.automation.utils.automation_base import AutomationBase from .utils.analyzer_setup import launch_db_access diff --git a/tests/integration/test_automation_db_load_from_db.py b/tests/integration/test_automation_db_load_from_db.py index c0a2886..5a758e2 100644 --- a/tests/integration/test_automation_db_load_from_db.py +++ b/tests/integration/test_automation_db_load_from_db.py @@ -2,9 +2,9 @@ import unittest from datetime import datetime, timedelta -from discord_analyzer.automation.utils.model import AutomationDB +from tc_analyzer_lib.automation.utils.model import AutomationDB from dotenv import load_dotenv -from discord_analyzer.utils.mongo import MongoSingleton +from tc_analyzer_lib.utils.mongo import MongoSingleton class TestAutomationDBLoadFromDB(unittest.TestCase): diff --git a/tests/integration/test_automation_db_save_to_db.py b/tests/integration/test_automation_db_save_to_db.py index 25d41e8..3d650c0 100644 --- a/tests/integration/test_automation_db_save_to_db.py +++ b/tests/integration/test_automation_db_save_to_db.py @@ -2,10 +2,10 @@ import unittest from datetime import datetime, timezone -from discord_analyzer.automation.utils.interfaces import Automation -from discord_analyzer.automation.utils.model import AutomationDB +from tc_analyzer_lib.automation.utils.interfaces import Automation +from tc_analyzer_lib.automation.utils.model import AutomationDB from dotenv import load_dotenv -from discord_analyzer.utils.mongo import MongoSingleton +from tc_analyzer_lib.utils.mongo import MongoSingleton class TestAutomationDBSaveToDB(unittest.TestCase): diff --git a/tests/integration/test_automation_fire_messages_mongo_saga_message_ngu_strategy.py b/tests/integration/test_automation_fire_messages_mongo_saga_message_ngu_strategy.py index 8bec35c..a084620 100644 --- a/tests/integration/test_automation_fire_messages_mongo_saga_message_ngu_strategy.py +++ b/tests/integration/test_automation_fire_messages_mongo_saga_message_ngu_strategy.py @@ -1,7 +1,7 @@ from datetime import datetime, timedelta -from discord_analyzer.automation.automation_workflow import AutomationWorkflow -from discord_analyzer.automation.utils.interfaces import ( +from tc_analyzer_lib.automation.automation_workflow import AutomationWorkflow +from tc_analyzer_lib.automation.utils.interfaces import ( Automation, AutomationAction, AutomationReport, diff --git a/tests/integration/test_automation_fire_messages_mongo_saga_message_nickname_strategy.py b/tests/integration/test_automation_fire_messages_mongo_saga_message_nickname_strategy.py index 0908295..754a4b1 100644 --- a/tests/integration/test_automation_fire_messages_mongo_saga_message_nickname_strategy.py +++ b/tests/integration/test_automation_fire_messages_mongo_saga_message_nickname_strategy.py @@ -1,7 +1,7 @@ from datetime import datetime, timedelta -from discord_analyzer.automation.automation_workflow import AutomationWorkflow -from discord_analyzer.automation.utils.interfaces import ( +from tc_analyzer_lib.automation.automation_workflow import AutomationWorkflow +from tc_analyzer_lib.automation.utils.interfaces import ( Automation, AutomationAction, AutomationReport, diff --git a/tests/integration/test_automation_fire_messages_mongo_saga_message_no_handlebar.py b/tests/integration/test_automation_fire_messages_mongo_saga_message_no_handlebar.py index 65120fb..3f2715a 100644 --- a/tests/integration/test_automation_fire_messages_mongo_saga_message_no_handlebar.py +++ b/tests/integration/test_automation_fire_messages_mongo_saga_message_no_handlebar.py @@ -1,7 +1,7 @@ from datetime import datetime, timedelta -from discord_analyzer.automation.automation_workflow import AutomationWorkflow -from discord_analyzer.automation.utils.interfaces import ( +from tc_analyzer_lib.automation.automation_workflow import AutomationWorkflow +from tc_analyzer_lib.automation.utils.interfaces import ( Automation, AutomationAction, AutomationReport, diff --git a/tests/integration/test_automation_fire_messages_mongo_saga_message_username_strategy.py b/tests/integration/test_automation_fire_messages_mongo_saga_message_username_strategy.py index e3712c2..2c6fe1c 100644 --- a/tests/integration/test_automation_fire_messages_mongo_saga_message_username_strategy.py +++ b/tests/integration/test_automation_fire_messages_mongo_saga_message_username_strategy.py @@ -1,7 +1,7 @@ from datetime import datetime, timedelta -from discord_analyzer.automation.automation_workflow import AutomationWorkflow -from discord_analyzer.automation.utils.interfaces import ( +from tc_analyzer_lib.automation.automation_workflow import AutomationWorkflow +from tc_analyzer_lib.automation.utils.interfaces import ( Automation, AutomationAction, AutomationReport, diff --git a/tests/integration/test_decentralization_score.py b/tests/integration/test_decentralization_score.py index 1b82408..bc722fa 100644 --- a/tests/integration/test_decentralization_score.py +++ b/tests/integration/test_decentralization_score.py @@ -1,6 +1,6 @@ # the nodes of the graph are partially connected -from discord_analyzer.algorithms.neo4j_analysis.centrality import Centerality -from discord_analyzer.schemas import GraphSchema +from tc_analyzer_lib.algorithms.neo4j_analysis.centrality import Centerality +from tc_analyzer_lib.schemas import GraphSchema from tc_neo4j_lib.neo4j_ops import Neo4jOps diff --git a/tests/integration/test_degree_centrality_multiple_guilds.py b/tests/integration/test_degree_centrality_multiple_guilds.py index ee2338d..8dcc8e8 100644 --- a/tests/integration/test_degree_centrality_multiple_guilds.py +++ b/tests/integration/test_degree_centrality_multiple_guilds.py @@ -1,7 +1,7 @@ # we have nodes of a community is connected to another one # meaning we have nodes available in more than one community -from discord_analyzer.algorithms.neo4j_analysis.centrality import Centerality -from discord_analyzer.schemas import GraphSchema +from tc_analyzer_lib.algorithms.neo4j_analysis.centrality import Centerality +from tc_analyzer_lib.schemas import GraphSchema from tc_neo4j_lib.neo4j_ops import Neo4jOps diff --git a/tests/integration/test_degree_centrality_multiple_guilds_preserve_parallel.py b/tests/integration/test_degree_centrality_multiple_guilds_preserve_parallel.py index 64fa8b3..27915ec 100644 --- a/tests/integration/test_degree_centrality_multiple_guilds_preserve_parallel.py +++ b/tests/integration/test_degree_centrality_multiple_guilds_preserve_parallel.py @@ -1,7 +1,7 @@ # we have nodes of a community is connected to another one # meaning we have nodes available in more than one community -from discord_analyzer.algorithms.neo4j_analysis.centrality import Centerality -from discord_analyzer.schemas import GraphSchema +from tc_analyzer_lib.algorithms.neo4j_analysis.centrality import Centerality +from tc_analyzer_lib.schemas import GraphSchema from tc_neo4j_lib.neo4j_ops import Neo4jOps diff --git a/tests/integration/test_degree_centrality_parallel_preservation.py b/tests/integration/test_degree_centrality_parallel_preservation.py index e89f921..5e5e286 100644 --- a/tests/integration/test_degree_centrality_parallel_preservation.py +++ b/tests/integration/test_degree_centrality_parallel_preservation.py @@ -1,6 +1,6 @@ # the nodes of the graph are partially connected -from discord_analyzer.algorithms.neo4j_analysis.centrality import Centerality -from discord_analyzer.schemas import GraphSchema +from tc_analyzer_lib.algorithms.neo4j_analysis.centrality import Centerality +from tc_analyzer_lib.schemas import GraphSchema from tc_neo4j_lib.neo4j_ops import Neo4jOps diff --git a/tests/integration/test_discord_heatmaps_config.py b/tests/integration/test_discord_heatmaps_config.py index 6ab12f2..0773474 100644 --- a/tests/integration/test_discord_heatmaps_config.py +++ b/tests/integration/test_discord_heatmaps_config.py @@ -1,7 +1,7 @@ from unittest import TestCase -from discord_analyzer.schemas import ActivityDirection, ActivityType -from discord_analyzer.schemas.platform_configs import DiscordAnalyzerConfig +from tc_analyzer_lib.schemas import ActivityDirection, ActivityType +from tc_analyzer_lib.schemas.platform_configs import DiscordAnalyzerConfig class TestDiscordAnalyzerConfig(TestCase): diff --git a/tests/integration/test_fragmentation_score.py b/tests/integration/test_fragmentation_score.py index 915a3ed..cdbf69e 100644 --- a/tests/integration/test_fragmentation_score.py +++ b/tests/integration/test_fragmentation_score.py @@ -1,7 +1,7 @@ from datetime import datetime, timedelta -from discord_analyzer.metrics.neo4j_analytics import Neo4JAnalytics -from discord_analyzer.schemas import GraphSchema +from tc_analyzer_lib.metrics.neo4j_analytics import Neo4JAnalytics +from tc_analyzer_lib.schemas import GraphSchema from tc_neo4j_lib.neo4j_ops import Neo4jOps diff --git a/tests/integration/test_fragmentation_score_exclude_past.py b/tests/integration/test_fragmentation_score_exclude_past.py index 6eba0e9..39dde9f 100644 --- a/tests/integration/test_fragmentation_score_exclude_past.py +++ b/tests/integration/test_fragmentation_score_exclude_past.py @@ -1,7 +1,7 @@ from datetime import datetime, timedelta -from discord_analyzer.metrics.neo4j_analytics import Neo4JAnalytics -from discord_analyzer.schemas import GraphSchema +from tc_analyzer_lib.metrics.neo4j_analytics import Neo4JAnalytics +from tc_analyzer_lib.schemas import GraphSchema from tc_neo4j_lib.neo4j_ops import Neo4jOps diff --git a/tests/integration/test_fragmentation_score_from_start.py b/tests/integration/test_fragmentation_score_from_start.py index db1c4cd..b1c0e90 100644 --- a/tests/integration/test_fragmentation_score_from_start.py +++ b/tests/integration/test_fragmentation_score_from_start.py @@ -1,7 +1,7 @@ from datetime import datetime, timedelta -from discord_analyzer.metrics.neo4j_analytics import Neo4JAnalytics -from discord_analyzer.schemas import GraphSchema +from tc_analyzer_lib.metrics.neo4j_analytics import Neo4JAnalytics +from tc_analyzer_lib.schemas import GraphSchema from tc_neo4j_lib.neo4j_ops import Neo4jOps diff --git a/tests/integration/test_fragmentation_score_rescaling.py b/tests/integration/test_fragmentation_score_rescaling.py index 85540c0..0273537 100644 --- a/tests/integration/test_fragmentation_score_rescaling.py +++ b/tests/integration/test_fragmentation_score_rescaling.py @@ -1,7 +1,7 @@ from datetime import datetime, timedelta -from discord_analyzer.metrics.neo4j_analytics import Neo4JAnalytics -from discord_analyzer.schemas import GraphSchema +from tc_analyzer_lib.metrics.neo4j_analytics import Neo4JAnalytics +from tc_analyzer_lib.schemas import GraphSchema from tc_neo4j_lib.neo4j_ops import Neo4jOps diff --git a/tests/integration/test_get_guild_community_ids.py b/tests/integration/test_get_guild_community_ids.py index 0ee257f..b0c0b1e 100644 --- a/tests/integration/test_get_guild_community_ids.py +++ b/tests/integration/test_get_guild_community_ids.py @@ -2,8 +2,8 @@ from unittest import TestCase from bson.objectid import ObjectId -from discord_analyzer.utils.get_guild_utils import get_platform_guild_id -from discord_analyzer.utils.mongo import MongoSingleton +from tc_analyzer_lib.utils.get_guild_utils import get_platform_guild_id +from tc_analyzer_lib.utils.mongo import MongoSingleton class TestGetGuildId(TestCase): diff --git a/tests/integration/test_get_guild_owner.py b/tests/integration/test_get_guild_owner.py index 9cc08a8..0444706 100644 --- a/tests/integration/test_get_guild_owner.py +++ b/tests/integration/test_get_guild_owner.py @@ -2,8 +2,8 @@ from unittest import TestCase from datetime import datetime, timedelta -from discord_analyzer.utils.mongo import MongoSingleton -from discord_analyzer.utils.get_guild_utils import get_platform_community_owner +from tc_analyzer_lib.utils.mongo import MongoSingleton +from tc_analyzer_lib.utils.get_guild_utils import get_platform_community_owner class TestGetGuildOwner(TestCase): diff --git a/tests/integration/test_get_guild_platform_id.py b/tests/integration/test_get_guild_platform_id.py index 63966fc..bb125b7 100644 --- a/tests/integration/test_get_guild_platform_id.py +++ b/tests/integration/test_get_guild_platform_id.py @@ -2,8 +2,8 @@ from unittest import TestCase from bson.objectid import ObjectId -from discord_analyzer.utils.get_guild_utils import get_guild_platform_id -from discord_analyzer.utils.mongo import MongoSingleton +from tc_analyzer_lib.utils.get_guild_utils import get_guild_platform_id +from tc_analyzer_lib.utils.mongo import MongoSingleton class TestGetGuildId(TestCase): diff --git a/tests/integration/test_get_past_7_days_heatmaps.py b/tests/integration/test_get_past_7_days_heatmaps.py index 52cb174..25d2076 100644 --- a/tests/integration/test_get_past_7_days_heatmaps.py +++ b/tests/integration/test_get_past_7_days_heatmaps.py @@ -1,7 +1,7 @@ from datetime import datetime, timedelta import numpy as np -from discord_analyzer.algorithms.utils.member_activity_utils import ( +from tc_analyzer_lib.algorithms.utils.member_activity_utils import ( get_users_past_window, ) diff --git a/tests/integration/test_heatmaps_analytics.py b/tests/integration/test_heatmaps_analytics.py index 770ec84..e7a434b 100644 --- a/tests/integration/test_heatmaps_analytics.py +++ b/tests/integration/test_heatmaps_analytics.py @@ -1,9 +1,9 @@ from datetime import datetime, timedelta from unittest import TestCase -from discord_analyzer.metrics.heatmaps import Heatmaps -from discord_analyzer.schemas.platform_configs import DiscordAnalyzerConfig -from discord_analyzer.utils.mongo import MongoSingleton +from tc_analyzer_lib.metrics.heatmaps import Heatmaps +from tc_analyzer_lib.schemas.platform_configs import DiscordAnalyzerConfig +from tc_analyzer_lib.utils.mongo import MongoSingleton class TestHeatmapsAnalytics(TestCase): diff --git a/tests/integration/test_heatmaps_analytics_base.py b/tests/integration/test_heatmaps_analytics_base.py index a2f4baf..ed47f74 100644 --- a/tests/integration/test_heatmaps_analytics_base.py +++ b/tests/integration/test_heatmaps_analytics_base.py @@ -1,8 +1,8 @@ from datetime import datetime from unittest import TestCase -from discord_analyzer.metrics.heatmaps.analytics_hourly import AnalyticsHourly -from discord_analyzer.utils.mongo import MongoSingleton +from tc_analyzer_lib.metrics.heatmaps.analytics_hourly import AnalyticsHourly +from tc_analyzer_lib.utils.mongo import MongoSingleton class TestHeatmapsAnalyticsBaseWithFilter(TestCase): diff --git a/tests/integration/test_heatmaps_analytics_different_source.py b/tests/integration/test_heatmaps_analytics_different_source.py index cba667c..3d66b9c 100644 --- a/tests/integration/test_heatmaps_analytics_different_source.py +++ b/tests/integration/test_heatmaps_analytics_different_source.py @@ -1,9 +1,9 @@ from datetime import datetime, timedelta from unittest import TestCase -from discord_analyzer.metrics.heatmaps import Heatmaps -from discord_analyzer.schemas.platform_configs import DiscordAnalyzerConfig -from discord_analyzer.utils.mongo import MongoSingleton +from tc_analyzer_lib.metrics.heatmaps import Heatmaps +from tc_analyzer_lib.schemas.platform_configs import DiscordAnalyzerConfig +from tc_analyzer_lib.utils.mongo import MongoSingleton class TestHeatmapsAnalyticsSingleDay(TestCase): diff --git a/tests/integration/test_heatmaps_analytics_hourly_no_filter.py b/tests/integration/test_heatmaps_analytics_hourly_no_filter.py index 1106763..f2f8bad 100644 --- a/tests/integration/test_heatmaps_analytics_hourly_no_filter.py +++ b/tests/integration/test_heatmaps_analytics_hourly_no_filter.py @@ -1,8 +1,8 @@ from datetime import datetime from unittest import TestCase -from discord_analyzer.metrics.heatmaps.analytics_hourly import AnalyticsHourly -from discord_analyzer.utils.mongo import MongoSingleton +from tc_analyzer_lib.metrics.heatmaps.analytics_hourly import AnalyticsHourly +from tc_analyzer_lib.utils.mongo import MongoSingleton class TestHeatmapsAnalyticsBaseNoFilter(TestCase): diff --git a/tests/integration/test_heatmaps_analytics_raw.py b/tests/integration/test_heatmaps_analytics_raw.py index 0ad8076..4c73e29 100644 --- a/tests/integration/test_heatmaps_analytics_raw.py +++ b/tests/integration/test_heatmaps_analytics_raw.py @@ -1,9 +1,9 @@ from datetime import datetime, timedelta from unittest import TestCase -from discord_analyzer.metrics.heatmaps.analytics_raw import AnalyticsRaw -from discord_analyzer.schemas import ActivityDirection, RawAnalyticsItem -from discord_analyzer.utils.mongo import MongoSingleton +from tc_analyzer_lib.metrics.heatmaps.analytics_raw import AnalyticsRaw +from tc_analyzer_lib.schemas import ActivityDirection, RawAnalyticsItem +from tc_analyzer_lib.utils.mongo import MongoSingleton class TestHeatmapsRawAnalytics(TestCase): diff --git a/tests/integration/test_heatmaps_hourly_analytics_actions_vectors.py b/tests/integration/test_heatmaps_hourly_analytics_actions_vectors.py index 2e65636..5f5d6a7 100644 --- a/tests/integration/test_heatmaps_hourly_analytics_actions_vectors.py +++ b/tests/integration/test_heatmaps_hourly_analytics_actions_vectors.py @@ -1,8 +1,8 @@ from datetime import datetime from unittest import TestCase -from discord_analyzer.metrics.heatmaps.analytics_hourly import AnalyticsHourly -from discord_analyzer.utils.mongo import MongoSingleton +from tc_analyzer_lib.metrics.heatmaps.analytics_hourly import AnalyticsHourly +from tc_analyzer_lib.utils.mongo import MongoSingleton class TestHeatmapsRawAnalyticsVectorsActions(TestCase): diff --git a/tests/integration/test_heatmaps_hourly_analytics_interaction_vectors.py b/tests/integration/test_heatmaps_hourly_analytics_interaction_vectors.py index dfe3d88..2587e16 100644 --- a/tests/integration/test_heatmaps_hourly_analytics_interaction_vectors.py +++ b/tests/integration/test_heatmaps_hourly_analytics_interaction_vectors.py @@ -1,8 +1,8 @@ from datetime import datetime from unittest import TestCase -from discord_analyzer.metrics.heatmaps.analytics_hourly import AnalyticsHourly -from discord_analyzer.utils.mongo import MongoSingleton +from tc_analyzer_lib.metrics.heatmaps.analytics_hourly import AnalyticsHourly +from tc_analyzer_lib.utils.mongo import MongoSingleton class TestHeatmapsRawAnalyticsVectorsInteractions(TestCase): diff --git a/tests/integration/test_heatmaps_hourly_lone_message.py b/tests/integration/test_heatmaps_hourly_lone_message.py index c69b720..2ae5167 100644 --- a/tests/integration/test_heatmaps_hourly_lone_message.py +++ b/tests/integration/test_heatmaps_hourly_lone_message.py @@ -1,8 +1,8 @@ from datetime import datetime, timedelta -from discord_analyzer.metrics.heatmaps import Heatmaps -from discord_analyzer.schemas.platform_configs import DiscordAnalyzerConfig -from discord_analyzer.utils.mongo import MongoSingleton +from tc_analyzer_lib.metrics.heatmaps import Heatmaps +from tc_analyzer_lib.schemas.platform_configs import DiscordAnalyzerConfig +from tc_analyzer_lib.utils.mongo import MongoSingleton def test_lone_messages(): diff --git a/tests/integration/test_heatmaps_hourly_mentions.py b/tests/integration/test_heatmaps_hourly_mentions.py index e663ebd..4a56143 100644 --- a/tests/integration/test_heatmaps_hourly_mentions.py +++ b/tests/integration/test_heatmaps_hourly_mentions.py @@ -1,8 +1,8 @@ from datetime import datetime, timedelta -from discord_analyzer.metrics.heatmaps import Heatmaps -from discord_analyzer.schemas.platform_configs import DiscordAnalyzerConfig -from discord_analyzer.utils.mongo import MongoSingleton +from tc_analyzer_lib.metrics.heatmaps import Heatmaps +from tc_analyzer_lib.schemas.platform_configs import DiscordAnalyzerConfig +from tc_analyzer_lib.utils.mongo import MongoSingleton def test_mentioned_messages(): diff --git a/tests/integration/test_heatmaps_process_hourly_single_day.py b/tests/integration/test_heatmaps_process_hourly_single_day.py index d3434a6..2a47834 100644 --- a/tests/integration/test_heatmaps_process_hourly_single_day.py +++ b/tests/integration/test_heatmaps_process_hourly_single_day.py @@ -1,9 +1,9 @@ from datetime import datetime from unittest import TestCase -from discord_analyzer.metrics.heatmaps import Heatmaps -from discord_analyzer.schemas.platform_configs import DiscordAnalyzerConfig -from discord_analyzer.utils.mongo import MongoSingleton +from tc_analyzer_lib.metrics.heatmaps import Heatmaps +from tc_analyzer_lib.schemas.platform_configs import DiscordAnalyzerConfig +from tc_analyzer_lib.utils.mongo import MongoSingleton class TestHeatmapsProcessHourlySingleDay(TestCase): diff --git a/tests/integration/test_heatmaps_process_raw_analytics.py b/tests/integration/test_heatmaps_process_raw_analytics.py index 51b9508..18eeb69 100644 --- a/tests/integration/test_heatmaps_process_raw_analytics.py +++ b/tests/integration/test_heatmaps_process_raw_analytics.py @@ -1,9 +1,9 @@ from datetime import datetime from unittest import TestCase -from discord_analyzer.metrics.heatmaps import Heatmaps -from discord_analyzer.schemas.platform_configs import DiscordAnalyzerConfig -from discord_analyzer.utils.mongo import MongoSingleton +from tc_analyzer_lib.metrics.heatmaps import Heatmaps +from tc_analyzer_lib.schemas.platform_configs import DiscordAnalyzerConfig +from tc_analyzer_lib.utils.mongo import MongoSingleton class TestHeatmapsProcessRawAnalyticsSingleDay(TestCase): diff --git a/tests/integration/test_heatmaps_reactions.py b/tests/integration/test_heatmaps_reactions.py index e1e05f9..09cd53b 100644 --- a/tests/integration/test_heatmaps_reactions.py +++ b/tests/integration/test_heatmaps_reactions.py @@ -1,8 +1,8 @@ from datetime import datetime, timedelta -from discord_analyzer.metrics.heatmaps import Heatmaps -from discord_analyzer.schemas.platform_configs import DiscordAnalyzerConfig -from discord_analyzer.utils.mongo import MongoSingleton +from tc_analyzer_lib.metrics.heatmaps import Heatmaps +from tc_analyzer_lib.schemas.platform_configs import DiscordAnalyzerConfig +from tc_analyzer_lib.utils.mongo import MongoSingleton def test_reacted_messages(): diff --git a/tests/integration/test_heatmaps_replier.py b/tests/integration/test_heatmaps_replier.py index 4c46f80..a716060 100644 --- a/tests/integration/test_heatmaps_replier.py +++ b/tests/integration/test_heatmaps_replier.py @@ -1,8 +1,8 @@ from datetime import datetime, timedelta -from discord_analyzer.metrics.heatmaps import Heatmaps -from discord_analyzer.schemas.platform_configs import DiscordAnalyzerConfig -from discord_analyzer.utils.mongo import MongoSingleton +from tc_analyzer_lib.metrics.heatmaps import Heatmaps +from tc_analyzer_lib.schemas.platform_configs import DiscordAnalyzerConfig +from tc_analyzer_lib.utils.mongo import MongoSingleton def test_reply_messages(): diff --git a/tests/integration/test_heatmaps_thread_msg.py b/tests/integration/test_heatmaps_thread_msg.py index f354e6f..09fa994 100644 --- a/tests/integration/test_heatmaps_thread_msg.py +++ b/tests/integration/test_heatmaps_thread_msg.py @@ -1,8 +1,8 @@ from datetime import datetime, timedelta -from discord_analyzer.metrics.heatmaps import Heatmaps -from discord_analyzer.schemas.platform_configs import DiscordAnalyzerConfig -from discord_analyzer.utils.mongo import MongoSingleton +from tc_analyzer_lib.metrics.heatmaps import Heatmaps +from tc_analyzer_lib.schemas.platform_configs import DiscordAnalyzerConfig +from tc_analyzer_lib.utils.mongo import MongoSingleton def test_thread_messages(): diff --git a/tests/integration/test_heatmaps_utils.py b/tests/integration/test_heatmaps_utils.py index 6e74ecb..a9cb018 100644 --- a/tests/integration/test_heatmaps_utils.py +++ b/tests/integration/test_heatmaps_utils.py @@ -1,8 +1,8 @@ from datetime import datetime from unittest import TestCase -from discord_analyzer.metrics.heatmaps.heatmaps_utils import HeatmapsUtils -from discord_analyzer.utils.mongo import MongoSingleton +from tc_analyzer_lib.metrics.heatmaps.heatmaps_utils import HeatmapsUtils +from tc_analyzer_lib.utils.mongo import MongoSingleton class TestHeatmapsUtils(TestCase): diff --git a/tests/integration/test_interacted_in_deletion.py b/tests/integration/test_interacted_in_deletion.py index ad0eb58..6c3227d 100644 --- a/tests/integration/test_interacted_in_deletion.py +++ b/tests/integration/test_interacted_in_deletion.py @@ -1,5 +1,5 @@ -from discord_analyzer.metrics.neo4j_analytics import Neo4JAnalytics -from discord_analyzer.schemas import GraphSchema +from tc_analyzer_lib.metrics.neo4j_analytics import Neo4JAnalytics +from tc_analyzer_lib.schemas import GraphSchema from tc_neo4j_lib.neo4j_ops import Neo4jOps diff --git a/tests/integration/test_lcc_all_connected.py b/tests/integration/test_lcc_all_connected.py index 5478b9d..1b2f172 100644 --- a/tests/integration/test_lcc_all_connected.py +++ b/tests/integration/test_lcc_all_connected.py @@ -1,8 +1,8 @@ # test out local clustering coefficient with all nodes connected -from discord_analyzer.algorithms.neo4j_analysis.local_clustering_coefficient import ( +from tc_analyzer_lib.algorithms.neo4j_analysis.local_clustering_coefficient import ( LocalClusteringCoeff, ) -from discord_analyzer.schemas import GraphSchema +from tc_analyzer_lib.schemas import GraphSchema from tc_neo4j_lib.neo4j_ops import Neo4jOps diff --git a/tests/integration/test_lcc_partially_connected.py b/tests/integration/test_lcc_partially_connected.py index 8ee598b..a00ea58 100644 --- a/tests/integration/test_lcc_partially_connected.py +++ b/tests/integration/test_lcc_partially_connected.py @@ -1,8 +1,8 @@ # the nodes of the graph are partially connected -from discord_analyzer.algorithms.neo4j_analysis.local_clustering_coefficient import ( +from tc_analyzer_lib.algorithms.neo4j_analysis.local_clustering_coefficient import ( LocalClusteringCoeff, ) -from discord_analyzer.schemas import GraphSchema +from tc_analyzer_lib.schemas import GraphSchema from tc_neo4j_lib.neo4j_ops import Neo4jOps diff --git a/tests/integration/test_louvain_algorithm_computation.py b/tests/integration/test_louvain_algorithm_computation.py index be10dc0..7a336b3 100644 --- a/tests/integration/test_louvain_algorithm_computation.py +++ b/tests/integration/test_louvain_algorithm_computation.py @@ -1,5 +1,5 @@ -from discord_analyzer.algorithms.neo4j_analysis.louvain import Louvain -from discord_analyzer.schemas import GraphSchema +from tc_analyzer_lib.algorithms.neo4j_analysis.louvain import Louvain +from tc_analyzer_lib.schemas import GraphSchema from tc_neo4j_lib.neo4j_ops import Neo4jOps diff --git a/tests/integration/test_louvain_algorithm_get_computed_dates.py b/tests/integration/test_louvain_algorithm_get_computed_dates.py index 81f299a..e76fb6b 100644 --- a/tests/integration/test_louvain_algorithm_get_computed_dates.py +++ b/tests/integration/test_louvain_algorithm_get_computed_dates.py @@ -1,5 +1,5 @@ -from discord_analyzer.algorithms.neo4j_analysis.louvain import Louvain -from discord_analyzer.schemas import GraphSchema +from tc_analyzer_lib.algorithms.neo4j_analysis.louvain import Louvain +from tc_analyzer_lib.schemas import GraphSchema from tc_neo4j_lib.neo4j_ops import Neo4jOps diff --git a/tests/integration/test_member_activity_utils.py b/tests/integration/test_member_activity_utils.py index 22e0bf3..bcf8d69 100644 --- a/tests/integration/test_member_activity_utils.py +++ b/tests/integration/test_member_activity_utils.py @@ -1,6 +1,6 @@ from datetime import datetime, timedelta -from discord_analyzer.metrics.memberactivity_utils import MemberActivityUtils +from tc_analyzer_lib.metrics.memberactivity_utils import MemberActivityUtils from .utils.analyzer_setup import launch_db_access from .utils.setup_platform import setup_platform diff --git a/tests/integration/test_neo4j_compute_metrics.py b/tests/integration/test_neo4j_compute_metrics.py index c40d3e4..b94d825 100644 --- a/tests/integration/test_neo4j_compute_metrics.py +++ b/tests/integration/test_neo4j_compute_metrics.py @@ -1,6 +1,6 @@ import numpy as np -from discord_analyzer.metrics.neo4j_analytics import Neo4JAnalytics -from discord_analyzer.schemas import GraphSchema +from tc_analyzer_lib.metrics.neo4j_analytics import Neo4JAnalytics +from tc_analyzer_lib.schemas import GraphSchema from tc_neo4j_lib.neo4j_ops import Neo4jOps diff --git a/tests/integration/test_neo4j_compute_metrics_from_start.py b/tests/integration/test_neo4j_compute_metrics_from_start.py index 6aaf780..a4cbc2d 100644 --- a/tests/integration/test_neo4j_compute_metrics_from_start.py +++ b/tests/integration/test_neo4j_compute_metrics_from_start.py @@ -1,6 +1,6 @@ import numpy as np -from discord_analyzer.metrics.neo4j_analytics import Neo4JAnalytics -from discord_analyzer.schemas import GraphSchema +from tc_analyzer_lib.metrics.neo4j_analytics import Neo4JAnalytics +from tc_analyzer_lib.schemas import GraphSchema from tc_neo4j_lib.neo4j_ops import Neo4jOps diff --git a/tests/integration/test_neo4j_projection_utils_computed_dates.py b/tests/integration/test_neo4j_projection_utils_computed_dates.py index a0ff1cd..dcf6894 100644 --- a/tests/integration/test_neo4j_projection_utils_computed_dates.py +++ b/tests/integration/test_neo4j_projection_utils_computed_dates.py @@ -1,5 +1,5 @@ -from discord_analyzer.algorithms.neo4j_analysis.utils import ProjectionUtils -from discord_analyzer.schemas import GraphSchema +from tc_analyzer_lib.algorithms.neo4j_analysis.utils import ProjectionUtils +from tc_analyzer_lib.schemas import GraphSchema from tc_neo4j_lib.neo4j_ops import Neo4jOps diff --git a/tests/integration/test_network_graph_creation.py b/tests/integration/test_network_graph_creation.py index 95f10fe..d19f916 100644 --- a/tests/integration/test_network_graph_creation.py +++ b/tests/integration/test_network_graph_creation.py @@ -4,7 +4,7 @@ import networkx as nx import numpy as np import pytest -from discord_analyzer.algorithms.utils.activity import Activity +from tc_analyzer_lib.algorithms.utils.activity import Activity from tc_neo4j_lib.neo4j_ops import Neo4jOps diff --git a/tests/integration/test_node_stats.py b/tests/integration/test_node_stats.py index f038dff..ae1b08a 100644 --- a/tests/integration/test_node_stats.py +++ b/tests/integration/test_node_stats.py @@ -1,6 +1,6 @@ # test out local clustering coefficient with all nodes connected -from discord_analyzer.algorithms.neo4j_analysis.analyzer_node_stats import NodeStats -from discord_analyzer.schemas import GraphSchema +from tc_analyzer_lib.algorithms.neo4j_analysis.analyzer_node_stats import NodeStats +from tc_analyzer_lib.schemas import GraphSchema from tc_neo4j_lib.neo4j_ops import Neo4jOps diff --git a/tests/integration/test_platforms_base_config.py b/tests/integration/test_platforms_base_config.py index f316919..ec39cab 100644 --- a/tests/integration/test_platforms_base_config.py +++ b/tests/integration/test_platforms_base_config.py @@ -1,12 +1,12 @@ import unittest -from discord_analyzer.schemas import ( +from tc_analyzer_lib.schemas import ( ActivityDirection, ActivityType, HourlyAnalytics, RawAnalytics, ) -from discord_analyzer.schemas.platform_configs.config_base import PlatformConfigBase +from tc_analyzer_lib.schemas.platform_configs.config_base import PlatformConfigBase class TestPlatformBaseConfig(unittest.TestCase): diff --git a/tests/integration/test_publish_on_success_recompute_false.py b/tests/integration/test_publish_on_success_recompute_false.py index c82e89e..bb479a0 100644 --- a/tests/integration/test_publish_on_success_recompute_false.py +++ b/tests/integration/test_publish_on_success_recompute_false.py @@ -1,14 +1,14 @@ import os from datetime import datetime, timedelta -from discord_analyzer.automation.utils.interfaces import ( +from tc_analyzer_lib.automation.utils.interfaces import ( Automation, AutomationAction, AutomationReport, AutomationTrigger, ) from bson.objectid import ObjectId -from discord_analyzer.publish_on_success import publish_on_success +from tc_analyzer_lib.publish_on_success import publish_on_success from dotenv import load_dotenv from .utils.analyzer_setup import launch_db_access diff --git a/tests/integration/test_publish_on_success_recompute_true.py b/tests/integration/test_publish_on_success_recompute_true.py index e0bb8cf..8e25301 100644 --- a/tests/integration/test_publish_on_success_recompute_true.py +++ b/tests/integration/test_publish_on_success_recompute_true.py @@ -1,14 +1,14 @@ import os from datetime import datetime, timedelta -from discord_analyzer.automation.utils.interfaces import ( +from tc_analyzer_lib.automation.utils.interfaces import ( Automation, AutomationAction, AutomationReport, AutomationTrigger, ) from bson.objectid import ObjectId -from discord_analyzer.publish_on_success import publish_on_success +from tc_analyzer_lib.publish_on_success import publish_on_success from dotenv import load_dotenv from .utils.analyzer_setup import launch_db_access diff --git a/tests/integration/test_rawinfo_webhook_fetching.py b/tests/integration/test_rawinfo_webhook_fetching.py index a955aab..96e8575 100644 --- a/tests/integration/test_rawinfo_webhook_fetching.py +++ b/tests/integration/test_rawinfo_webhook_fetching.py @@ -1,7 +1,7 @@ from datetime import datetime, timedelta -from discord_analyzer.models.RawInfoModel import RawInfoModel -from discord_analyzer.utils.mongo import MongoSingleton +from tc_analyzer_lib.models.RawInfoModel import RawInfoModel +from tc_analyzer_lib.utils.mongo import MongoSingleton def test_rawinfo_get_day_entry_empty_data(): diff --git a/tests/integration/test_service_connection.py b/tests/integration/test_service_connection.py index 378bf82..94fa7b7 100644 --- a/tests/integration/test_service_connection.py +++ b/tests/integration/test_service_connection.py @@ -1,5 +1,5 @@ from tc_messageBroker.message_broker import RabbitMQ -from discord_analyzer.utils.credentials import get_rabbit_mq_credentials +from tc_analyzer_lib.utils.credentials import get_rabbit_mq_credentials def test_rabbit_mq_connect(): diff --git a/tests/integration/utils/analyzer_setup.py b/tests/integration/utils/analyzer_setup.py index b1bb25f..4e03ab2 100644 --- a/tests/integration/utils/analyzer_setup.py +++ b/tests/integration/utils/analyzer_setup.py @@ -1,4 +1,4 @@ -from discord_analyzer.DB_operations.mongodb_access import DB_access +from tc_analyzer_lib.DB_operations.mongodb_access import DB_access from dotenv import load_dotenv diff --git a/tests/integration/utils/mock_graph.py b/tests/integration/utils/mock_graph.py index bef5ae0..f4b1479 100644 --- a/tests/integration/utils/mock_graph.py +++ b/tests/integration/utils/mock_graph.py @@ -1,6 +1,6 @@ import os -from discord_analyzer.tc_analyzer import TCAnalyzer +from tc_analyzer_lib.tc_analyzer import TCAnalyzer from dotenv import load_dotenv from tc_core_analyzer_lib.assess_engagement import EngagementAssessment from tc_core_analyzer_lib.utils.activity import DiscordActivity diff --git a/tests/integration/utils/setup_platform.py b/tests/integration/utils/setup_platform.py index b7be425..3d50de8 100644 --- a/tests/integration/utils/setup_platform.py +++ b/tests/integration/utils/setup_platform.py @@ -3,8 +3,8 @@ import numpy as np from bson.objectid import ObjectId -from discord_analyzer.DB_operations.mongodb_access import DB_access -from discord_analyzer.tc_analyzer import TCAnalyzer +from tc_analyzer_lib.DB_operations.mongodb_access import DB_access +from tc_analyzer_lib.tc_analyzer import TCAnalyzer def setup_platform( diff --git a/tests/unit/test_analyzer_heatmaps_compute_iteration_counts.py b/tests/unit/test_analyzer_heatmaps_compute_iteration_counts.py index 8252ec8..5de93a5 100644 --- a/tests/unit/test_analyzer_heatmaps_compute_iteration_counts.py +++ b/tests/unit/test_analyzer_heatmaps_compute_iteration_counts.py @@ -1,8 +1,8 @@ from datetime import datetime from unittest import TestCase -from discord_analyzer.metrics.heatmaps import Heatmaps -from discord_analyzer.schemas.platform_configs import DiscordAnalyzerConfig +from tc_analyzer_lib.metrics.heatmaps import Heatmaps +from tc_analyzer_lib.schemas.platform_configs import DiscordAnalyzerConfig class TestAnalyzerHeatmapsIterationCount(TestCase): diff --git a/tests/unit/test_automation_class.py b/tests/unit/test_automation_class.py index 9243332..31aaf45 100644 --- a/tests/unit/test_automation_class.py +++ b/tests/unit/test_automation_class.py @@ -1,7 +1,7 @@ import unittest from datetime import datetime -from discord_analyzer.automation.utils.interfaces import ( +from tc_analyzer_lib.automation.utils.interfaces import ( Automation, AutomationAction, AutomationReport, diff --git a/tests/unit/test_automation_get_handler_type.py b/tests/unit/test_automation_get_handler_type.py index 17eaba0..434583c 100644 --- a/tests/unit/test_automation_get_handler_type.py +++ b/tests/unit/test_automation_get_handler_type.py @@ -1,6 +1,6 @@ import unittest -from discord_analyzer.automation.automation_workflow import AutomationWorkflow +from tc_analyzer_lib.automation.automation_workflow import AutomationWorkflow class TestGetHandlerType(unittest.TestCase): diff --git a/tests/unit/test_automation_trigger_action_report.py b/tests/unit/test_automation_trigger_action_report.py index e8f808a..c8b8802 100644 --- a/tests/unit/test_automation_trigger_action_report.py +++ b/tests/unit/test_automation_trigger_action_report.py @@ -1,6 +1,6 @@ import unittest -from discord_analyzer.automation.utils.interfaces import ( +from tc_analyzer_lib.automation.utils.interfaces import ( AutomationAction, AutomationReport, AutomationTrigger, diff --git a/tests/unit/test_compile_message.py b/tests/unit/test_compile_message.py index 4601501..d7a3239 100644 --- a/tests/unit/test_compile_message.py +++ b/tests/unit/test_compile_message.py @@ -1,6 +1,6 @@ import unittest -from discord_analyzer.automation.automation_workflow import AutomationWorkflow +from tc_analyzer_lib.automation.automation_workflow import AutomationWorkflow class CompileTemplateMessage(unittest.TestCase): diff --git a/tests/unit/test_converting_to_dict.py b/tests/unit/test_converting_to_dict.py index b4800c0..505dc17 100644 --- a/tests/unit/test_converting_to_dict.py +++ b/tests/unit/test_converting_to_dict.py @@ -1,4 +1,4 @@ -from discord_analyzer.algorithms.utils.member_activity_utils import convert_to_dict +from tc_analyzer_lib.algorithms.utils.member_activity_utils import convert_to_dict def test_empty(): diff --git a/tests/unit/test_creds_loading.py b/tests/unit/test_creds_loading.py index c28e412..3d8f27c 100644 --- a/tests/unit/test_creds_loading.py +++ b/tests/unit/test_creds_loading.py @@ -1,4 +1,4 @@ -from discord_analyzer.utils.credentials import ( +from tc_analyzer_lib.utils.credentials import ( get_mongo_credentials, get_rabbit_mq_credentials, get_redis_credentials, diff --git a/tests/unit/test_engagement_notifier_subtract_users.py b/tests/unit/test_engagement_notifier_subtract_users.py index d4376f9..613c8e8 100644 --- a/tests/unit/test_engagement_notifier_subtract_users.py +++ b/tests/unit/test_engagement_notifier_subtract_users.py @@ -1,4 +1,4 @@ -from discord_analyzer.automation.utils.automation_base import AutomationBase +from tc_analyzer_lib.automation.utils.automation_base import AutomationBase def test_subtract_users_empty_data(): diff --git a/tests/unit/test_generate_interaction_mtx.py b/tests/unit/test_generate_interaction_mtx.py index c5a4133..fe545a2 100644 --- a/tests/unit/test_generate_interaction_mtx.py +++ b/tests/unit/test_generate_interaction_mtx.py @@ -1,5 +1,5 @@ -from discord_analyzer.algorithms.utils.activity import Activity -from discord_analyzer.algorithms.utils.compute_interaction_mtx_utils import ( +from tc_analyzer_lib.algorithms.utils.activity import Activity +from tc_analyzer_lib.algorithms.utils.compute_interaction_mtx_utils import ( generate_interaction_matrix, ) diff --git a/tests/unit/test_generate_interaction_mtx_mention.py b/tests/unit/test_generate_interaction_mtx_mention.py index d5da9bd..dbcec85 100644 --- a/tests/unit/test_generate_interaction_mtx_mention.py +++ b/tests/unit/test_generate_interaction_mtx_mention.py @@ -1,5 +1,5 @@ -from discord_analyzer.algorithms.utils.activity import Activity -from discord_analyzer.algorithms.utils.compute_interaction_mtx_utils import ( +from tc_analyzer_lib.algorithms.utils.activity import Activity +from tc_analyzer_lib.algorithms.utils.compute_interaction_mtx_utils import ( generate_interaction_matrix, ) diff --git a/tests/unit/test_generate_interaction_mtx_reaction.py b/tests/unit/test_generate_interaction_mtx_reaction.py index 66e86f7..1183545 100644 --- a/tests/unit/test_generate_interaction_mtx_reaction.py +++ b/tests/unit/test_generate_interaction_mtx_reaction.py @@ -1,5 +1,5 @@ -from discord_analyzer.algorithms.utils.activity import Activity -from discord_analyzer.algorithms.utils.compute_interaction_mtx_utils import ( +from tc_analyzer_lib.algorithms.utils.activity import Activity +from tc_analyzer_lib.algorithms.utils.compute_interaction_mtx_utils import ( generate_interaction_matrix, ) diff --git a/tests/unit/test_generate_interaction_mtx_reply.py b/tests/unit/test_generate_interaction_mtx_reply.py index 840f138..71985ea 100644 --- a/tests/unit/test_generate_interaction_mtx_reply.py +++ b/tests/unit/test_generate_interaction_mtx_reply.py @@ -1,5 +1,5 @@ -from discord_analyzer.algorithms.utils.activity import Activity -from discord_analyzer.algorithms.utils.compute_interaction_mtx_utils import ( +from tc_analyzer_lib.algorithms.utils.activity import Activity +from tc_analyzer_lib.algorithms.utils.compute_interaction_mtx_utils import ( generate_interaction_matrix, ) diff --git a/tests/unit/test_get_timestamp.py b/tests/unit/test_get_timestamp.py index 6a5273b..adc61f2 100644 --- a/tests/unit/test_get_timestamp.py +++ b/tests/unit/test_get_timestamp.py @@ -1,8 +1,8 @@ import unittest from datetime import datetime, timezone -from discord_analyzer.DB_operations.network_graph import NetworkGraph -from discord_analyzer.schemas import GraphSchema +from tc_analyzer_lib.DB_operations.network_graph import NetworkGraph +from tc_analyzer_lib.schemas import GraphSchema class TestGetTimestamp(unittest.TestCase): diff --git a/tests/unit/test_graph_schema.py b/tests/unit/test_graph_schema.py index 210a117..851a307 100644 --- a/tests/unit/test_graph_schema.py +++ b/tests/unit/test_graph_schema.py @@ -1,6 +1,6 @@ from unittest import TestCase -from discord_analyzer.schemas import GraphSchema +from tc_analyzer_lib.schemas import GraphSchema class TestGraphSchema(TestCase): diff --git a/tests/unit/test_heatmaps_analytics_base_process_vectors.py b/tests/unit/test_heatmaps_analytics_base_process_vectors.py index 3b7495f..aee8195 100644 --- a/tests/unit/test_heatmaps_analytics_base_process_vectors.py +++ b/tests/unit/test_heatmaps_analytics_base_process_vectors.py @@ -1,6 +1,6 @@ from unittest import TestCase -from discord_analyzer.metrics.heatmaps.analytics_hourly import AnalyticsHourly +from tc_analyzer_lib.metrics.heatmaps.analytics_hourly import AnalyticsHourly class TestRawMemberActivitiesProcessVectors(TestCase): diff --git a/tests/unit/test_member_activity_utils.py b/tests/unit/test_member_activity_utils.py index 50d2c84..2bd9a59 100644 --- a/tests/unit/test_member_activity_utils.py +++ b/tests/unit/test_member_activity_utils.py @@ -1,6 +1,6 @@ from datetime import datetime, timedelta -from discord_analyzer.algorithms.utils.member_activity_history_utils import ( +from tc_analyzer_lib.algorithms.utils.member_activity_history_utils import ( MemberActivityPastUtils, ) diff --git a/tests/unit/test_mongo_singleton.py b/tests/unit/test_mongo_singleton.py index bc976f3..33eed71 100644 --- a/tests/unit/test_mongo_singleton.py +++ b/tests/unit/test_mongo_singleton.py @@ -1,7 +1,7 @@ import unittest from pymongo import MongoClient -from discord_analyzer.utils.mongo import MongoSingleton +from tc_analyzer_lib.utils.mongo import MongoSingleton class TestMongoSingleton(unittest.TestCase): diff --git a/tests/unit/test_per_account_interaction.py b/tests/unit/test_per_account_interaction.py index 8a0270e..cb8a722 100644 --- a/tests/unit/test_per_account_interaction.py +++ b/tests/unit/test_per_account_interaction.py @@ -1,4 +1,4 @@ -from discord_analyzer.algorithms.analytics_interactions_script import ( +from tc_analyzer_lib.algorithms.analytics_interactions_script import ( per_account_interactions, ) diff --git a/tests/unit/test_prepare_results_per_acc.py b/tests/unit/test_prepare_results_per_acc.py index dc4d936..6cc66ea 100644 --- a/tests/unit/test_prepare_results_per_acc.py +++ b/tests/unit/test_prepare_results_per_acc.py @@ -1,4 +1,4 @@ -from discord_analyzer.algorithms.utils.compute_interaction_mtx_utils import ( +from tc_analyzer_lib.algorithms.utils.compute_interaction_mtx_utils import ( prepare_per_account, ) diff --git a/tests/unit/test_process_non_reaction_heatmaps.py b/tests/unit/test_process_non_reaction_heatmaps.py index c75155d..fbe4c0b 100644 --- a/tests/unit/test_process_non_reaction_heatmaps.py +++ b/tests/unit/test_process_non_reaction_heatmaps.py @@ -1,7 +1,7 @@ from unittest import TestCase import numpy as np -from discord_analyzer.algorithms.compute_interaction_matrix_discord import ( +from tc_analyzer_lib.algorithms.compute_interaction_matrix_discord import ( process_actions, ) diff --git a/tests/unit/test_schema_hourly_analytics.py b/tests/unit/test_schema_hourly_analytics.py index ee38be5..d6b573c 100644 --- a/tests/unit/test_schema_hourly_analytics.py +++ b/tests/unit/test_schema_hourly_analytics.py @@ -1,6 +1,6 @@ from unittest import TestCase -from discord_analyzer.schemas import ActivityDirection, ActivityType, HourlyAnalytics +from tc_analyzer_lib.schemas import ActivityDirection, ActivityType, HourlyAnalytics class TestHourlyAnalytics(TestCase): diff --git a/tests/unit/test_schema_raw_analytics.py b/tests/unit/test_schema_raw_analytics.py index 742f441..71893a8 100644 --- a/tests/unit/test_schema_raw_analytics.py +++ b/tests/unit/test_schema_raw_analytics.py @@ -1,7 +1,7 @@ from unittest import TestCase -from discord_analyzer.schemas import ActivityDirection, ActivityType -from discord_analyzer.schemas.platform_configs.config_base import RawAnalytics +from tc_analyzer_lib.schemas import ActivityDirection, ActivityType +from tc_analyzer_lib.schemas.platform_configs.config_base import RawAnalytics class TestRawAnalytics(TestCase): From 83a16702fe6e6a0eb04bb3980b508732492dae1f Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Tue, 2 Jul 2024 16:57:46 +0330 Subject: [PATCH 17/23] fix: black linter issues! --- setup.py | 2 +- tc_analyzer_lib/publish_on_success.py | 4 ++-- tc_analyzer_lib/tc_analyzer.py | 1 - tc_analyzer_lib/utils/get_guild_utils.py | 14 +++++++---- ...iod_1year_recompute_available_analytics.py | 4 +++- ..._period_1year_recompute_empty_analytics.py | 4 +++- ...riod_1year_run_once_available_analytics.py | 4 +++- ...r_period_1year_run_once_empty_analytics.py | 4 +++- .../test_analyzer_period_35days_run_once.py | 4 +++- ...od_3month_recompute_available_analytics.py | 4 +++- ...period_3month_recompute_empty_analytics.py | 4 +++- ...iod_3month_run_once_available_analytics.py | 4 +++- ..._period_3month_run_once_empty_analytics.py | 4 +++- ...od_6month_recompute_available_analytics.py | 4 +++- ...period_6month_recompute_empty_analytics.py | 4 +++- ...iod_6month_run_once_available_analytics.py | 4 +++- ..._period_6month_run_once_empty_analytics.py | 4 +++- ...iod_month_recompute_available_analytics.py | 4 +++- ..._period_month_recompute_empty_analytics.py | 4 +++- ...riod_month_run_once_available_analytics.py | 4 +++- ...r_period_month_run_once_empty_analytics.py | 4 +++- ...riod_week_recompute_available_analytics.py | 4 +++- ...r_period_week_recompute_empty_analytics.py | 4 +++- ...eriod_week_run_once_available_analytics.py | 4 +++- ...er_period_week_run_once_empty_analytics.py | 4 +++- tests/integration/test_get_guild_owner.py | 11 ++++----- ...test_publish_on_success_recompute_false.py | 14 +++++------ .../test_publish_on_success_recompute_true.py | 23 ++++++++----------- tests/integration/utils/setup_platform.py | 3 +-- 29 files changed, 97 insertions(+), 59 deletions(-) diff --git a/setup.py b/setup.py index 29cb148..f773acf 100644 --- a/setup.py +++ b/setup.py @@ -14,4 +14,4 @@ description="A platform agnostic analyzer, computing the TogetherCrew dashboard metrics.", long_description=open("README.md").read(), install_requires=requirements, -) \ No newline at end of file +) diff --git a/tc_analyzer_lib/publish_on_success.py b/tc_analyzer_lib/publish_on_success.py index 22ffa05..be53af7 100644 --- a/tc_analyzer_lib/publish_on_success.py +++ b/tc_analyzer_lib/publish_on_success.py @@ -6,7 +6,7 @@ from tc_analyzer_lib.utils.get_guild_utils import ( get_platform_guild_id, get_platform_name, - get_platform_community_owner + get_platform_community_owner, ) from tc_analyzer_lib.utils.rabbitmq import RabbitMQAccess @@ -32,7 +32,7 @@ def publish_on_success(platform_id: str, recompute: bool) -> None: guild_id = get_platform_guild_id(platform_id) platform_name = get_platform_name(platform_id) - + automation_workflow = AutomationWorkflow() # working specifically for discord if platform_name == "discord" and recompute: diff --git a/tc_analyzer_lib/tc_analyzer.py b/tc_analyzer_lib/tc_analyzer.py index f3f89b4..e72eac5 100644 --- a/tc_analyzer_lib/tc_analyzer.py +++ b/tc_analyzer_lib/tc_analyzer.py @@ -65,7 +65,6 @@ def __init__( # connect to Neo4j & MongoDB database self.database_connect() - def analyze(self, recompute: bool) -> None: # TODO: merge run_one and recompute codes if recompute: diff --git a/tc_analyzer_lib/utils/get_guild_utils.py b/tc_analyzer_lib/utils/get_guild_utils.py index 2f2219c..b1adf3e 100644 --- a/tc_analyzer_lib/utils/get_guild_utils.py +++ b/tc_analyzer_lib/utils/get_guild_utils.py @@ -56,6 +56,7 @@ def get_guild_platform_id(guild_id: str) -> str: return platform_id + def get_platform_name(platform_id: str) -> str: """ get the platform name @@ -76,10 +77,13 @@ def get_platform_name(platform_id: str) -> str: {"_id": ObjectId(platform_id)}, {"name": True} ) if platform is None: - raise AttributeError(f"platform with given platform_id: {platform_id} not found!") + raise AttributeError( + f"platform with given platform_id: {platform_id} not found!" + ) return platform["name"] + def get_platform_community_owner(platform_id: str) -> str: """ get the community owener discord id using the platform id @@ -92,7 +96,7 @@ def get_platform_community_owner(platform_id: str) -> str: Returns -------- owner_discord_id : str - the owner discord id + the owner discord id """ client = MongoSingleton.get_instance().client @@ -101,7 +105,9 @@ def get_platform_community_owner(platform_id: str) -> str: ) if platform is None: - raise AttributeError(f"platform with given platform_id: {platform_id} not found!") + raise AttributeError( + f"platform with given platform_id: {platform_id} not found!" + ) community_id = platform["community"] community = client["Core"]["users"].find_one( @@ -111,7 +117,7 @@ def get_platform_community_owner(platform_id: str) -> str: raise AttributeError( f"Community user with given community id: {community_id} not found!" ) - + owner_discord_id = community["discordId"] return owner_discord_id diff --git a/tests/integration/test_analyzer_period_1year_recompute_available_analytics.py b/tests/integration/test_analyzer_period_1year_recompute_available_analytics.py index 5256b55..27a3f2c 100644 --- a/tests/integration/test_analyzer_period_1year_recompute_available_analytics.py +++ b/tests/integration/test_analyzer_period_1year_recompute_available_analytics.py @@ -23,7 +23,9 @@ def test_analyzer_one_year_period_recompute_available_analytics(): "973993299281076286", ] - analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=360) + analyzer = setup_platform( + db_access, platform_id, discordId_list=acc_id, days_ago_period=360 + ) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") diff --git a/tests/integration/test_analyzer_period_1year_recompute_empty_analytics.py b/tests/integration/test_analyzer_period_1year_recompute_empty_analytics.py index 396ada1..5d02b6e 100644 --- a/tests/integration/test_analyzer_period_1year_recompute_empty_analytics.py +++ b/tests/integration/test_analyzer_period_1year_recompute_empty_analytics.py @@ -21,7 +21,9 @@ def test_analyzer_one_year_period_recompute_empty_analytics(): "973993299281076286", ] - analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=360) + analyzer = setup_platform( + db_access, platform_id, discordId_list=acc_id, days_ago_period=360 + ) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") diff --git a/tests/integration/test_analyzer_period_1year_run_once_available_analytics.py b/tests/integration/test_analyzer_period_1year_run_once_available_analytics.py index 3d9cb7f..d925fd5 100644 --- a/tests/integration/test_analyzer_period_1year_run_once_available_analytics.py +++ b/tests/integration/test_analyzer_period_1year_run_once_available_analytics.py @@ -23,7 +23,9 @@ def test_analyzer_one_year_period_run_once_available_analytics(): "973993299281076286", ] - analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=360) + analyzer = setup_platform( + db_access, platform_id, discordId_list=acc_id, days_ago_period=360 + ) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") diff --git a/tests/integration/test_analyzer_period_1year_run_once_empty_analytics.py b/tests/integration/test_analyzer_period_1year_run_once_empty_analytics.py index 0341d09..f59820d 100644 --- a/tests/integration/test_analyzer_period_1year_run_once_empty_analytics.py +++ b/tests/integration/test_analyzer_period_1year_run_once_empty_analytics.py @@ -21,7 +21,9 @@ def test_analyzer_one_year_period_run_once_empty_analytics(): "973993299281076286", ] - analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=360) + analyzer = setup_platform( + db_access, platform_id, discordId_list=acc_id, days_ago_period=360 + ) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") diff --git a/tests/integration/test_analyzer_period_35days_run_once.py b/tests/integration/test_analyzer_period_35days_run_once.py index 12f9373..73d1192 100644 --- a/tests/integration/test_analyzer_period_35days_run_once.py +++ b/tests/integration/test_analyzer_period_35days_run_once.py @@ -24,7 +24,9 @@ def test_analyzer_40days_period_run_once_available_analytics_overlapping_period( "user2", ] - analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=40) + analyzer = setup_platform( + db_access, platform_id, discordId_list=acc_id, days_ago_period=40 + ) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") diff --git a/tests/integration/test_analyzer_period_3month_recompute_available_analytics.py b/tests/integration/test_analyzer_period_3month_recompute_available_analytics.py index 8e842c0..1497865 100644 --- a/tests/integration/test_analyzer_period_3month_recompute_available_analytics.py +++ b/tests/integration/test_analyzer_period_3month_recompute_available_analytics.py @@ -23,7 +23,9 @@ def test_analyzer_three_month_period_recompute_available_analytics(): "973993299281076286", ] - analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=90) + analyzer = setup_platform( + db_access, platform_id, discordId_list=acc_id, days_ago_period=90 + ) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") diff --git a/tests/integration/test_analyzer_period_3month_recompute_empty_analytics.py b/tests/integration/test_analyzer_period_3month_recompute_empty_analytics.py index 33a5d31..09c4166 100644 --- a/tests/integration/test_analyzer_period_3month_recompute_empty_analytics.py +++ b/tests/integration/test_analyzer_period_3month_recompute_empty_analytics.py @@ -21,7 +21,9 @@ def test_analyzer_three_month_period_recompute_empty_analytics(): "973993299281076286", ] - analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=90) + analyzer = setup_platform( + db_access, platform_id, discordId_list=acc_id, days_ago_period=90 + ) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") diff --git a/tests/integration/test_analyzer_period_3month_run_once_available_analytics.py b/tests/integration/test_analyzer_period_3month_run_once_available_analytics.py index 89acd68..f1ceb5a 100644 --- a/tests/integration/test_analyzer_period_3month_run_once_available_analytics.py +++ b/tests/integration/test_analyzer_period_3month_run_once_available_analytics.py @@ -23,7 +23,9 @@ def test_analyzer_three_month_period_run_once_available_analytics(): "973993299281076286", ] - analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=90) + analyzer = setup_platform( + db_access, platform_id, discordId_list=acc_id, days_ago_period=90 + ) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") diff --git a/tests/integration/test_analyzer_period_3month_run_once_empty_analytics.py b/tests/integration/test_analyzer_period_3month_run_once_empty_analytics.py index f5f285f..f3b51dd 100644 --- a/tests/integration/test_analyzer_period_3month_run_once_empty_analytics.py +++ b/tests/integration/test_analyzer_period_3month_run_once_empty_analytics.py @@ -21,7 +21,9 @@ def test_analyzer_three_month_period_run_once_empty_analytics(): "973993299281076286", ] - analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=90) + analyzer = setup_platform( + db_access, platform_id, discordId_list=acc_id, days_ago_period=90 + ) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") diff --git a/tests/integration/test_analyzer_period_6month_recompute_available_analytics.py b/tests/integration/test_analyzer_period_6month_recompute_available_analytics.py index c46b7d8..5bb7e48 100644 --- a/tests/integration/test_analyzer_period_6month_recompute_available_analytics.py +++ b/tests/integration/test_analyzer_period_6month_recompute_available_analytics.py @@ -23,7 +23,9 @@ def test_analyzer_six_month_period_recompute_available_analytics(): "973993299281076286", ] - analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=180) + analyzer = setup_platform( + db_access, platform_id, discordId_list=acc_id, days_ago_period=180 + ) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") diff --git a/tests/integration/test_analyzer_period_6month_recompute_empty_analytics.py b/tests/integration/test_analyzer_period_6month_recompute_empty_analytics.py index 70d3025..14b90a4 100644 --- a/tests/integration/test_analyzer_period_6month_recompute_empty_analytics.py +++ b/tests/integration/test_analyzer_period_6month_recompute_empty_analytics.py @@ -21,7 +21,9 @@ def test_analyzer_six_month_period_recompute_empty_analytics(): "973993299281076286", ] - analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=180) + analyzer = setup_platform( + db_access, platform_id, discordId_list=acc_id, days_ago_period=180 + ) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") diff --git a/tests/integration/test_analyzer_period_6month_run_once_available_analytics.py b/tests/integration/test_analyzer_period_6month_run_once_available_analytics.py index 3b77713..94dff3e 100644 --- a/tests/integration/test_analyzer_period_6month_run_once_available_analytics.py +++ b/tests/integration/test_analyzer_period_6month_run_once_available_analytics.py @@ -23,7 +23,9 @@ def test_analyzer_six_month_period_run_once_available_analytics(): "973993299281076286", ] - analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=180) + analyzer = setup_platform( + db_access, platform_id, discordId_list=acc_id, days_ago_period=180 + ) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") diff --git a/tests/integration/test_analyzer_period_6month_run_once_empty_analytics.py b/tests/integration/test_analyzer_period_6month_run_once_empty_analytics.py index d62387a..c4eee00 100644 --- a/tests/integration/test_analyzer_period_6month_run_once_empty_analytics.py +++ b/tests/integration/test_analyzer_period_6month_run_once_empty_analytics.py @@ -21,7 +21,9 @@ def test_analyzer_six_month_period_run_once_empty_analytics(): "973993299281076286", ] - analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=180) + analyzer = setup_platform( + db_access, platform_id, discordId_list=acc_id, days_ago_period=180 + ) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") diff --git a/tests/integration/test_analyzer_period_month_recompute_available_analytics.py b/tests/integration/test_analyzer_period_month_recompute_available_analytics.py index e86ee19..465d845 100644 --- a/tests/integration/test_analyzer_period_month_recompute_available_analytics.py +++ b/tests/integration/test_analyzer_period_month_recompute_available_analytics.py @@ -23,7 +23,9 @@ def test_analyzer_month_period_recompute_available_analytics(): "973993299281076286", ] - analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=30) + analyzer = setup_platform( + db_access, platform_id, discordId_list=acc_id, days_ago_period=30 + ) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") diff --git a/tests/integration/test_analyzer_period_month_recompute_empty_analytics.py b/tests/integration/test_analyzer_period_month_recompute_empty_analytics.py index f91df20..f0f313c 100644 --- a/tests/integration/test_analyzer_period_month_recompute_empty_analytics.py +++ b/tests/integration/test_analyzer_period_month_recompute_empty_analytics.py @@ -21,7 +21,9 @@ def test_analyzer_month_period_recompute_empty_analytics(): "973993299281076286", ] - analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=30) + analyzer = setup_platform( + db_access, platform_id, discordId_list=acc_id, days_ago_period=30 + ) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") diff --git a/tests/integration/test_analyzer_period_month_run_once_available_analytics.py b/tests/integration/test_analyzer_period_month_run_once_available_analytics.py index 2baa631..692782a 100644 --- a/tests/integration/test_analyzer_period_month_run_once_available_analytics.py +++ b/tests/integration/test_analyzer_period_month_run_once_available_analytics.py @@ -23,7 +23,9 @@ def test_analyzer_month_period_run_once_available_analytics(): "973993299281076286", ] - analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=30) + analyzer = setup_platform( + db_access, platform_id, discordId_list=acc_id, days_ago_period=30 + ) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") diff --git a/tests/integration/test_analyzer_period_month_run_once_empty_analytics.py b/tests/integration/test_analyzer_period_month_run_once_empty_analytics.py index bd21234..a84fe47 100644 --- a/tests/integration/test_analyzer_period_month_run_once_empty_analytics.py +++ b/tests/integration/test_analyzer_period_month_run_once_empty_analytics.py @@ -21,7 +21,9 @@ def test_analyzer_month_period_run_once_empty_analytics(): "973993299281076286", ] - analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=30) + analyzer = setup_platform( + db_access, platform_id, discordId_list=acc_id, days_ago_period=30 + ) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") diff --git a/tests/integration/test_analyzer_period_week_recompute_available_analytics.py b/tests/integration/test_analyzer_period_week_recompute_available_analytics.py index 0168ed0..0eb5282 100644 --- a/tests/integration/test_analyzer_period_week_recompute_available_analytics.py +++ b/tests/integration/test_analyzer_period_week_recompute_available_analytics.py @@ -23,7 +23,9 @@ def test_analyzer_week_period_recompute_available_analytics(): "user_1", "user_2", ] - analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=8) + analyzer = setup_platform( + db_access, platform_id, discordId_list=acc_id, days_ago_period=8 + ) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") diff --git a/tests/integration/test_analyzer_period_week_recompute_empty_analytics.py b/tests/integration/test_analyzer_period_week_recompute_empty_analytics.py index 94421b2..3794f28 100644 --- a/tests/integration/test_analyzer_period_week_recompute_empty_analytics.py +++ b/tests/integration/test_analyzer_period_week_recompute_empty_analytics.py @@ -21,7 +21,9 @@ def test_analyzer_week_period_recompute_empty_analytics(): "973993299281076286", ] - analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=7) + analyzer = setup_platform( + db_access, platform_id, discordId_list=acc_id, days_ago_period=7 + ) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") diff --git a/tests/integration/test_analyzer_period_week_run_once_available_analytics.py b/tests/integration/test_analyzer_period_week_run_once_available_analytics.py index 5b7f214..f4245fc 100644 --- a/tests/integration/test_analyzer_period_week_run_once_available_analytics.py +++ b/tests/integration/test_analyzer_period_week_run_once_available_analytics.py @@ -23,7 +23,9 @@ def test_analyzer_week_period_run_once_available_analytics(): "973993299281076285", "973993299281076286", ] - analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=8) + analyzer = setup_platform( + db_access, platform_id, discordId_list=acc_id, days_ago_period=8 + ) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") diff --git a/tests/integration/test_analyzer_period_week_run_once_empty_analytics.py b/tests/integration/test_analyzer_period_week_run_once_empty_analytics.py index c141363..bded353 100644 --- a/tests/integration/test_analyzer_period_week_run_once_empty_analytics.py +++ b/tests/integration/test_analyzer_period_week_run_once_empty_analytics.py @@ -21,7 +21,9 @@ def test_analyzer_week_period_run_once_empty_analytics(): "user_1", ] - analyzer = setup_platform(db_access, platform_id, discordId_list=acc_id, days_ago_period=7) + analyzer = setup_platform( + db_access, platform_id, discordId_list=acc_id, days_ago_period=7 + ) db_access.db_mongo_client[platform_id].drop_collection("heatmaps") db_access.db_mongo_client[platform_id].drop_collection("memberactivities") diff --git a/tests/integration/test_get_guild_owner.py b/tests/integration/test_get_guild_owner.py index 0444706..83a1f88 100644 --- a/tests/integration/test_get_guild_owner.py +++ b/tests/integration/test_get_guild_owner.py @@ -90,7 +90,8 @@ def test_single_platform(self): owner = get_platform_community_owner(platform_id=self.platform_id) self.assertEqual( - owner, expected_owner_discord_id, + owner, + expected_owner_discord_id, ) def test_multiple_platforms(self): @@ -130,9 +131,7 @@ def test_multiple_platforms(self): owner = get_platform_community_owner(platform_id=self.platform_id) - self.assertEqual( - owner, expected_owner_discord_id - ) + self.assertEqual(owner, expected_owner_discord_id) def test_multiple_platforms_available(self): expected_owner_discord_id = "1234567891" @@ -213,6 +212,4 @@ def test_multiple_platforms_available(self): owner = get_platform_community_owner(platform_id=self.platform_id) - self.assertEqual( - owner, expected_owner_discord_id - ) + self.assertEqual(owner, expected_owner_discord_id) diff --git a/tests/integration/test_publish_on_success_recompute_false.py b/tests/integration/test_publish_on_success_recompute_false.py index bb479a0..784b363 100644 --- a/tests/integration/test_publish_on_success_recompute_false.py +++ b/tests/integration/test_publish_on_success_recompute_false.py @@ -32,8 +32,8 @@ def test_publish_on_success_recompute_false_check_notification_choreographies(): {"_id": ObjectId(platform_id)} ) - db_access.db_mongo_client.drop_database(platform_id) - db_access.db_mongo_client.drop_database(guild_id) + db_access.db_mongo_client.drop_database(platform_id) + db_access.db_mongo_client.drop_database(guild_id) db_access.db_mongo_client["Saga"].drop_collection("sagas") db_access.db_mongo_client[at_db].drop_collection(at_collection) @@ -238,14 +238,12 @@ def test_publish_on_success_recompute_false_check_notification_choreographies(): db_access.db_mongo_client[at_db][at_collection].insert_one(automation.to_dict()) - date_yesterday = ( - (datetime.now() - timedelta(days=1)) - .replace(hour=0, minute=0, second=0, microsecond=0) + date_yesterday = (datetime.now() - timedelta(days=1)).replace( + hour=0, minute=0, second=0, microsecond=0 ) - date_two_past_days = ( - (datetime.now() - timedelta(days=2)) - .replace(hour=0, minute=0, second=0, microsecond=0) + date_two_past_days = (datetime.now() - timedelta(days=2)).replace( + hour=0, minute=0, second=0, microsecond=0 ) db_access.db_mongo_client[platform_id]["memberactivities"].insert_many( diff --git a/tests/integration/test_publish_on_success_recompute_true.py b/tests/integration/test_publish_on_success_recompute_true.py index 8e25301..e57680b 100644 --- a/tests/integration/test_publish_on_success_recompute_true.py +++ b/tests/integration/test_publish_on_success_recompute_true.py @@ -30,8 +30,8 @@ def test_publish_on_success_recompute_true_check_notification_choreographies(): db_access.db_mongo_client["Core"].drop_collection("platforms") db_access.db_mongo_client["Core"].drop_collection("users") - db_access.db_mongo_client.drop_database(platform_id) - db_access.db_mongo_client.drop_database(guild_id) + db_access.db_mongo_client.drop_database(platform_id) + db_access.db_mongo_client.drop_database(guild_id) db_access.db_mongo_client["Saga"].drop_collection("sagas") db_access.db_mongo_client[at_db].drop_collection(at_collection) @@ -89,7 +89,6 @@ def test_publish_on_success_recompute_true_check_notification_choreographies(): "tcaAt": datetime(2023, 12, 2), } ) - db_access.db_mongo_client["Saga"]["sagas"].insert_one( { @@ -250,14 +249,12 @@ def test_publish_on_success_recompute_true_check_notification_choreographies(): db_access.db_mongo_client[at_db][at_collection].insert_one(automation.to_dict()) - date_yesterday = ( - (datetime.now() - timedelta(days=1)) - .replace(hour=0, minute=0, second=0, microsecond=0) + date_yesterday = (datetime.now() - timedelta(days=1)).replace( + hour=0, minute=0, second=0, microsecond=0 ) - date_two_past_days = ( - (datetime.now() - timedelta(days=2)) - .replace(hour=0, minute=0, second=0, microsecond=0) + date_two_past_days = (datetime.now() - timedelta(days=2)).replace( + hour=0, minute=0, second=0, microsecond=0 ) db_access.db_mongo_client[platform_id]["memberactivities"].insert_many( @@ -347,7 +344,7 @@ def test_publish_on_success_recompute_true_check_notification_choreographies(): {"data.discordId": owner_discord_id} ) assert job_finished_saga["data"]["message"] == ( - "Your data import into TogetherCrew is complete! " - "See your insights on your dashboard https://app.togethercrew.com/." - " If you have questions send a DM to katerinabc (Discord) or k_bc0 (Telegram)." - ) + "Your data import into TogetherCrew is complete! " + "See your insights on your dashboard https://app.togethercrew.com/." + " If you have questions send a DM to katerinabc (Discord) or k_bc0 (Telegram)." + ) diff --git a/tests/integration/utils/setup_platform.py b/tests/integration/utils/setup_platform.py index 3d50de8..2bf06b4 100644 --- a/tests/integration/utils/setup_platform.py +++ b/tests/integration/utils/setup_platform.py @@ -117,5 +117,4 @@ def setup_platform( } ) - - return analyzer \ No newline at end of file + return analyzer From 6c1fa07823e983cddf54a0d548293451f19f418e Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Tue, 2 Jul 2024 17:36:54 +0330 Subject: [PATCH 18/23] fix: lint issues! --- .../DB_operations/mongo_neo4j_ops.py | 2 +- .../DB_operations/mongodb_interaction.py | 2 +- .../DB_operations/network_graph.py | 2 +- .../compute_interaction_matrix_discord.py | 4 +- .../neo4j_analysis/analyzer_node_stats.py | 1 - .../utils/member_activity_history_utils.py | 3 +- .../algorithms/utils/member_activity_utils.py | 2 +- .../automation/automation_workflow.py | 2 +- tc_analyzer_lib/metrics/utils/platform.py | 2 +- tc_analyzer_lib/models/GuildsRnDaoModel.py | 3 +- tc_analyzer_lib/models/HeatMapModel.py | 2 +- tc_analyzer_lib/models/RawInfoModel.py | 2 +- tc_analyzer_lib/publish_on_success.py | 4 +- tc_analyzer_lib/schemas/__init__.py | 2 +- tc_analyzer_lib/tc_analyzer.py | 3 +- tc_analyzer_lib/utils/rabbitmq.py | 2 +- .../test_analyzer_platform_fetch_period.py | 4 +- .../test_analyzer_platform_fetch_resources.py | 4 +- .../test_analyzer_utils_platform.py | 21 +--------- ...test_analyzer_utils_platform_parameters.py | 4 +- .../test_assess_engagement_mention.py | 6 +-- .../test_assess_engagement_reactions.py | 6 +-- .../test_assess_engagement_replies.py | 6 +-- .../test_automation_db_load_from_db.py | 2 +- .../test_automation_db_save_to_db.py | 2 +- tests/integration/test_get_guild_owner.py | 6 +-- .../test_get_past_7_days_heatmaps.py | 4 +- .../test_network_graph_creation.py | 39 +++++++++-------- ...test_publish_on_success_recompute_false.py | 4 +- .../test_publish_on_success_recompute_true.py | 4 +- tests/integration/test_service_connection.py | 2 +- tests/integration/utils/analyzer_setup.py | 2 +- tests/integration/utils/mock_graph.py | 42 +++++++++---------- 33 files changed, 87 insertions(+), 109 deletions(-) diff --git a/tc_analyzer_lib/DB_operations/mongo_neo4j_ops.py b/tc_analyzer_lib/DB_operations/mongo_neo4j_ops.py index 8876366..02a0598 100644 --- a/tc_analyzer_lib/DB_operations/mongo_neo4j_ops.py +++ b/tc_analyzer_lib/DB_operations/mongo_neo4j_ops.py @@ -2,8 +2,8 @@ from tc_analyzer_lib.DB_operations.mongodb_interaction import MongoDBOps from tc_analyzer_lib.DB_operations.network_graph import NetworkGraph -from tc_neo4j_lib.neo4j_ops import Neo4jOps, Query from tc_analyzer_lib.schemas import GraphSchema +from tc_neo4j_lib.neo4j_ops import Neo4jOps, Query class MongoNeo4jDB: diff --git a/tc_analyzer_lib/DB_operations/mongodb_interaction.py b/tc_analyzer_lib/DB_operations/mongodb_interaction.py index 659bfc8..9ef5cb4 100644 --- a/tc_analyzer_lib/DB_operations/mongodb_interaction.py +++ b/tc_analyzer_lib/DB_operations/mongodb_interaction.py @@ -1,8 +1,8 @@ import logging -from tc_analyzer_lib.DB_operations.mongodb_access import DB_access from pymongo.read_concern import ReadConcern from pymongo.write_concern import WriteConcern +from tc_analyzer_lib.DB_operations.mongodb_access import DB_access class MongoDBOps: diff --git a/tc_analyzer_lib/DB_operations/network_graph.py b/tc_analyzer_lib/DB_operations/network_graph.py index 6c118b0..43a6888 100644 --- a/tc_analyzer_lib/DB_operations/network_graph.py +++ b/tc_analyzer_lib/DB_operations/network_graph.py @@ -3,8 +3,8 @@ import datetime import networkx -from tc_neo4j_lib import Query from tc_analyzer_lib.schemas import GraphSchema +from tc_neo4j_lib import Query class NetworkGraph: diff --git a/tc_analyzer_lib/algorithms/compute_interaction_matrix_discord.py b/tc_analyzer_lib/algorithms/compute_interaction_matrix_discord.py index 43a6335..e280e5d 100644 --- a/tc_analyzer_lib/algorithms/compute_interaction_matrix_discord.py +++ b/tc_analyzer_lib/algorithms/compute_interaction_matrix_discord.py @@ -1,10 +1,10 @@ import copy -from typing import Any from datetime import datetime +from typing import Any from numpy import diag_indices_from, ndarray - from tc_analyzer_lib.utils.mongo import MongoSingleton + from .utils.compute_interaction_mtx_utils import ( generate_interaction_matrix, prepare_per_account, diff --git a/tc_analyzer_lib/algorithms/neo4j_analysis/analyzer_node_stats.py b/tc_analyzer_lib/algorithms/neo4j_analysis/analyzer_node_stats.py index 65788eb..ff6cc5a 100644 --- a/tc_analyzer_lib/algorithms/neo4j_analysis/analyzer_node_stats.py +++ b/tc_analyzer_lib/algorithms/neo4j_analysis/analyzer_node_stats.py @@ -42,7 +42,6 @@ def __init__( self.projection_utils = ProjectionUtils(self.platform_id, self.graph_schema) def compute_stats(self, from_start: bool) -> None: - # possible dates to do the computations possible_dates = self.projection_utils.get_dates() diff --git a/tc_analyzer_lib/algorithms/utils/member_activity_history_utils.py b/tc_analyzer_lib/algorithms/utils/member_activity_history_utils.py index 75c8313..cff4f9d 100644 --- a/tc_analyzer_lib/algorithms/utils/member_activity_history_utils.py +++ b/tc_analyzer_lib/algorithms/utils/member_activity_history_utils.py @@ -2,9 +2,8 @@ from datetime import datetime, timedelta from typing import Any -from dateutil import parser -from tc_analyzer_lib.DB_operations.mongodb_access import DB_access from numpy import array +from tc_analyzer_lib.DB_operations.mongodb_access import DB_access class MemberActivityPastUtils: diff --git a/tc_analyzer_lib/algorithms/utils/member_activity_utils.py b/tc_analyzer_lib/algorithms/utils/member_activity_utils.py index 29b05e5..10a51ea 100644 --- a/tc_analyzer_lib/algorithms/utils/member_activity_utils.py +++ b/tc_analyzer_lib/algorithms/utils/member_activity_utils.py @@ -4,12 +4,12 @@ import numpy as np import pymongo +from networkx import DiGraph from tc_analyzer_lib.algorithms.compute_interaction_matrix_discord import ( compute_interaction_matrix_discord, ) from tc_analyzer_lib.DB_operations.mongodb_access import DB_access from tc_analyzer_lib.schemas.platform_configs.config_base import PlatformConfigBase -from networkx import DiGraph from tc_core_analyzer_lib.assess_engagement import EngagementAssessment diff --git a/tc_analyzer_lib/automation/automation_workflow.py b/tc_analyzer_lib/automation/automation_workflow.py index 0816494..8f2b5da 100644 --- a/tc_analyzer_lib/automation/automation_workflow.py +++ b/tc_analyzer_lib/automation/automation_workflow.py @@ -1,9 +1,9 @@ import logging from typing import Any +from pybars import Compiler from tc_analyzer_lib.automation.utils.automation_base import AutomationBase from tc_analyzer_lib.automation.utils.model import AutomationDB -from pybars import Compiler from tc_messageBroker.rabbit_mq.event import Event from tc_messageBroker.rabbit_mq.queue import Queue diff --git a/tc_analyzer_lib/metrics/utils/platform.py b/tc_analyzer_lib/metrics/utils/platform.py index d8d2116..5989a12 100644 --- a/tc_analyzer_lib/metrics/utils/platform.py +++ b/tc_analyzer_lib/metrics/utils/platform.py @@ -1,6 +1,6 @@ -from bson import ObjectId from datetime import datetime +from bson import ObjectId from tc_analyzer_lib.utils.mongo import MongoSingleton diff --git a/tc_analyzer_lib/models/GuildsRnDaoModel.py b/tc_analyzer_lib/models/GuildsRnDaoModel.py index e29199d..ae2e6cb 100644 --- a/tc_analyzer_lib/models/GuildsRnDaoModel.py +++ b/tc_analyzer_lib/models/GuildsRnDaoModel.py @@ -1,6 +1,5 @@ -#!/usr/bin/env python3 -from tc_analyzer_lib.models.BaseModel import BaseModel from pymongo.database import Database +from tc_analyzer_lib.models.BaseModel import BaseModel class GuildsRnDaoModel(BaseModel): diff --git a/tc_analyzer_lib/models/HeatMapModel.py b/tc_analyzer_lib/models/HeatMapModel.py index 8f5b1bb..4c7bf15 100644 --- a/tc_analyzer_lib/models/HeatMapModel.py +++ b/tc_analyzer_lib/models/HeatMapModel.py @@ -1,9 +1,9 @@ #!/usr/bin/env python3 from datetime import datetime -from tc_analyzer_lib.models.BaseModel import BaseModel from pymongo import DESCENDING from pymongo.database import Database +from tc_analyzer_lib.models.BaseModel import BaseModel class HeatMapModel(BaseModel): diff --git a/tc_analyzer_lib/models/RawInfoModel.py b/tc_analyzer_lib/models/RawInfoModel.py index afd86bb..51f7f68 100644 --- a/tc_analyzer_lib/models/RawInfoModel.py +++ b/tc_analyzer_lib/models/RawInfoModel.py @@ -3,9 +3,9 @@ from datetime import datetime, timedelta from typing import Any -from tc_analyzer_lib.models.BaseModel import BaseModel from pymongo import ASCENDING from pymongo.database import Database +from tc_analyzer_lib.models.BaseModel import BaseModel class RawInfoModel(BaseModel): diff --git a/tc_analyzer_lib/publish_on_success.py b/tc_analyzer_lib/publish_on_success.py index be53af7..5b22649 100644 --- a/tc_analyzer_lib/publish_on_success.py +++ b/tc_analyzer_lib/publish_on_success.py @@ -1,14 +1,14 @@ import logging from tc_analyzer_lib.automation.automation_workflow import AutomationWorkflow -from tc_messageBroker.rabbit_mq.event import Event -from tc_messageBroker.rabbit_mq.queue import Queue from tc_analyzer_lib.utils.get_guild_utils import ( get_platform_guild_id, get_platform_name, get_platform_community_owner, ) from tc_analyzer_lib.utils.rabbitmq import RabbitMQAccess +from tc_messageBroker.rabbit_mq.event import Event +from tc_messageBroker.rabbit_mq.queue import Queue def publish_on_success(platform_id: str, recompute: bool) -> None: diff --git a/tc_analyzer_lib/schemas/__init__.py b/tc_analyzer_lib/schemas/__init__.py index 054b06b..fa41b99 100644 --- a/tc_analyzer_lib/schemas/__init__.py +++ b/tc_analyzer_lib/schemas/__init__.py @@ -1,6 +1,6 @@ # flake8: noqa from .activity_type import ActivityDirection, ActivityType +from .graph import GraphSchema from .hourly_analytics import HourlyAnalytics from .raw_analytics import RawAnalytics from .raw_analytics_item import RawAnalyticsItem -from .graph import GraphSchema diff --git a/tc_analyzer_lib/tc_analyzer.py b/tc_analyzer_lib/tc_analyzer.py index e72eac5..57d0a8a 100644 --- a/tc_analyzer_lib/tc_analyzer.py +++ b/tc_analyzer_lib/tc_analyzer.py @@ -1,6 +1,6 @@ import logging - from datetime import datetime + from tc_analyzer_lib.metrics.analyzer_memberactivities import MemberActivities from tc_analyzer_lib.metrics.heatmaps import Heatmaps from tc_analyzer_lib.metrics.neo4j_analytics import Neo4JAnalytics @@ -9,7 +9,6 @@ from tc_analyzer_lib.schemas import GraphSchema from tc_analyzer_lib.schemas.platform_configs import DiscordAnalyzerConfig from tc_analyzer_lib.schemas.platform_configs.config_base import PlatformConfigBase -from tc_analyzer_lib.schemas.platform_configs import DiscordAnalyzerConfig class TCAnalyzer(AnalyzerDBManager): diff --git a/tc_analyzer_lib/utils/rabbitmq.py b/tc_analyzer_lib/utils/rabbitmq.py index c8dee69..a833b0f 100644 --- a/tc_analyzer_lib/utils/rabbitmq.py +++ b/tc_analyzer_lib/utils/rabbitmq.py @@ -1,8 +1,8 @@ import logging +from tc_analyzer_lib.utils.credentials import get_rabbit_mq_credentials from tc_messageBroker import RabbitMQ from tc_messageBroker.rabbit_mq.queue import Queue -from tc_analyzer_lib.utils.credentials import get_rabbit_mq_credentials class RabbitMQAccess: diff --git a/tests/integration/test_analyzer_platform_fetch_period.py b/tests/integration/test_analyzer_platform_fetch_period.py index f041d25..9ca4f44 100644 --- a/tests/integration/test_analyzer_platform_fetch_period.py +++ b/tests/integration/test_analyzer_platform_fetch_period.py @@ -1,9 +1,9 @@ -from bson import ObjectId from datetime import datetime from unittest import TestCase -from tc_analyzer_lib.utils.mongo import MongoSingleton +from bson import ObjectId from tc_analyzer_lib.metrics.utils import Platform +from tc_analyzer_lib.utils.mongo import MongoSingleton class TestPlatformUtilsFetchPeriod(TestCase): diff --git a/tests/integration/test_analyzer_platform_fetch_resources.py b/tests/integration/test_analyzer_platform_fetch_resources.py index d693d5a..eb46fd2 100644 --- a/tests/integration/test_analyzer_platform_fetch_resources.py +++ b/tests/integration/test_analyzer_platform_fetch_resources.py @@ -1,9 +1,9 @@ -from bson import ObjectId from datetime import datetime from unittest import TestCase -from tc_analyzer_lib.utils.mongo import MongoSingleton +from bson import ObjectId from tc_analyzer_lib.metrics.utils import Platform +from tc_analyzer_lib.utils.mongo import MongoSingleton class TestPlatformUtilsFetchResources(TestCase): diff --git a/tests/integration/test_analyzer_utils_platform.py b/tests/integration/test_analyzer_utils_platform.py index 8cad941..a6974a5 100644 --- a/tests/integration/test_analyzer_utils_platform.py +++ b/tests/integration/test_analyzer_utils_platform.py @@ -1,6 +1,6 @@ -from bson import ObjectId from unittest import TestCase +from bson import ObjectId from tc_analyzer_lib.metrics.utils import Platform from tc_analyzer_lib.utils.mongo import MongoSingleton @@ -150,25 +150,6 @@ def test_get_community_id_single_platform_available(self): self.assertEqual(expected_community_id, community_id) - def test_get_community_id_single_platform_available(self): - platform_id = "60d5ec44f9a3c2b6d7e2d11a" - expected_community_id = "77d5ec44f6a3c2b6d7e2d11a" - - self.client["Core"]["platforms"].insert_one( - { - "_id": ObjectId(platform_id), - "name": "discord", - "community": ObjectId(expected_community_id), - "metadata": { - "isInProgress": True, - }, - } - ) - platform_obj = Platform(platform_id) - community_id = platform_obj.get_community_id() - - self.assertEqual(expected_community_id, community_id) - def test_get_community_id_irrelevant_platform_available(self): platform_id = "60d5ec44f9a3c2b6d7e2d11a" platform_id2 = "60d5ec44f9a3c2b6d7e2d11b" diff --git a/tests/integration/test_analyzer_utils_platform_parameters.py b/tests/integration/test_analyzer_utils_platform_parameters.py index 49365e9..c6add2a 100644 --- a/tests/integration/test_analyzer_utils_platform_parameters.py +++ b/tests/integration/test_analyzer_utils_platform_parameters.py @@ -1,7 +1,7 @@ -from bson import ObjectId -from unittest import TestCase from datetime import datetime, timedelta +from unittest import TestCase +from bson import ObjectId from tc_analyzer_lib.metrics.utils import Platform from tc_analyzer_lib.utils.mongo import MongoSingleton diff --git a/tests/integration/test_assess_engagement_mention.py b/tests/integration/test_assess_engagement_mention.py index 9a0f05e..01f4795 100644 --- a/tests/integration/test_assess_engagement_mention.py +++ b/tests/integration/test_assess_engagement_mention.py @@ -2,13 +2,13 @@ from unittest import TestCase from tc_analyzer_lib.algorithms.utils.member_activity_utils import assess_engagement +from tc_analyzer_lib.metrics.heatmaps import Heatmaps from tc_analyzer_lib.metrics.utils.analyzer_db_manager import AnalyzerDBManager +from tc_analyzer_lib.schemas import GraphSchema +from tc_analyzer_lib.schemas.platform_configs import DiscordAnalyzerConfig from .utils.analyzer_setup import launch_db_access from .utils.setup_platform import setup_platform -from tc_analyzer_lib.metrics.heatmaps import Heatmaps -from tc_analyzer_lib.schemas import GraphSchema -from tc_analyzer_lib.schemas.platform_configs import DiscordAnalyzerConfig class TestAssessEngagementMentions(TestCase): diff --git a/tests/integration/test_assess_engagement_reactions.py b/tests/integration/test_assess_engagement_reactions.py index 4ac59f7..5e3b34d 100644 --- a/tests/integration/test_assess_engagement_reactions.py +++ b/tests/integration/test_assess_engagement_reactions.py @@ -2,13 +2,13 @@ from unittest import TestCase from tc_analyzer_lib.algorithms.utils.member_activity_utils import assess_engagement +from tc_analyzer_lib.metrics.heatmaps import Heatmaps from tc_analyzer_lib.metrics.utils.analyzer_db_manager import AnalyzerDBManager +from tc_analyzer_lib.schemas import GraphSchema +from tc_analyzer_lib.schemas.platform_configs import DiscordAnalyzerConfig from .utils.analyzer_setup import launch_db_access from .utils.setup_platform import setup_platform -from tc_analyzer_lib.metrics.heatmaps import Heatmaps -from tc_analyzer_lib.schemas import GraphSchema -from tc_analyzer_lib.schemas.platform_configs import DiscordAnalyzerConfig class TestAssessEngagementReactions(TestCase): diff --git a/tests/integration/test_assess_engagement_replies.py b/tests/integration/test_assess_engagement_replies.py index eff015b..1182c21 100644 --- a/tests/integration/test_assess_engagement_replies.py +++ b/tests/integration/test_assess_engagement_replies.py @@ -2,13 +2,13 @@ from unittest import TestCase from tc_analyzer_lib.algorithms.utils.member_activity_utils import assess_engagement +from tc_analyzer_lib.metrics.heatmaps import Heatmaps from tc_analyzer_lib.metrics.utils.analyzer_db_manager import AnalyzerDBManager +from tc_analyzer_lib.schemas import GraphSchema +from tc_analyzer_lib.schemas.platform_configs import DiscordAnalyzerConfig from .utils.analyzer_setup import launch_db_access from .utils.setup_platform import setup_platform -from tc_analyzer_lib.metrics.heatmaps import Heatmaps -from tc_analyzer_lib.schemas import GraphSchema -from tc_analyzer_lib.schemas.platform_configs import DiscordAnalyzerConfig class TestAssessEngagementReplies(TestCase): diff --git a/tests/integration/test_automation_db_load_from_db.py b/tests/integration/test_automation_db_load_from_db.py index 5a758e2..4951bec 100644 --- a/tests/integration/test_automation_db_load_from_db.py +++ b/tests/integration/test_automation_db_load_from_db.py @@ -2,8 +2,8 @@ import unittest from datetime import datetime, timedelta -from tc_analyzer_lib.automation.utils.model import AutomationDB from dotenv import load_dotenv +from tc_analyzer_lib.automation.utils.model import AutomationDB from tc_analyzer_lib.utils.mongo import MongoSingleton diff --git a/tests/integration/test_automation_db_save_to_db.py b/tests/integration/test_automation_db_save_to_db.py index 3d650c0..f360321 100644 --- a/tests/integration/test_automation_db_save_to_db.py +++ b/tests/integration/test_automation_db_save_to_db.py @@ -2,9 +2,9 @@ import unittest from datetime import datetime, timezone +from dotenv import load_dotenv from tc_analyzer_lib.automation.utils.interfaces import Automation from tc_analyzer_lib.automation.utils.model import AutomationDB -from dotenv import load_dotenv from tc_analyzer_lib.utils.mongo import MongoSingleton diff --git a/tests/integration/test_get_guild_owner.py b/tests/integration/test_get_guild_owner.py index 83a1f88..844beab 100644 --- a/tests/integration/test_get_guild_owner.py +++ b/tests/integration/test_get_guild_owner.py @@ -1,9 +1,9 @@ -from bson import ObjectId -from unittest import TestCase from datetime import datetime, timedelta +from unittest import TestCase -from tc_analyzer_lib.utils.mongo import MongoSingleton +from bson import ObjectId from tc_analyzer_lib.utils.get_guild_utils import get_platform_community_owner +from tc_analyzer_lib.utils.mongo import MongoSingleton class TestGetGuildOwner(TestCase): diff --git a/tests/integration/test_get_past_7_days_heatmaps.py b/tests/integration/test_get_past_7_days_heatmaps.py index 25d2076..a1c4686 100644 --- a/tests/integration/test_get_past_7_days_heatmaps.py +++ b/tests/integration/test_get_past_7_days_heatmaps.py @@ -1,9 +1,7 @@ from datetime import datetime, timedelta import numpy as np -from tc_analyzer_lib.algorithms.utils.member_activity_utils import ( - get_users_past_window, -) +from tc_analyzer_lib.algorithms.utils.member_activity_utils import get_users_past_window from .utils.analyzer_setup import launch_db_access diff --git a/tests/integration/test_network_graph_creation.py b/tests/integration/test_network_graph_creation.py index d19f916..03cd493 100644 --- a/tests/integration/test_network_graph_creation.py +++ b/tests/integration/test_network_graph_creation.py @@ -10,6 +10,9 @@ @pytest.mark.skip("To be updated to platform centric!") def test_network_graph_create(): + """ + testing the mock graph generation + """ from .utils.mock_graph import generate_mock_graph, store_mock_data_in_neo4j community_id = "4321" @@ -160,21 +163,21 @@ def test_network_graph_create(): # DATABASE SAVING - store_mock_data_in_neo4j( - graph_dict=graph_dict, guildId=guildId, community_id=community_id - ) - - results = neo4j_ops.gds.run_cypher( - f""" - MATCH (a:{user_label}) -[:{is_member}] -> (g:{platform_label} {{guildId: '{platform_id}'}}) - MATCH (a)-[r{interacted_with}]-> (b:{user_label}) - RETURN - a.id as fromUserId, - r.weight as weight, - r.date as date, - b.id as toUserId - """ - ) - print(desired_outputs) - print(results) - assert desired_outputs in results.values + # store_mock_data_in_neo4j( + # graph_dict=graph_dict, guildId=guildId, community_id=community_id + # ) + + # results = neo4j_ops.gds.run_cypher( + # f""" + # MATCH (a:{user_label}) -[:{is_member}] -> (g:{platform_label} {{guildId: '{platform_id}'}}) + # MATCH (a)-[r{interacted_with}]-> (b:{user_label}) + # RETURN + # a.id as fromUserId, + # r.weight as weight, + # r.date as date, + # b.id as toUserId + # """ + # ) + # print(desired_outputs) + # print(results) + # assert desired_outputs in results.values diff --git a/tests/integration/test_publish_on_success_recompute_false.py b/tests/integration/test_publish_on_success_recompute_false.py index 784b363..007b9f6 100644 --- a/tests/integration/test_publish_on_success_recompute_false.py +++ b/tests/integration/test_publish_on_success_recompute_false.py @@ -1,15 +1,15 @@ import os from datetime import datetime, timedelta +from bson.objectid import ObjectId +from dotenv import load_dotenv from tc_analyzer_lib.automation.utils.interfaces import ( Automation, AutomationAction, AutomationReport, AutomationTrigger, ) -from bson.objectid import ObjectId from tc_analyzer_lib.publish_on_success import publish_on_success -from dotenv import load_dotenv from .utils.analyzer_setup import launch_db_access diff --git a/tests/integration/test_publish_on_success_recompute_true.py b/tests/integration/test_publish_on_success_recompute_true.py index e57680b..79ef6e3 100644 --- a/tests/integration/test_publish_on_success_recompute_true.py +++ b/tests/integration/test_publish_on_success_recompute_true.py @@ -1,15 +1,15 @@ import os from datetime import datetime, timedelta +from bson.objectid import ObjectId +from dotenv import load_dotenv from tc_analyzer_lib.automation.utils.interfaces import ( Automation, AutomationAction, AutomationReport, AutomationTrigger, ) -from bson.objectid import ObjectId from tc_analyzer_lib.publish_on_success import publish_on_success -from dotenv import load_dotenv from .utils.analyzer_setup import launch_db_access diff --git a/tests/integration/test_service_connection.py b/tests/integration/test_service_connection.py index 94fa7b7..ff828d2 100644 --- a/tests/integration/test_service_connection.py +++ b/tests/integration/test_service_connection.py @@ -1,5 +1,5 @@ -from tc_messageBroker.message_broker import RabbitMQ from tc_analyzer_lib.utils.credentials import get_rabbit_mq_credentials +from tc_messageBroker.message_broker import RabbitMQ def test_rabbit_mq_connect(): diff --git a/tests/integration/utils/analyzer_setup.py b/tests/integration/utils/analyzer_setup.py index 4e03ab2..3c4c87f 100644 --- a/tests/integration/utils/analyzer_setup.py +++ b/tests/integration/utils/analyzer_setup.py @@ -1,5 +1,5 @@ -from tc_analyzer_lib.DB_operations.mongodb_access import DB_access from dotenv import load_dotenv +from tc_analyzer_lib.DB_operations.mongodb_access import DB_access def launch_db_access(platform_id: str): diff --git a/tests/integration/utils/mock_graph.py b/tests/integration/utils/mock_graph.py index f4b1479..14eee74 100644 --- a/tests/integration/utils/mock_graph.py +++ b/tests/integration/utils/mock_graph.py @@ -1,7 +1,7 @@ -import os +# import os -from tc_analyzer_lib.tc_analyzer import TCAnalyzer -from dotenv import load_dotenv +# from dotenv import load_dotenv +# from tc_analyzer_lib.tc_analyzer import TCAnalyzer from tc_core_analyzer_lib.assess_engagement import EngagementAssessment from tc_core_analyzer_lib.utils.activity import DiscordActivity @@ -64,25 +64,25 @@ def generate_mock_graph(int_matrix, acc_names): return graph -def store_mock_data_in_neo4j(graph_dict, guildId, community_id): - # CREDS - load_dotenv() +# def store_mock_data_in_neo4j(graph_dict, guildId, community_id): +# # CREDS +# load_dotenv() - analyzer = TCAnalyzer(guildId) - analyzer.database_connect() +# analyzer = TCAnalyzer(guildId) +# analyzer.database_connect() - guilds_data = {} +# guilds_data = {} - guilds_data["heatmaps"] = None - guilds_data["memberactivities"] = ( - None, - graph_dict, - ) +# guilds_data["heatmaps"] = None +# guilds_data["memberactivities"] = ( +# None, +# graph_dict, +# ) - analyzer.DB_connections.store_analytics_data( - analytics_data=guilds_data, - guild_id=guildId, - community_id=community_id, - remove_heatmaps=False, - remove_memberactivities=False, - ) +# analyzer.DB_connections.store_analytics_data( +# analytics_data=guilds_data, +# guild_id=guildId, +# community_id=community_id, +# remove_heatmaps=False, +# remove_memberactivities=False, +# ) From f2430a5e75a051bd562c221bb585d93237a4e413 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Tue, 2 Jul 2024 17:46:36 +0330 Subject: [PATCH 19/23] fix: the test case is for mock graph genertion part! It is not needed. --- .../test_network_graph_creation.py | 322 +++++++++--------- 1 file changed, 161 insertions(+), 161 deletions(-) diff --git a/tests/integration/test_network_graph_creation.py b/tests/integration/test_network_graph_creation.py index 03cd493..eeda953 100644 --- a/tests/integration/test_network_graph_creation.py +++ b/tests/integration/test_network_graph_creation.py @@ -1,165 +1,165 @@ # test out local clustering coefficient with all nodes connected -from datetime import datetime, timedelta - -import networkx as nx -import numpy as np -import pytest -from tc_analyzer_lib.algorithms.utils.activity import Activity -from tc_neo4j_lib.neo4j_ops import Neo4jOps - - -@pytest.mark.skip("To be updated to platform centric!") -def test_network_graph_create(): - """ - testing the mock graph generation - """ - from .utils.mock_graph import generate_mock_graph, store_mock_data_in_neo4j - - community_id = "4321" - neo4j_ops = Neo4jOps.get_instance() - # deleting all data - neo4j_ops.gds.run_cypher("MATCH (n) DETACH DELETE (n)") - - guildId = "1234" - acc_names = np.array(["1000", "1001", "1002"]) - graph_dict = {} - - # saving the desired outputs - desired_outputs = [] - - # Generating 1st graph - np.random.seed(123) - int_matrix = {} - int_matrix[Activity.Reply] = np.array( - [ - [0, 1, 2], - [0, 0, 3], - [0, 4, 0], - ] - ) - - int_matrix[Activity.Mention] = np.array( - [ - [0, 1, 2], - [0, 0, 3], - [0, 4, 0], - ] - ) - - int_matrix[Activity.Reaction] = np.array( - [ - [0, 1, 2], - [0, 0, 3], - [0, 4, 0], - ] - ) - - graph = generate_mock_graph(int_matrix, acc_names) - - node_att = {} - for i, node in enumerate(list(graph)): - node_att[node] = acc_names[i] - - nx.set_node_attributes(graph, node_att, "acc_name") - - graph_date = datetime.now() - graph_date_timestamp = graph_date.replace( - hour=0, minute=0, second=0, microsecond=0 - ).timestamp() - graph_dict[graph_date] = graph - - desired_outputs.extend( - [ - ["1000", 1, graph_date_timestamp, "1001"], - ["1000", 2, graph_date_timestamp, "1002"], - ["1001", 3, graph_date_timestamp, "1002"], - ["1002", 4, graph_date_timestamp, "1001"], - ] - ) - - # Generating 2nd graph - int_matrix = {} - int_matrix[Activity.Reply] = np.array( - [ - [0, 0, 1], - [2, 0, 5], - [0, 0, 0], - ] - ) - - int_matrix[Activity.Mention] = np.array( - [ - [0, 0, 1], - [2, 0, 5], - [0, 0, 0], - ] - ) - - int_matrix[Activity.Reaction] = np.array( - [ - [0, 0, 1], - [2, 0, 5], - [0, 0, 0], - ] - ) - - graph = generate_mock_graph(int_matrix, acc_names) - - nx.set_node_attributes(graph, node_att, "acc_name") - - graph_date = datetime.now() + timedelta(days=-1) - graph_date_timestamp = graph_date.replace( - hour=0, minute=0, second=0, microsecond=0 - ).timestamp() - graph_dict[graph_date] = graph - - desired_outputs.extend( - [ - ["1000", 1, graph_date_timestamp, "1002"], - ["1001", 2, graph_date_timestamp, "1000"], - ["1001", 5, graph_date_timestamp, "1002"], - ] - ) - - # generating 3rd graph - int_matrix = {} - int_matrix[Activity.Reply] = np.array( - [ - [0, 0, 3], - [0, 0, 0], - [1, 0, 0], - ] - ) - int_matrix[Activity.Mention] = np.array( - [ - [0, 0, 3], - [0, 0, 0], - [1, 0, 0], - ] - ) - int_matrix[Activity.Reaction] = np.array( - [ - [0, 0, 3], - [0, 0, 0], - [1, 0, 0], - ] - ) - - graph = generate_mock_graph(int_matrix, acc_names) - nx.set_node_attributes(graph, node_att, "acc_name") - - graph_date = datetime.now() + timedelta(days=-8) - graph_date_timestamp = graph_date.replace( - hour=0, minute=0, second=0, microsecond=0 - ).timestamp() - graph_dict[graph_date] = graph - - desired_outputs.extend( - [ - ["1000", 3, graph_date_timestamp, "1002"], - ["1002", 1, graph_date_timestamp, "1000"], - ] - ) +# from datetime import datetime, timedelta + +# import networkx as nx +# import numpy as np +# import pytest +# from tc_analyzer_lib.algorithms.utils.activity import Activity +# from tc_neo4j_lib.neo4j_ops import Neo4jOps + + +# @pytest.mark.skip("To be updated to platform centric!") +# def test_network_graph_create(): +# """ +# testing the mock graph generation +# """ +# from .utils.mock_graph import generate_mock_graph, store_mock_data_in_neo4j + +# community_id = "4321" +# neo4j_ops = Neo4jOps.get_instance() +# # deleting all data +# neo4j_ops.gds.run_cypher("MATCH (n) DETACH DELETE (n)") + +# guildId = "1234" +# acc_names = np.array(["1000", "1001", "1002"]) +# graph_dict = {} + +# # saving the desired outputs +# desired_outputs = [] + +# # Generating 1st graph +# np.random.seed(123) +# int_matrix = {} +# int_matrix[Activity.Reply] = np.array( +# [ +# [0, 1, 2], +# [0, 0, 3], +# [0, 4, 0], +# ] +# ) + +# int_matrix[Activity.Mention] = np.array( +# [ +# [0, 1, 2], +# [0, 0, 3], +# [0, 4, 0], +# ] +# ) + +# int_matrix[Activity.Reaction] = np.array( +# [ +# [0, 1, 2], +# [0, 0, 3], +# [0, 4, 0], +# ] +# ) + +# graph = generate_mock_graph(int_matrix, acc_names) + +# node_att = {} +# for i, node in enumerate(list(graph)): +# node_att[node] = acc_names[i] + +# nx.set_node_attributes(graph, node_att, "acc_name") + +# graph_date = datetime.now() +# graph_date_timestamp = graph_date.replace( +# hour=0, minute=0, second=0, microsecond=0 +# ).timestamp() +# graph_dict[graph_date] = graph + +# desired_outputs.extend( +# [ +# ["1000", 1, graph_date_timestamp, "1001"], +# ["1000", 2, graph_date_timestamp, "1002"], +# ["1001", 3, graph_date_timestamp, "1002"], +# ["1002", 4, graph_date_timestamp, "1001"], +# ] +# ) + +# # Generating 2nd graph +# int_matrix = {} +# int_matrix[Activity.Reply] = np.array( +# [ +# [0, 0, 1], +# [2, 0, 5], +# [0, 0, 0], +# ] +# ) + +# int_matrix[Activity.Mention] = np.array( +# [ +# [0, 0, 1], +# [2, 0, 5], +# [0, 0, 0], +# ] +# ) + +# int_matrix[Activity.Reaction] = np.array( +# [ +# [0, 0, 1], +# [2, 0, 5], +# [0, 0, 0], +# ] +# ) + +# graph = generate_mock_graph(int_matrix, acc_names) + +# nx.set_node_attributes(graph, node_att, "acc_name") + +# graph_date = datetime.now() + timedelta(days=-1) +# graph_date_timestamp = graph_date.replace( +# hour=0, minute=0, second=0, microsecond=0 +# ).timestamp() +# graph_dict[graph_date] = graph + +# desired_outputs.extend( +# [ +# ["1000", 1, graph_date_timestamp, "1002"], +# ["1001", 2, graph_date_timestamp, "1000"], +# ["1001", 5, graph_date_timestamp, "1002"], +# ] +# ) + +# # generating 3rd graph +# int_matrix = {} +# int_matrix[Activity.Reply] = np.array( +# [ +# [0, 0, 3], +# [0, 0, 0], +# [1, 0, 0], +# ] +# ) +# int_matrix[Activity.Mention] = np.array( +# [ +# [0, 0, 3], +# [0, 0, 0], +# [1, 0, 0], +# ] +# ) +# int_matrix[Activity.Reaction] = np.array( +# [ +# [0, 0, 3], +# [0, 0, 0], +# [1, 0, 0], +# ] +# ) + +# graph = generate_mock_graph(int_matrix, acc_names) +# nx.set_node_attributes(graph, node_att, "acc_name") + +# graph_date = datetime.now() + timedelta(days=-8) +# graph_date_timestamp = graph_date.replace( +# hour=0, minute=0, second=0, microsecond=0 +# ).timestamp() +# graph_dict[graph_date] = graph + +# desired_outputs.extend( +# [ +# ["1000", 3, graph_date_timestamp, "1002"], +# ["1002", 1, graph_date_timestamp, "1000"], +# ] +# ) # DATABASE SAVING From 4dfb41ea2acd33690f5abc9b734a395e3246e9c1 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Tue, 2 Jul 2024 17:47:09 +0330 Subject: [PATCH 20/23] fix: isort linter issue! --- tc_analyzer_lib/publish_on_success.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tc_analyzer_lib/publish_on_success.py b/tc_analyzer_lib/publish_on_success.py index 5b22649..dc9d0ca 100644 --- a/tc_analyzer_lib/publish_on_success.py +++ b/tc_analyzer_lib/publish_on_success.py @@ -2,9 +2,9 @@ from tc_analyzer_lib.automation.automation_workflow import AutomationWorkflow from tc_analyzer_lib.utils.get_guild_utils import ( + get_platform_community_owner, get_platform_guild_id, get_platform_name, - get_platform_community_owner, ) from tc_analyzer_lib.utils.rabbitmq import RabbitMQAccess from tc_messageBroker.rabbit_mq.event import Event From 549f834d38de86cefbf12202979ded2b2e1cf8bc Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Tue, 2 Jul 2024 18:39:49 +0330 Subject: [PATCH 21/23] fix: trying to skip black linter! --- tests/integration/test_network_graph_creation.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/integration/test_network_graph_creation.py b/tests/integration/test_network_graph_creation.py index eeda953..53945ab 100644 --- a/tests/integration/test_network_graph_creation.py +++ b/tests/integration/test_network_graph_creation.py @@ -1,3 +1,4 @@ +# fmt: off # test out local clustering coefficient with all nodes connected # from datetime import datetime, timedelta @@ -181,3 +182,5 @@ # print(desired_outputs) # print(results) # assert desired_outputs in results.values + +# fmt: on \ No newline at end of file From ad088eeeb84347b3f069cfb97dbde665717f2fd6 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Wed, 3 Jul 2024 09:34:28 +0330 Subject: [PATCH 22/23] fix: deleting the case was for mock graph generation! It isn't needed anymore as we're not producing mock graphs. In first try we tried commenting it out but still it was producing lint errors, so we're removing it as it is also no longer needed. --- .../test_network_graph_creation.py | 186 ------------------ 1 file changed, 186 deletions(-) delete mode 100644 tests/integration/test_network_graph_creation.py diff --git a/tests/integration/test_network_graph_creation.py b/tests/integration/test_network_graph_creation.py deleted file mode 100644 index 53945ab..0000000 --- a/tests/integration/test_network_graph_creation.py +++ /dev/null @@ -1,186 +0,0 @@ -# fmt: off -# test out local clustering coefficient with all nodes connected -# from datetime import datetime, timedelta - -# import networkx as nx -# import numpy as np -# import pytest -# from tc_analyzer_lib.algorithms.utils.activity import Activity -# from tc_neo4j_lib.neo4j_ops import Neo4jOps - - -# @pytest.mark.skip("To be updated to platform centric!") -# def test_network_graph_create(): -# """ -# testing the mock graph generation -# """ -# from .utils.mock_graph import generate_mock_graph, store_mock_data_in_neo4j - -# community_id = "4321" -# neo4j_ops = Neo4jOps.get_instance() -# # deleting all data -# neo4j_ops.gds.run_cypher("MATCH (n) DETACH DELETE (n)") - -# guildId = "1234" -# acc_names = np.array(["1000", "1001", "1002"]) -# graph_dict = {} - -# # saving the desired outputs -# desired_outputs = [] - -# # Generating 1st graph -# np.random.seed(123) -# int_matrix = {} -# int_matrix[Activity.Reply] = np.array( -# [ -# [0, 1, 2], -# [0, 0, 3], -# [0, 4, 0], -# ] -# ) - -# int_matrix[Activity.Mention] = np.array( -# [ -# [0, 1, 2], -# [0, 0, 3], -# [0, 4, 0], -# ] -# ) - -# int_matrix[Activity.Reaction] = np.array( -# [ -# [0, 1, 2], -# [0, 0, 3], -# [0, 4, 0], -# ] -# ) - -# graph = generate_mock_graph(int_matrix, acc_names) - -# node_att = {} -# for i, node in enumerate(list(graph)): -# node_att[node] = acc_names[i] - -# nx.set_node_attributes(graph, node_att, "acc_name") - -# graph_date = datetime.now() -# graph_date_timestamp = graph_date.replace( -# hour=0, minute=0, second=0, microsecond=0 -# ).timestamp() -# graph_dict[graph_date] = graph - -# desired_outputs.extend( -# [ -# ["1000", 1, graph_date_timestamp, "1001"], -# ["1000", 2, graph_date_timestamp, "1002"], -# ["1001", 3, graph_date_timestamp, "1002"], -# ["1002", 4, graph_date_timestamp, "1001"], -# ] -# ) - -# # Generating 2nd graph -# int_matrix = {} -# int_matrix[Activity.Reply] = np.array( -# [ -# [0, 0, 1], -# [2, 0, 5], -# [0, 0, 0], -# ] -# ) - -# int_matrix[Activity.Mention] = np.array( -# [ -# [0, 0, 1], -# [2, 0, 5], -# [0, 0, 0], -# ] -# ) - -# int_matrix[Activity.Reaction] = np.array( -# [ -# [0, 0, 1], -# [2, 0, 5], -# [0, 0, 0], -# ] -# ) - -# graph = generate_mock_graph(int_matrix, acc_names) - -# nx.set_node_attributes(graph, node_att, "acc_name") - -# graph_date = datetime.now() + timedelta(days=-1) -# graph_date_timestamp = graph_date.replace( -# hour=0, minute=0, second=0, microsecond=0 -# ).timestamp() -# graph_dict[graph_date] = graph - -# desired_outputs.extend( -# [ -# ["1000", 1, graph_date_timestamp, "1002"], -# ["1001", 2, graph_date_timestamp, "1000"], -# ["1001", 5, graph_date_timestamp, "1002"], -# ] -# ) - -# # generating 3rd graph -# int_matrix = {} -# int_matrix[Activity.Reply] = np.array( -# [ -# [0, 0, 3], -# [0, 0, 0], -# [1, 0, 0], -# ] -# ) -# int_matrix[Activity.Mention] = np.array( -# [ -# [0, 0, 3], -# [0, 0, 0], -# [1, 0, 0], -# ] -# ) -# int_matrix[Activity.Reaction] = np.array( -# [ -# [0, 0, 3], -# [0, 0, 0], -# [1, 0, 0], -# ] -# ) - -# graph = generate_mock_graph(int_matrix, acc_names) -# nx.set_node_attributes(graph, node_att, "acc_name") - -# graph_date = datetime.now() + timedelta(days=-8) -# graph_date_timestamp = graph_date.replace( -# hour=0, minute=0, second=0, microsecond=0 -# ).timestamp() -# graph_dict[graph_date] = graph - -# desired_outputs.extend( -# [ -# ["1000", 3, graph_date_timestamp, "1002"], -# ["1002", 1, graph_date_timestamp, "1000"], -# ] -# ) - - # DATABASE SAVING - - # store_mock_data_in_neo4j( - # graph_dict=graph_dict, guildId=guildId, community_id=community_id - # ) - - # results = neo4j_ops.gds.run_cypher( - # f""" - # MATCH (a:{user_label}) -[:{is_member}] -> (g:{platform_label} {{guildId: '{platform_id}'}}) - # MATCH (a)-[r{interacted_with}]-> (b:{user_label}) - # RETURN - # a.id as fromUserId, - # r.weight as weight, - # r.date as date, - # b.id as toUserId - # """ - # ) - # print(desired_outputs) - # print(results) - # assert desired_outputs in results.values - -# fmt: on \ No newline at end of file From 652fc02e0c2cb1e62dac4c826e90c222cb2a65ba Mon Sep 17 00:00:00 2001 From: Mohammad Amin Dadgar <48308230+amindadgar@users.noreply.github.com> Date: Wed, 3 Jul 2024 11:26:10 +0330 Subject: [PATCH 23/23] Update requirements.txt --- requirements.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/requirements.txt b/requirements.txt index 4389aba..b778b21 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,11 +2,9 @@ attrs==22.2.0 dnspython==2.2.1 exceptiongroup==1.1.0 iniconfig==2.0.0 -numpy==1.24.1 packaging==23.0 pluggy==1.0.0 pymongo==4.3.3 -pytest==7.2.0 python-dateutil==2.8.2 pytz==2022.7.1 python-dotenv>=1.0.0 @@ -14,8 +12,6 @@ six==1.16.0 tomli==2.0.1 networkx==3.1 requests==2.29.0 -pytest-cov==4.0.0 -coverage==7.2.5 python-dateutil==2.8.2 tqdm tc-messageBroker==1.6.7 @@ -23,6 +19,6 @@ sentry-sdk rq redis tc-core-analyzer-lib==1.3.1 -tc-neo4j-lib==2.0.0 +tc-neo4j-lib==2.0.1 pybars3 backoff==2.2.1