THREESCALE-9973: Bullet n plus 1 offences#4305
Open
madnialihussain wants to merge 10 commits into
Open
Conversation
❌ 3 blocking issues (4 total)
|
jlledom
reviewed
May 22, 2026
Contributor
jlledom
left a comment
There was a problem hiding this comment.
All changes look good to me so far, but there are a lot of cukes failing because of the removed exceptions. Do you plan to fix them?
Contributor
|
This comment is not needed anymore: |
…ontract fixes and restore safelist entries
ba9d0b4 to
34085b1
Compare
Contributor
Author
Thanks for the review. Yes, they're fixed in the latest push |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it
This PR removes
7 n_plus_one_querysafelist entries fromconfig/environments/test.rbby fixing the underlying N+1 queries with proper eager loading.The changes include:
.includesAVOID eager loadingwarningsRelated issue: THREESCALE-9973
Changes by commit
1cf51db5fAdd conditional
:serviceinclude toApplicationsIndexPresenter(only when no service filter and multiservice) and add:service+user_account: [:admin_user]includes toBuyers::Applications::Bulk::BaseController.Removes:
Cinstance :service26e446521Add conditional
:user_accountinclude toApplicationsIndexPresenter(only when no buyer context). Add.with_accounttoService#latest_applicationsto fix N+1 on service show page.Removes:
Cinstance :user_accountb8f4015c3Extend
user_accountinclude touser_account: [:admin_user]inApplicationsIndexPresenter.The view accesses
account.admin_uservialink_to_buyer_or_deleted.Removes:
Account :admin_usere8cf2b66bAdd conditional
bought_account_planandbought_account_contract: [:plan]includes toBuyers::AccountsIndexPresenter(only whenaccount_plans_size > 1).Removes:
Account :bought_account_planAccount :bought_account_contract66f91e0d3Add
.includes(:user)to proxy configs collection query and decouple single-record finder to avoidAVOID eager loadingwarnings on show action.Removes:
ProxyConfig :user8a12d0f73Add
.includes(message: { sender: [:admin_user] })to inbox controller and.includes(:sender)to trash controller.MessageRecipient(sender accessed throughMessage)MessagedirectlyRemoves:
Message :sender1c76daf1aAdd
.includes({ buyer_account: [:admin_user] }, :provider_account)toFinance::Provider::InvoicesIndexPresenter,.includes(:buyer_account, :provider_account)toProvider::Admin::Account::InvoicesController, and.includes(:provider_account)to developer portalInvoicesController.Removes:
Invoice :buyer_accountInvoice :provider_account4042a5f20Use
ActiveRecord::Associations::Preloaderto conditionally preload:member_permissionsonly for member users inUsersIndexPresenter, avoidingAVOID eager loadingwarnings when all users are admins.Removes:
User :member_permissions7b6ec834eRevert
Account :admin_user,:bought_account_contract, and:bought_account_planfixes and restore their safelist entries.Bulk controllers (
Buyers::Accounts::Bulk) share a single collection method across new and create actions with different eager loading requirements. Adding includes to the shared collection causesunused_eager_loadingwarnings on the action that doesn't need them. Fixing this cleanly would require action specific preloading, which adds too much complexity for this PR so I reverted it to keep the PR clean.Restores:
Account :admin_userAccount :bought_account_contractAccount :bought_account_plan