MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / likeScan

Function likeScan

__tests__/explore-long-query.test.ts:52–58  ·  view source on GitHub ↗

The lookup as it was before the index: a LIKE scan, ties left to the plan.

(db: SqliteDatabase, substring: string, kinds: string[], excludePrefix: boolean, limit: number)

Source from the content-addressed store, hash-verified

50
51/** The lookup as it was before the index: a LIKE scan, ties left to the plan. */
52function likeScan(db: SqliteDatabase, substring: string, kinds: string[], excludePrefix: boolean, limit: number): string[] {
53 let sql = 'SELECT nodes.*, 1.0 as score FROM nodes WHERE name LIKE ?';
54 const params: (string | number)[] = [`%${substring}%`];
55 if (excludePrefix) { sql += ' AND name NOT LIKE ?'; params.push(`${substring}%`); }
56 sql += ` AND kind IN (${kinds.map(() => '?').join(',')}) ORDER BY length(name) ASC LIMIT ?`;
57 return (db.prepare(sql).all(...params, ...kinds, limit) as Array<{ id: string }>).map((row) => row.id);
58}
59
60/** Many names of equal length across kinds and files, so ties decide the order. */
61function writeTieProject(dir: string): void {

Callers 2

expectSameRowsFunction · 0.85

Calls 5

pushMethod · 0.80
mapMethod · 0.80
allMethod · 0.65
prepareMethod · 0.65
joinMethod · 0.45

Tested by

no test coverage detected