fix(live): index category lookups for catalog search (#49)
Avoid repeated category scans while filtering the paginated Live catalog, and keep the search timing and query-plan reproductions in the regression suite. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@ -77,6 +77,18 @@ async function requestAllPages(base, cookie, query = {}) {
|
||||
return items;
|
||||
}
|
||||
|
||||
test('application startup creates the composite category lookup index', async t => {
|
||||
const app = await startApp(t);
|
||||
const response = await request(app.base, app.cookie);
|
||||
assert.equal(response.status, 200);
|
||||
const db = new Database(path.join(app.dir, 'content.db'), { fileMustExist: true });
|
||||
t.after(() => db.close());
|
||||
const index = db.prepare(`SELECT sql FROM sqlite_master
|
||||
WHERE type='index' AND name='idx_categories_source_type_category'`).get();
|
||||
assert.ok(index, 'startup schema should create idx_categories_source_type_category');
|
||||
assert.match(index.sql, /\(source_id,\s*type,\s*category_id\)/i);
|
||||
});
|
||||
|
||||
function seedCatalog(dir, userId) {
|
||||
const db = new Database(path.join(dir, 'content.db'));
|
||||
const insertCategory = db.prepare(`
|
||||
|
||||
Reference in New Issue
Block a user