pet-rescue icon indicating copy to clipboard operation
pet-rescue copied to clipboard

1021 Refactor Pet instance method to use the Match model instead of the AdopterApplication model

Open coalest opened this issue 1 year ago • 1 comments

🔗 Issue

#1021

✍️ Description

  • Refactored Pet#is_adopted? method to reference Match association rather than AdopterApplication
  • Fixed related tests

coalest avatar Oct 10 '24 13:10 coalest

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: Screenshot from 2024-10-10 16-29-50

After changes: Screenshot from 2024-10-10 16-30-58

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.

coalest avatar Oct 10 '24 14:10 coalest