pet-rescue
pet-rescue copied to clipboard
1021 Refactor Pet instance method to use the Match model instead of the AdopterApplication model
🔗 Issue
#1021
✍️ Description
- Refactored
Pet#is_adopted?method to referenceMatchassociation rather thanAdopterApplication - Fixed related tests
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 is_adopted? method, that there is an N+1 on the /staff/pets page because of that method and the in_foster?/open? methods are called in order to fetch the status of every pet.
Before changes:
After changes:
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.