Skip to content

Commit

Permalink
fix: black linter issues!
Browse files Browse the repository at this point in the history
  • Loading branch information
amindadgar committed Jul 2, 2024
1 parent a5713de commit 83a1670
Show file tree
Hide file tree
Showing 29 changed files with 97 additions and 59 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
description="A platform agnostic analyzer, computing the TogetherCrew dashboard metrics.",
long_description=open("README.md").read(),
install_requires=requirements,
)
)
4 changes: 2 additions & 2 deletions tc_analyzer_lib/publish_on_success.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand Down
1 change: 0 additions & 1 deletion tc_analyzer_lib/tc_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 10 additions & 4 deletions tc_analyzer_lib/utils/get_guild_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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(
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 3 additions & 1 deletion tests/integration/test_analyzer_period_35days_run_once.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
11 changes: 4 additions & 7 deletions tests/integration/test_get_guild_owner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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)
14 changes: 6 additions & 8 deletions tests/integration/test_publish_on_success_recompute_false.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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(
Expand Down
Loading

0 comments on commit 83a1670

Please sign in to comment.