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

Add dynamic filtering, sorting to GET /api/outfits #94

Open
3 tasks
rak3rman opened this issue Feb 26, 2024 · 0 comments
Open
3 tasks

Add dynamic filtering, sorting to GET /api/outfits #94

rak3rman opened this issue Feb 26, 2024 · 0 comments
Labels
backend Related to the hono backend

Comments

@rak3rman
Copy link
Member

rak3rman commented Feb 26, 2024

Description

Enable an API user to be able to filter and sort (asc and desc) each data field passed by GET /api/outfits. This is going to be a tricky one to do right. If no sorting or filtering attributes are passed, then all results are returned (subject to pagination if implemented). Both the filtering and sorting should be abstracted away from the API implementation in services/outfits.ts as seperate functions (schema.ts or utils/ could be a good home for these functions). You'll likely have to do some sort of "query building" to whittle down to the result that the user wants. For filtering, only consider "AND" or inner joins for now. Filtering like this is common practice in the industry, search the web for best practices.

For example, consider the case where I'd like to filter by rating. The user should be able to pass in a parameter where rating = 2 and all returned values should contain an outfit with a rating of 2. For sorting, say I'd like to sort by rating as well in asc order. Then the returned values should be sorted by such.

Acceptance Criteria

Generated by Zenhub AI

  • Scenario: Filtering by rating
  • Given the user wants to filter by rating
  • When the user sends a GET request to /api/outfits with a parameter "rating=2"
  • Then the API should return all outfits with a rating of 2
  • Scenario: Sorting by rating in ascending order
    • Given the user wants to sort by rating in ascending order
    • When the user sends a GET request to /api/outfits with a parameter "sort=rating,asc"
    • Then the API should return the outfits sorted by rating in ascending order
  • Scenario: Filtering and sorting by rating
    • Given the user wants to filter by rating and sort by rating in ascending order
    • When the user sends a GET request to /api/outfits with parameters "rating=2" and "sort=rating,asc"
    • Then the API should return all outfits with a rating of 2 sorted in ascending order
@rak3rman rak3rman changed the title Add dynamic filtering to GET /api/outfits Add dynamic filtering, sorting to GET /api/outfits Feb 26, 2024
@rak3rman rak3rman added feat New actionable feature that impacts user experience backend Related to the hono backend labels Feb 26, 2024
@rak3rman rak3rman added this to the Minimum Viable Product milestone Mar 4, 2024
@rak3rman rak3rman removed the feat New actionable feature that impacts user experience label Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Related to the hono backend
Projects
None yet
Development

No branches or pull requests

1 participant