(query: string, topN: number)
| 29 | export function createChatDbFtsSearcher(db: DatabaseAdapter): FtsSearcher { |
| 30 | return { |
| 31 | search(query: string, topN: number): Array<{ id: number; ts: number }> { |
| 32 | const keywords = extractFtsKeywords(query) |
| 33 | if (keywords.length === 0) return [] |
| 34 | const { rowids } = searchByFts(db, keywords, topN, 0) |
| 35 | if (rowids.length === 0) return [] |
| 36 | const placeholders = rowids.map(() => '?').join(', ') |
| 37 | const tsRows = db.prepare(`SELECT id, ts FROM message WHERE id IN (${placeholders})`).all(...rowids) as Array<{ |
| 38 | id: number |
| 39 | ts: number |
| 40 | }> |
| 41 | const tsById = new Map(tsRows.map((r) => [r.id, r.ts * 1000])) |
| 42 | return rowids.flatMap((id) => { |
| 43 | const ts = tsById.get(id) |
| 44 | return ts !== undefined ? [{ id, ts }] : [] |
| 45 | }) |
| 46 | }, |
| 47 | } |
| 48 | } |
nothing calls this directly
no test coverage detected