Skip to content

refactor(worker): Inject repository service into ReportService and optimize commit query#788

Merged
thomasrockhu-codecov merged 4 commits intomainfrom
seer/refactor/inject-repo-service-optimize-query
Mar 30, 2026
Merged

refactor(worker): Inject repository service into ReportService and optimize commit query#788
thomasrockhu-codecov merged 4 commits intomainfrom
seer/refactor/inject-repo-service-optimize-query

Conversation

@sentry
Copy link
Copy Markdown
Contributor

@sentry sentry bot commented Mar 29, 2026

Fixes WORKER-VHG. The issue was that: Repeated GithubAppInstallation queries due to lazy-loaded relationships and uncached get_repo_provider_service calls.

  • Modified ReportService to accept an optional TorngitBaseAdapter instance as repository_service in its constructor.
  • Updated ReportService's get_existing_report_for_carryforward method to utilize the injected repository_service if provided, falling back to get_repo_provider_service otherwise.
  • Enhanced the preprocess_upload_task to eagerly load Repository, Owner, and GithubAppInstallation data when fetching a Commit object, reducing N+1 queries.
  • Passed the pre-fetched repository_service to the ReportService constructor within preprocess_upload_task.

This fix was generated by Seer in Sentry, triggered by Tom Hu. 👁️ Run ID: 12511267

Not quite right? Click here to continue debugging with Seer.

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.


Note

Medium Risk
Touches the report carryforward initialization path and how provider diffs are fetched, so regressions could affect carryforward line shifting. Also changes ORM loading behavior in the preprocess task, which is low-risk but could surface relationship/loading assumptions.

Overview
Reduces repeated git-provider and DB lookups during preprocess by injecting a pre-created TorngitBaseAdapter into ReportService and reusing it when shifting carryforward reports (falling back to get_repo_provider_service only if not provided).

Optimizes preprocess_upload by eager-loading Commit.repository -> Repository.author -> Owner.github_app_installations via joinedload, then passing the fetched repository_service into ReportService to avoid N+1/lazy-load queries during report initialization.

Written by Cursor Bugbot for commit 06d6205. This will update automatically on new commits. Configure here.

@sentry
Copy link
Copy Markdown
Contributor Author

sentry bot commented Mar 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.25%. Comparing base (13ff78c) to head (06d6205).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #788   +/-   ##
=======================================
  Coverage   92.25%   92.25%           
=======================================
  Files        1305     1305           
  Lines       47981    47985    +4     
  Branches     1636     1636           
=======================================
+ Hits        44263    44267    +4     
  Misses       3407     3407           
  Partials      311      311           
Flag Coverage Δ
workerintegration 58.57% <100.00%> (+0.01%) ⬆️
workerunit 90.38% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@codecov-notifications
Copy link
Copy Markdown

codecov-notifications bot commented Mar 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

Co-authored-by: Tom Hu <88201630+thomasrockhu-codecov@users.noreply.github.com>
@thomasrockhu-codecov thomasrockhu-codecov added this pull request to the merge queue Mar 30, 2026
Merged via the queue into main with commit 932aa91 Mar 30, 2026
40 checks passed
@thomasrockhu-codecov thomasrockhu-codecov deleted the seer/refactor/inject-repo-service-optimize-query branch March 30, 2026 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants