Added missings docstrings

This commit is contained in:
2024-10-23 13:48:41 +02:00
parent b61e1ac6eb
commit 2d55d7a4d2
+5 -3
View File
@@ -13,6 +13,7 @@ class Reddit_Adapter(praw.Reddit):
number_of_instances = 0
def __init__(self, client_id:str, client_secret:str):
"""Initializes the Reddit Adapter, while stating credentials for the login to the reddit api"""
self.__instance_number = self.__class__.number_of_instances
self.__class__.number_of_instances += 1
@@ -28,17 +29,18 @@ class Reddit_Adapter(praw.Reddit):
"""Fetches specified submission (post) and returns it"""
start_time = datetime.now().timestamp()
self.__events.increment()
subm: praw.models.Submission = self.submission(url = post_url)
subm = self.submission(url = post_url)
self.__logger.debug(f"Submission for post (URL: {post_url}), successfully fetched after {get_elapsed_time_milliseconds(datetime.now().timestamp() - start_time)}")
return subm
def get_total_requests(self) -> int:
"""Returns the total number of events"""
"""Returns the total number of requests made since the creation of the adapter"""
return self.__events.get_total_events()
def get_events_last_5m(self) -> int:
"""Returns the number of requests made in the last 5 minutes"""
return self.__events.get_count("5m")
def get_events_last_5m_10m_15m(self) -> tuple[int]:
"""Returns an tuple containing the number of requests made in the last 5, 10 and 15 minutes"""
return (self.__events.get_count("5m"), self.__events.get_count("10m"), self.__events.get_count("15m"))