Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit cdbd476

Browse files
committed
Use the CommitLoader for bundleAnalysisCompareWithParent
This is loading the `parent_commit` using the async batch-loading `CommitLoader`. This way, we can avoid one of the N+1 queries being executed when executing the `GetCommits` GraphQL query. However, we are still loading all the BA `CommitReport`s separately within `load_bundle_analysis_comparison`, which is another 2N+1 problem on its own. Will solve that one another time :-)
1 parent ab4cb5b commit cdbd476

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

graphql_api/types/commit/commit.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -393,16 +393,19 @@ def resolve_coverage_components(commit: Commit, info, filters=None) -> List[Comp
393393

394394

395395
@commit_bundle_analysis_bindable.field("bundleAnalysisCompareWithParent")
396-
@sync_to_async
397396
@sentry_sdk.trace
398-
def resolve_commit_bundle_analysis_compare_with_parent(
397+
async def resolve_commit_bundle_analysis_compare_with_parent(
399398
commit: Commit, info: GraphQLResolveInfo
400399
) -> Union[BundleAnalysisComparison, Any]:
401-
base_commit = Commit.objects.filter(commitid=commit.parent_commit_id).first()
402-
if not base_commit:
400+
if not commit.parent_commit_id:
403401
return MissingBaseCommit()
402+
base_commit = await CommitLoader.loader(info, commit.repository_id).load(
403+
commit.parent_commit_id
404+
)
404405

405-
bundle_analysis_comparison = load_bundle_analysis_comparison(base_commit, commit)
406+
bundle_analysis_comparison = await sync_to_async(load_bundle_analysis_comparison)(
407+
base_commit, commit
408+
)
406409

407410
# Store the created SQLite DB path in info.context
408411
# when the request is fully handled, have the file deleted

0 commit comments

Comments
 (0)