-
Notifications
You must be signed in to change notification settings - Fork 377
fix(web): deduplicate repository lookups in search results #1684
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -341,9 +341,8 @@ const encodeSSEREsponseChunk = (response: object | string) => { | |
| // chunk. The mapping allows us to efficiently lookup repository metadata. | ||
| const createReposMapForChunk = async (chunk: ZoektGrpcSearchResponse, reposMapCache: Map<string | number, Repo>, prisma: PrismaClient): Promise<Map<string | number, Repo>> => { | ||
| const reposMap = new Map<string | number, Repo>(); | ||
| await Promise.all(chunk.files.map(async (file) => { | ||
| const id = getRepoIdForFile(file); | ||
|
|
||
| const repoIds = [...new Set(chunk.files.map(getRepoIdForFile))]; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: Within a chunk the dedup is correct, but repositories that are not in the database never get cached ( Prompt for AI agents |
||
| await Promise.all(repoIds.map(async (id) => { | ||
| const repo = await (async () => { | ||
| // If it's in the cache, return the cached value. | ||
| if (reposMapCache.has(id)) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: The streaming test verifies only file and repositoryInfo counts, never that each
response.files[i].repositoryIdcorresponds to the emittedrepository_id. The unary tests assert this mapping; the streaming chunk test should too, so a cache mis-association or reordering that keeps counts unchanged cannot slip through — it also directly covers the PR's "result order preserved" claim for the cross-chunk cache path.Prompt for AI agents