Skip to content

Commit 66df52a

Browse files
kckernclaude
andcommitted
perf(web): skip the reference lookup for notes
Staging perf flagged notes.scripture.guide/31103-0008 at 960 ms (live 144 ms). The notes presenter reads the path as a word id and ignores the lookup, but the controller still looked it up as a reference: verse ids 31103-0008, a range of 31,000 verses fetched and discarded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 0dad274 commit 66df52a

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

‎apps/web/src/app/controllers/ScriptureController.js‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ export class ScriptureController {
6464

6565
if (isEmptyReference(reference) && !config.parallel && !answersEmpty(config)) return this.home(req, res);
6666

67+
// notes: the path is a word id (31103-0008) that NotesPresenter reads itself; looked up as
68+
// a reference it can be a range of tens of thousands of verses
69+
if (config.outputFormat === 'notes') {
70+
req.scriptureResult = new ScriptureResult({ reference: new Reference({ query: reference, normalized: '', verseIds: [] }), verses: [], config });
71+
return next();
72+
}
73+
6774
const result = await this.lookupService.lookup(isEmptyReference(reference) ? '' : reference, config);
6875
result.bookOnly = await this.bookOnly(result, config);
6976
result.legacyBlocks = await this.legacyBlocks(result, config);

‎apps/web/test/unit/scriptureController.test.js‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,16 @@ describe('ScriptureController: the title of a reference of several blocks', () =
124124
expect((await run(several(), 'api')).title).toBeUndefined();
125125
});
126126
});
127+
128+
describe('ScriptureController: notes', () => {
129+
test('a notes path is a word id: no reference lookup or PHP blocks', async () => {
130+
// notes.scripture.guide/31103-0008 read as a reference is a 31,000-verse range
131+
const lookup = vi.fn(async () => empty());
132+
const blocks = vi.fn(async () => []);
133+
const ctl = new ScriptureController({ lookup }, references, { blocks });
134+
const result = await show('31103-0008', 'notes', '31103-0008', ctl);
135+
expect(lookup).not.toHaveBeenCalled();
136+
expect(blocks).not.toHaveBeenCalled();
137+
expect(result).toBeDefined();
138+
});
139+
});

0 commit comments

Comments
 (0)