Skip to content
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

Remove N+1 from admin users #4419

Merged
merged 2 commits into from
Jun 22, 2022

Conversation

tvdeyen
Copy link
Member

@tvdeyen tvdeyen commented Jun 14, 2022

Description

First fixing the preloading by using the correct relation name and then remove an explicit query by using a enumerable method to check if a user has orders in the admin users table.

Checklist:

Copy link
Contributor

@mamhoff mamhoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

Copy link
Member

@kennyadsl kennyadsl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 Thanks Thomas!

@waiting-for-dev
Copy link
Contributor

Hey @tvdeyen, could you rebase from master so that CI is green? 🙂

tvdeyen added 2 commits June 21, 2022 21:12
The has_many relation is called :orders, not :spree_orders
We preload users orders, but call count in the template.
This will always query the database. Using none? uses
the preloaded collection instead.
@tvdeyen tvdeyen force-pushed the remove-n1-from-admin-users branch from ef0d3fa to aa45abd Compare June 21, 2022 19:12
@tvdeyen
Copy link
Member Author

tvdeyen commented Jun 21, 2022

Hey @tvdeyen, could you rebase from master so that CI is green? 🙂

Done

@waiting-for-dev waiting-for-dev merged commit 08e3400 into solidusio:master Jun 22, 2022
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.

5 participants