From d92cfc11eb8fe81cd53402bdf2c6ae58a479ca65 Mon Sep 17 00:00:00 2001 From: ChuckBuilds <33324927+ChuckBuilds@users.noreply.github.com> Date: Sun, 20 Apr 2025 16:11:45 -0500 Subject: [PATCH] Add randomization to stock news headlines display --- src/stock_news_manager.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/stock_news_manager.py b/src/stock_news_manager.py index 10c552ac..db4bd13f 100644 --- a/src/stock_news_manager.py +++ b/src/stock_news_manager.py @@ -327,13 +327,14 @@ class StockNewsManager: start_idx = self.current_rotation_index * self.headlines_per_rotation end_idx = min(start_idx + self.headlines_per_rotation, len(self.all_news_items)) - # If we've reached the end, start over + # If we've reached the end, shuffle and start over if start_idx >= len(self.all_news_items): self.current_rotation_index = 0 + random.shuffle(self.all_news_items) # Reshuffle when we've shown all headlines start_idx = 0 end_idx = min(self.headlines_per_rotation, len(self.all_news_items)) self.rotation_complete = True - logger.info("Completed a full rotation of news headlines") + logger.info("Completed a full rotation of news headlines, reshuffling for next round") # Get the current batch of headlines current_news = self.all_news_items[start_idx:end_idx]