File size: 1,063 Bytes
2c10495
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const Database = require('better-sqlite3');
const path = require('path');

const db = new Database(path.join(process.cwd(), 'rag-kb.db'));


try {
  const docs = db.prepare('SELECT id, title, length(content_preview) as len, content_preview FROM documents WHERE content_preview IS NOT NULL AND content_preview != \'\' LIMIT 5').all();
  console.log("Documents with content:", docs.map(d => ({ id: d.id, title: d.title, length: d.len, preview: d.content_preview.substring(0, 50) })));

  const emptyDocs = db.prepare('SELECT id, title FROM documents WHERE content_preview IS NULL OR content_preview = \'\' LIMIT 5').all();
  console.log("Documents without content:", emptyDocs);

  const totalDocs = db.prepare('SELECT count(*) as count FROM documents').get();
  console.log("Total documents:", totalDocs);
  
  const totalEmpty = db.prepare('SELECT count(*) as count FROM documents WHERE content_preview IS NULL OR content_preview = \'\'').get();
  console.log("Total empty documents:", totalEmpty);

} catch (error) {
  console.error("Database error:", error);
}