diff --git a/src/app/social/reddit.py b/src/app/social/reddit.py index fa2e0e1..eeca968 100644 --- a/src/app/social/reddit.py +++ b/src/app/social/reddit.py @@ -1,6 +1,6 @@ import os from praw import Reddit # type: ignore -from praw.models import Submission, MoreComments # type: ignore +from praw.models import Submission # type: ignore from app.base.social import SocialWrapper, SocialPost, SocialComment @@ -28,16 +28,14 @@ def extract_post(post: Submission) -> SocialPost: social.title = post.title social.description = post.selftext - for i, top_comment in enumerate(post.comments.list()): - if i >= MAX_COMMENTS: - break - if isinstance(top_comment, MoreComments): #skip MoreComments objects - continue - + for top_comment in post.comments: comment = SocialComment() comment.time = str(top_comment.created) comment.description = top_comment.body social.comments.append(comment) + + if len(social.comments) >= MAX_COMMENTS: + break return social class RedditWrapper(SocialWrapper): diff --git a/src/app/utils/wrapper_handler.py b/src/app/utils/wrapper_handler.py index 14a2d9f..6bc9481 100644 --- a/src/app/utils/wrapper_handler.py +++ b/src/app/utils/wrapper_handler.py @@ -51,7 +51,7 @@ class WrapperHandler(Generic[WrapperType]): log_info(f"{inspect.getsource(func).strip()} {inspect.getclosurevars(func).nonlocals}") iterations = 0 - error = "" + error = "No error" while iterations < len(self.wrappers): wrapper = self.wrappers[self.index] wrapper_name = wrapper.__class__.__name__ @@ -92,7 +92,7 @@ class WrapperHandler(Generic[WrapperType]): log_info(f"{inspect.getsource(func).strip()} {inspect.getclosurevars(func).nonlocals}") results: dict[str, OutputType] = {} - error = "" + error = "No error" for wrapper in self.wrappers: wrapper_name = wrapper.__class__.__name__ try: