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

Filter pets by fostered on staff pet view

Open mononoken opened this issue 1 year ago • 2 comments

Description

On the staff pets view, /staff/pets, we cannot filter pets by if they are fosterable or fostered. Currently, they only show "adopted" and "unadopted".

These filters work with ransack, and they may benefit from being reworked from their current state.

I haven't fully thought through this. If you have suggestions, let's think about how this works and make a clearer idea of what these options should be and what their names on the UI should be.

The cases desired to show:

  • Pets who can be adopted but are not
  • Pets that are adopted
  • Pets who can be fostered but are not
  • Pets that are fostered

Acceptance criteria

  • [ ] Filter pets by all of the cases described

mononoken avatar Jun 01 '24 18:06 mononoken

Ideas for Desired Filters

  • Pets who can be adopted but are not --> Adoptable
  • Pets that are adopted --> Adoptions
  • Pets who can be fostered but are not --> Fosterable
  • Pets that are currently or are schedule to be fostered --> Fosters

I would like to implement more granular filters like the following:

  • Pets that are fostered --> Current Fosters
  • Pets that were previously fostered --> Completed Fosters
  • Pets that are scheduled to be fostered --> Pending Fosters

It feels like this would require a change in design for the Match model, or at the very least implementing a state machine. Personally, I think the Match model would be better off as a parent class to Adoption and Foster models. It can contain shared behavior and logic while the child classes handle more specific functionality.

This is mainly driven by the foster_statuses method on the Match model. There are more options that should be added to this list of statuses. There are also statuses that should be considered for adoptable pets too, which we can convert into filters.

meg-gutshall avatar Jun 01 '24 20:06 meg-gutshall

Thanks @kasugaijin for removing the assigned label. I got way too busy when I came home to finish this up.

For anyone who wants to pick this up, the WIP code is in branch 795-add-pet-filters. The custom Ransackers aren't working at the moment (the case statement methods). I think it may be because the case statement is checking for an integer when the params would be passing a string to the method.

That would be a good place to pick back up on this issue. Ping me with any questions!

meg-gutshall avatar Jun 12 '24 13:06 meg-gutshall

I could take this issue on :raising_hand:

Out of all the filters mentioned by @meg-gutshall, the only one that looks like it would be more effort to implement is the "Completed Fosters" filter (if this would return all pets that were fostered in their past, regardless of their current status). This seems like it would require an additional table for recording adoption/fostering history.

Should we create this kind of pet adoption status history table, or for now just provide all the filters that don't require information on a pet's previous state?

coalest avatar Oct 05 '24 17:10 coalest

Hey @coalest I have some thoughts here - let me know what you think https://www.loom.com/share/9a2d70c4825b4754874d968a230b0932?sid=d6636dba-8f06-4342-a5de-f5fa70260c9b

Proposed filters for /staff/pets

  • Placement type
    • Adoptable
    • Fosterable
    • Adoptable & Fosterable
  • Adoption Status (rename from 'Status')
    • Adopted
    • Not adopted
  • Paused
    • Yes
    • No
  • Published
    • Yes
    • No

Foster Related Filters (not required - we already have filters doing this on on /staff/manage_fosters

Also - would be great to move Ransack logic on the Pet model into a concern - see how we do this for DefaultPetTask

kasugaijin avatar Oct 05 '24 20:10 kasugaijin

@kasugaijin Thanks for the loom, that really clears up what acceptance criteria for this task would be. Also agree with your suggestion to move this logic into a concern to keep the Pet model smaller.

I'll get started on this tomorrow.

coalest avatar Oct 07 '24 09:10 coalest