Fix bug in article date determination

This commit is contained in:
Alex Selimov 2025-08-15 21:43:18 -04:00
parent 193a50dd3b
commit 91e6859e69
2 changed files with 10 additions and 6 deletions

View file

@ -31,13 +31,13 @@ def generate_summary(
client_config: Dict[str, str], client_config: Dict[str, str],
content: str, content: str,
model: str = "llama3.2", model: str = "llama3.2",
max_length: int = 150, max_length: int = 75,
) -> Optional[str]: ) -> Optional[str]:
"""Generate a summary of the given content using Ollama.""" """Generate a summary of the given content using Ollama."""
if not content.strip(): if not content.strip():
return "No content available for summarization." 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} {content}

View file

@ -25,7 +25,7 @@ def fetch_rss_feed(url: str) -> feedparser.FeedParserDict:
def is_today(entry_date: Optional[str]) -> bool: 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: if not entry_date:
return False return False
@ -37,10 +37,14 @@ def is_today(entry_date: Optional[str]) -> bool:
if parsed_date.tzinfo is None: if parsed_date.tzinfo is None:
parsed_date = parsed_date.replace(tzinfo=timezone.utc) parsed_date = parsed_date.replace(tzinfo=timezone.utc)
# Get today's date in UTC # Get the current time in UTC
today = datetime.now(timezone.utc).date() 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: except Exception as e:
logger.warning(f"Error parsing date '{entry_date}': {e}") logger.warning(f"Error parsing date '{entry_date}': {e}")
return False return False