add Google News integration and enhance crawler capabilities

This commit is contained in:
ImBenji
2026-04-18 13:59:46 +01:00
parent 14727cdfe3
commit 830766bcfe
5 changed files with 77 additions and 24 deletions
+14 -3
View File
@@ -171,7 +171,7 @@ async function fetchAndStoreContent(id, url) {
}
}
async function backfillMissingContent(limit = 10) {
async function backfillMissingContent(limit = 100, concurrency = 5) {
if (contentBackfillRunning) {
return;
}
@@ -183,15 +183,26 @@ async function backfillMissingContent(limit = 10) {
? selectAllArticlesMissingContent.all()
: selectArticlesMissingContent.all(limit);
for (const row of rows) {
await fetchAndStoreContent(row.id, row.url);
for (let i = 0; i < rows.length; i += concurrency) {
const batch = rows.slice(i, i + concurrency);
await Promise.all(batch.map((row) => fetchAndStoreContent(row.id, row.url)));
}
} finally {
contentBackfillRunning = false;
}
}
function hasPendingContent() {
return Boolean(db.prepare(`
SELECT 1 FROM articles
WHERE (content IS NULL OR TRIM(content) = '')
AND (content_status IS NULL OR content_status = 'pending')
LIMIT 1
`).get());
}
module.exports = {
fetchAndStoreContent,
backfillMissingContent,
hasPendingContent,
};