feat: caché de contenido de fuentes — reutiliza URLs scrapeadas en últimos 7 días
Build & Deploy ResearchOwl / build-and-push (push) Successful in 6s
Build & Deploy ResearchOwl / build-and-push (push) Successful in 6s
This commit is contained in:
@@ -318,6 +318,19 @@ class ResearchDB:
|
||||
row = await cursor.fetchone()
|
||||
return row[0] if row else None
|
||||
|
||||
async def get_cached_content(self, url: str,
|
||||
max_age_days: int = 7) -> Optional[str]:
|
||||
threshold = time.time() - (max_age_days * 86400)
|
||||
async with self.db.execute(
|
||||
"""SELECT sc.content FROM source_contents sc
|
||||
JOIN sources s ON s.id = sc.source_id
|
||||
WHERE s.url = ? AND sc.created_at > ?
|
||||
ORDER BY sc.created_at DESC LIMIT 1""",
|
||||
(url, threshold)
|
||||
) as cur:
|
||||
row = await cur.fetchone()
|
||||
return row[0] if row else None
|
||||
|
||||
async def get_outputs(self, session_id: int) -> list[dict]:
|
||||
cursor = await self.db.execute(
|
||||
"SELECT * FROM outputs WHERE session_id = ? ORDER BY created_at DESC",
|
||||
|
||||
Reference in New Issue
Block a user