Skip to content
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

resources filter by category #488

Open
jacobvenable opened this issue Aug 31, 2021 · 1 comment
Open

resources filter by category #488

jacobvenable opened this issue Aug 31, 2021 · 1 comment
Labels
Project: Server Related to the server workspace Project: Web Related to the web workspace sorting and filtering ✅ Status: Dev Ready This is waiting to be started

Comments

@jacobvenable
Copy link
Member

Problem

We currently use the category endpoint to serve resources by category (example category page). The issue with this endpoint is that it returns resources as groups of sub-categories, e.g.:

{
  "subcategories": [
      {
         "name": "Meals",
         "resources": [
             {
                "name": "Resource A",
             },
             {
                "name": "Resource B",
             }
         ],
      },
      {
         "name": "Food Pantries",
         "resources": [
             {
                "name": "Resource A",
             },
             {
                "name": "Resource C",
             }
         ],
      }
   ]
}

It's possible to have a resource listed under multiple sub-categories, as shown in the example above where "Resource A" provides both a meal and a food pantry.

This requires the client to filter out repeats of resources.

Solution

Ideally we'd like to have our current resources endpoint support filtering by category. That way, we can use one endpoint for fetching resources.

API Updates

  • add an optional categories query param to the resources endpoint that accepts a string equaling a comma-separated list of categories we wish to filter resources by, e.g. /resources?categories=food,shelter
  • update the useResourcesByCategory hook to consume resources using that updated endpoint

Tech Notes

  • The current /resources endpoint currently supports filtering resources by a list of comma-separated IDs. We'll need to make sure we also honor the current filtering by id that exists on this endpoint. This means that if we provide both ids and categories as filters, we only return resources that match the passed ids AND belong to one or more of the passed categories.
@jacobvenable jacobvenable added Project: Server Related to the server workspace Project: Web Related to the web workspace sorting and filtering ✅ Status: Dev Ready This is waiting to be started labels Aug 31, 2021
@jacobvenable
Copy link
Member Author

Being taken on @Sunset05

@dannyirwin dannyirwin mentioned this issue Oct 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Project: Server Related to the server workspace Project: Web Related to the web workspace sorting and filtering ✅ Status: Dev Ready This is waiting to be started
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant