generated from TogetherCrew/python-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
analyzer_init.py
45 lines (34 loc) · 1.17 KB
/
analyzer_init.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from typing import Any
from discord_analyzer import RnDaoAnalyzer
from utils.credentials import get_mongo_credentials
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) -> RnDaoAnalyzer:
"""
Returns:
---------
analyzer : RnDaoAnalyzer
"""
analyzer = RnDaoAnalyzer(self.guild_id)
# credentials
mongo_creds = get_mongo_credentials()
analyzer.set_mongo_database_info(
mongo_db_host=mongo_creds["host"],
mongo_db_password=mongo_creds["password"],
mongo_db_port=mongo_creds["port"],
mongo_db_user=mongo_creds["user"],
)
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