Brett 2025-07-03 01:05:23 -04:00
parent bfae52f428
commit eb7ee3054d
3 changed files with 21 additions and 0 deletions

View File

@ -196,6 +196,13 @@ async def handle_article_url(message: discord.Message, url: str) -> None:
try:
title, processed_html = await article_repository.get_article(url)
if await article_repository.has_paragraphs(url):
await message.channel.send("This article has already been processed.")
LOGGER.info(f"Article {url} already processed")
return
LOGGER.info(f"Article {url} has not been processed. Beginning now!")
summary_bot = ChatBot(summary_system_prompt)
summary_parts = await summary_bot.multi_summary(processed_html, options={

View File

@ -176,6 +176,20 @@ class ArticleRepository:
return title, processed_html
async def has_paragraphs(self, url) -> bool:
async with self._lock:
row = self._row_for_url(url)
if not row:
return False
cur = self._conn.cursor()
row = cur.execute(f"SELECT COUNT(*) FROM summaries WHERE article_id = {row[0]}")
result = row.fetchone()
if not row.fetchone() or row.fetchone()[0] == 0:
return False
return True
async def set_paragraphs(self, url, paragraphs, summary, summary_ratings, topics, topic_ratings):
async with self._lock:
article_id = self._row_for_url(url)[0]