-
Notifications
You must be signed in to change notification settings - Fork 110
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
1021 Refactor Pet instance method to use the Match model instead of the AdopterApplication model #1055
Conversation
I just added a second commit that is purely performance related. It probably isn't a priority at the moment, but I noticed while refactoring the You can see the number of Active Record queries goes down significantly. I can put this into a separate PR, or just stash these changes for now, if we don't want to look at performance yet. |
8f042e6
to
d37b498
Compare
d37b498
to
74a8331
Compare
@@ -8,10 +8,9 @@ class Organizations::AdoptablePetsController < Organizations::BaseController | |||
helper_method :get_animals | |||
|
|||
def index | |||
@q = authorized_scope(Pet.includes(:adopter_applications, images_attachments: :blob), | |||
with: Organizations::AdoptablePetPolicy).ransack(params[:q]) | |||
@q = authorized_scope(Pet.all, with: Organizations::AdoptablePetPolicy).ransack(params[:q]) |
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.
Do you think we should only return pets that are unadopted for this collection? We won't ever show adopted pets to adopter users here.
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.
Sure, I can do that. Okay if I add that to this PR?
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.
Added to this PR for now (see last commit).
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.
Yes in this PR is fine. Thanks.
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.
Nice one! Looks like you were N+1 hunting
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.
LGTM!
🔗 Issue
#1021
✍️ Description
Pet#is_adopted?
method to referenceMatch
association rather thanAdopterApplication