-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
improve performance for n+1s #817
Conversation
|
||
dashboard.class::ATTRIBUTE_TYPES.map do |key, value| | ||
key if association_classes.include?(value) || | ||
association_classes.include?(value.try :deferred_class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use 4 (not 7) spaces for indenting a condition in an if statement spanning multiple lines.
Add parentheses to nested method call value.try :deferred_class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels a little messy. Maybe we can split the checking here into one line, the try
to another?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think was thinking of doing that. I'm going to take another stab at this.
@@ -5,6 +5,7 @@ class ApplicationController < ActionController::Base | |||
def index | |||
search_term = params[:search].to_s.strip | |||
resources = Administrate::Search.new(resource_resolver, search_term).run | |||
resources = resources.includes(*resource_includes) if resource_includes.any? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [82/80]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm this really looks like it needs to be moved to the Administrate::Page::Collection
model.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's try that and see how it goes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I thought about moving it to the collection class, but that didn't work out the way I thought it would. Instead, it's been moved to the dashboard and we pass the includes from there.
I would love to see this make it in. |
e8bb8ab
to
53f8bca
Compare
This guy solves some n+1 problems in the application. The solution is global.
I need to take time though to scope the n+1s down to just what attribute constants we're actually using.Tried using
COLLECTION_ATTRIBUTES
but that didn't work out very well. Didn't remove a single n+1. As per n+1 issues, I think sticking toATTRIBUTE_TYPES
is a good first step. I think we should integrate this withAdministate::Page::Collection
.