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

feat: enhanced the get product endpoint with category filter #1222

Open
wants to merge 10 commits into
base: dev
Choose a base branch
from

Conversation

PeterOyelegbin
Copy link

@PeterOyelegbin PeterOyelegbin commented Mar 2, 2025

Summary

Update the GET /api/v1/products endpoint to include a filter by category parameter. This will allow users to retrieve products based on their category of interest.

Description

  • Update the GET /api/v1/products endpoint to accept and process the category query parameter.
  • Users should be able to filter products by category while ensuring proper authorization checks.
  • The endpoint should continue functioning as expected for clients not using the category filter.

Related Issue (Link to issue ticket)

Feature Enhancement: To enable users to query products relevant to their category of interest while maintaining the existing functionality for unfiltered requests.

Issue Link

Motivation and Context

To enable users to query products relevant to their category of interest while maintaining the existing functionality for unfiltered requests.

How Has This Been Tested?

  • I used Postman to test the changes made
  • Also wrote a unit test to ensure no broken code during enhancement
  • Ran existing test to ensure no broken code after enhancement

Screenshots (if appropriate - Postman, etc):

  1. Unit test
    test cases

  2. Postman

    • When category is none:
      category_is_null

    • When the category is not none:
      category_is_not_null

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@phurhard
Copy link

phurhard commented Mar 2, 2025

Pull from upstream and re-push

@@ -61,7 +63,8 @@ def paginated_response(
```
'''

query = db.query(model)
if query is None:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when you set this condition what happens is query is not None?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohkay, your test fails

@@ -61,7 +63,8 @@ def paginated_response(
```
'''

query = db.query(model)
if query is None:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If query is none, then it gets all products;
if query is not none, it gets the product related to that category.

Copy link

@phurhard phurhard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update your PR

@PeterOyelegbin PeterOyelegbin requested a review from phurhard March 2, 2025 12:27
@phurhard
Copy link

phurhard commented Mar 2, 2025

When you push your PR, monitor it to ensure the checks pass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants