AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
fix(server): Fix bug in time comparison logic in RedditGetPostsBlock (#7426)
Toran Bruce Richards03ea4c2690e6
diff --git a/rnd/autogpt_server/autogpt_server/blocks/reddit.py b/rnd/autogpt_server/autogpt_server/blocks/reddit.pyindex 855611d4f6..de76d77498 100644--- a/rnd/autogpt_server/autogpt_server/blocks/reddit.py+++ b/rnd/autogpt_server/autogpt_server/blocks/reddit.py@@ -103,11 +103,16 @@ class RedditGetPostsBlock(Block):return subreddit.new(limit=input_data.post_limit)def run(self, input_data: Input) -> BlockOutput:+ current_time = datetime.now(tz=timezone.utc)for post in self.get_posts(input_data):- if input_data.last_minutes and post.created_utc < datetime.now(- tz=timezone.utc) - \- timedelta(minutes=input_data.last_minutes):- break+ if input_data.last_minutes:+ post_datetime = datetime.fromtimestamp(+ post.created_utc,+ tz=timezone.utc+ )+ time_difference = current_time - post_datetime+ if time_difference.total_seconds() / 60 > input_data.last_minutes:+ continueif input_data.last_post and post.id == input_data.last_post:break