rubyforgood / pet-rescue

Pet Rescue is an application making it easy to link adopters/fosters with pets. We work with grassroots pet rescue organizations to understand how we can make the most impact.
MIT License
62 stars 107 forks source link

Filter pets by fostered on staff pet view #795

Open mononoken opened 4 months ago

mononoken commented 4 months ago

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:

Acceptance criteria

meg-gutshall commented 4 months ago

Ideas for Desired Filters

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

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 commented 3 months ago

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!

coalest commented 4 hours ago

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?

kasugaijin commented 34 minutes ago

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

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