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

Commit 323ee99

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 f717a2b commit 323ee99

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
@@ -391,16 +391,19 @@ def resolve_coverage_components(commit: Commit, info, filters=None) -> List[Comp
391391

392392

393393
@commit_bundle_analysis_bindable.field("bundleAnalysisCompareWithParent")
394-
@sync_to_async
395394
@sentry_sdk.trace
396-
def resolve_commit_bundle_analysis_compare_with_parent(
395+
async def resolve_commit_bundle_analysis_compare_with_parent(
397396
commit: Commit, info: GraphQLResolveInfo
398397
) -> Union[BundleAnalysisComparison, Any]:
399-
base_commit = Commit.objects.filter(commitid=commit.parent_commit_id).first()
400-
if not base_commit:
398+
if not commit.parent_commit_id:
401399
return MissingBaseCommit()
400+
base_commit = await CommitLoader.loader(info, commit.repository_id).load(
401+
commit.parent_commit_id
402+
)
402403

403-
bundle_analysis_comparison = load_bundle_analysis_comparison(base_commit, commit)
404+
bundle_analysis_comparison = await sync_to_async(load_bundle_analysis_comparison)(
405+
base_commit, commit
406+
)
404407

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

0 commit comments

Comments
 (0)