Added missings docstrings
This commit is contained in:
@@ -13,6 +13,7 @@ class Reddit_Adapter(praw.Reddit):
|
|||||||
number_of_instances = 0
|
number_of_instances = 0
|
||||||
|
|
||||||
def __init__(self, client_id:str, client_secret:str):
|
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.__instance_number = self.__class__.number_of_instances
|
||||||
self.__class__.number_of_instances += 1
|
self.__class__.number_of_instances += 1
|
||||||
|
|
||||||
@@ -28,17 +29,18 @@ class Reddit_Adapter(praw.Reddit):
|
|||||||
"""Fetches specified submission (post) and returns it"""
|
"""Fetches specified submission (post) and returns it"""
|
||||||
start_time = datetime.now().timestamp()
|
start_time = datetime.now().timestamp()
|
||||||
self.__events.increment()
|
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)}")
|
self.__logger.debug(f"Submission for post (URL: {post_url}), successfully fetched after {get_elapsed_time_milliseconds(datetime.now().timestamp() - start_time)}")
|
||||||
return subm
|
return subm
|
||||||
|
|
||||||
|
|
||||||
def get_total_requests(self) -> int:
|
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()
|
return self.__events.get_total_events()
|
||||||
|
|
||||||
def get_events_last_5m(self) -> int:
|
def get_events_last_5m(self) -> int:
|
||||||
|
"""Returns the number of requests made in the last 5 minutes"""
|
||||||
return self.__events.get_count("5m")
|
return self.__events.get_count("5m")
|
||||||
|
|
||||||
def get_events_last_5m_10m_15m(self) -> tuple[int]:
|
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"))
|
return (self.__events.get_count("5m"), self.__events.get_count("10m"), self.__events.get_count("15m"))
|
||||||
Reference in New Issue
Block a user