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

buyer be able to view available product #75

Merged

Conversation

niyibi250
Copy link
Collaborator

@niyibi250 niyibi250 commented May 20, 2024

What does this PR do?

This pull request implements the AvailableProducts function, which retrieves available products from the database with pagination support. The function allows clients to request available products with optional pagination parameters (limit and page). If pagination parameters are not provided, default values are used (limit=10, page=1).

Description

  • Implementing the /getAvailableProducts route

This function should execute a database query to fetch available products where the isAvailablefield is set to true.
Pagination should be applied to limit the number of products returned per page and to skip the appropriate number of records based on the page number.
The function should include the category relation to eagerly load associated categories for each product.
Handling pagination:

If pagination parameters (limit and page) are not provided in the query, default values should be used (limit=10, page=1).

  • Constructing a JSON response

Once the products are fetched, the function should construct a JSON response containing the retrieved products, total pages, and the current page.

Total pages should be calculated based on the total count of available products and the specified limit.

  • Implementing error handling

The function should include appropriate error handling to handle any errors that may occur during the execution of the function (e.g., database query error, server error).
If an error occurs, the function should return a 500-status code along with an error message.

  • Testing

Test the getAvailableProducts route to ensure it retrieves available products correctly with the expected pagination behavior.
Verify that error handling is working as expected and that appropriate responses are returned in case of errors.

Testing: I have tested the getAvailableProducts route locally and verified that it retrieves available products correctly with the expected pagination behavior.

Related Issues:

#37

Screenshot:

Swagger:

image

Testing:

test shot

- establish route
- establish controller
-establish test

Feat: Buyer should be able to list products from vendors #57
@niyibi250 niyibi250 added bug Something isn't working backend Good for newcomers labels May 20, 2024
@niyibi250 niyibi250 added this to the Product Management milestone May 20, 2024
@niyibi250 niyibi250 linked an issue May 20, 2024 that may be closed by this pull request
3 tasks
@niyibi250 niyibi250 self-assigned this May 20, 2024
Feat: Buyer should be able to list products from vendors #57
Feat: Buyer should be able to list products from vendors #57
@niyibi250 niyibi250 removed the bug Something isn't working label May 20, 2024
Copy link
Contributor

@wayneleon1 wayneleon1 left a comment

Choose a reason for hiding this comment

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

looks good

Copy link
Contributor

@bertrandshema bertrandshema left a comment

Choose a reason for hiding this comment

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

It is good.

Copy link
Contributor

@ambroisegithub ambroisegithub left a comment

Choose a reason for hiding this comment

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

It Looks good For Me!!!!

@dushimeemma dushimeemma merged commit 5056205 into develop May 21, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Good for newcomers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feat: Buyer should be able to list products from vendors
5 participants