refactor content fetching and embedding processes for improved concurrency and error handling

This commit is contained in:
ImBenji
2026-04-19 18:51:42 +01:00
parent b4b2fe2ac7
commit 6bf3a9282f
8 changed files with 348 additions and 157 deletions
+3 -3
View File
@@ -45,7 +45,7 @@ function buildArticlesQuery(query) {
return {
sql: `
SELECT id, title, description, content, image, ${includeEmbedding ? 'embedding,' : ''} url, normalized_title, source, pub_date, ingested_at
SELECT id, title, description, content, ${includeEmbedding ? 'embedding,' : ''} url, normalized_title, source, pub_date, ingested_at
FROM articles
${whereClause}
ORDER BY COALESCE(pub_date, ingested_at) DESC, id DESC
@@ -72,7 +72,7 @@ function mapNeighborsToArticles(neighbors, excludeIndexPages, limit) {
const placeholders = ids.map(() => '?').join(', ');
const articles = db.prepare(`
SELECT id, title, description, content, image, url, normalized_title, source, pub_date, ingested_at
SELECT id, title, description, content, url, normalized_title, source, pub_date, ingested_at
FROM articles
WHERE id IN (${placeholders})
AND content IS NOT NULL AND content != ''
@@ -144,7 +144,7 @@ async function articleRoutes(fastify) {
}
const article = db.prepare(`
SELECT id, title, description, content, image, url, normalized_title, source, pub_date, ingested_at
SELECT id, title, description, content, url, normalized_title, source, pub_date, ingested_at
FROM articles
WHERE id = ?
AND content IS NOT NULL AND content != ''