From 91e6859e69bac0010d91342072df95e89c4bc849 Mon Sep 17 00:00:00 2001 From: Alex Selimov Date: Fri, 15 Aug 2025 21:43:18 -0400 Subject: [PATCH] Fix bug in article date determination --- src/rss2newsletter/ollama_client.py | 4 ++-- src/rss2newsletter/rss_fetcher.py | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/rss2newsletter/ollama_client.py b/src/rss2newsletter/ollama_client.py index 0aa18a4..b3c741e 100644 --- a/src/rss2newsletter/ollama_client.py +++ b/src/rss2newsletter/ollama_client.py @@ -31,13 +31,13 @@ def generate_summary( client_config: Dict[str, str], content: str, model: str = "llama3.2", - max_length: int = 150, + max_length: int = 75, ) -> Optional[str]: """Generate a summary of the given content using Ollama.""" if not content.strip(): return "No content available for summarization." - prompt = f"""Please provide a concise summary of the following article in approximately {max_length} words. Focus on the key points and main ideas: + prompt = f"""Please provide a concise summary of the following article in approximately {max_length} words. Return only the summary and nothing else. Focus on the key points and main ideas: {content} diff --git a/src/rss2newsletter/rss_fetcher.py b/src/rss2newsletter/rss_fetcher.py index 8278484..a08563c 100644 --- a/src/rss2newsletter/rss_fetcher.py +++ b/src/rss2newsletter/rss_fetcher.py @@ -25,7 +25,7 @@ def fetch_rss_feed(url: str) -> feedparser.FeedParserDict: def is_today(entry_date: Optional[str]) -> bool: - """Check if an entry was published today.""" + """Check if an entry was published within the last 24 hours.""" if not entry_date: return False @@ -37,10 +37,14 @@ def is_today(entry_date: Optional[str]) -> bool: if parsed_date.tzinfo is None: parsed_date = parsed_date.replace(tzinfo=timezone.utc) - # Get today's date in UTC - today = datetime.now(timezone.utc).date() + # Get the current time in UTC + now = datetime.now(timezone.utc) - return parsed_date.date() == today + # Calculate the time difference + time_difference = now - parsed_date + + # Check if the article was published within the last 24 hours + return time_difference.total_seconds() < 24 * 3600 except Exception as e: logger.warning(f"Error parsing date '{entry_date}': {e}") return False