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: Implement Product Review and Star Rating Feature" #1319

Merged
merged 11 commits into from
Mar 1, 2025

Conversation

Jhaemis-hack
Copy link
Contributor

Pull Request

Description

The ProductsController and ProductsService have been enhanced to support Product Reviews, Star Ratings, and Comments. Previously, the system lacked direct mechanisms for users to leave feedback on products, limiting transparency and engagement.

Key Additions:

Authenticated users can submit or update product reviews with:

  • Star rating (1-5)
  • Review text

Authenticated users can delete their own product reviews.

Each product now exposes the following in its response:

  • Average rating
  • Total number of reviews
  • Recent reviews (including reviewer name, rating, and comment)

Why this matters:

This enhancement improves user engagement, increases transparency, and provides organizations with actionable feedback to enhance their product offerings.


Related Issue

Fixes #


Type of Change

  • feat: New feature
  • fix: Bug fix
  • docs: Documentation updates
  • style: Code style/formatting changes
  • refactor: Code refactoring
  • perf: Performance improvements
  • test: Test additions/updates
  • chore: Build process or tooling changes
  • ci: CI configuration changes
  • other:

How Has This Been Tested?

  • Unit tests for ProductsService and ProductsController
  • Integration tests for the end-to-end review lifecycle (Create, Update, Delete, Fetch)
  • Manual tests using Postman to confirm API behavior and response structure

Test Evidence

{
    "status_code": 200,
    "id": "b9fa09d5-1d0e-4dba-9642-746b6fd66380",
    "name": "brush",
    "description": "10",
    "averageRating": 3,
    "totalReviews": 1,
    "recentReviews": [
        {
            "rating": 3,
            "review": "this is the best so far",
            "createdBy": "156f914d-cd7e-4a6a-924e-cb6a484f832e",
            "createdAt": "2025-02-28T23:57:32.913Z"
        }
    ]
}

Screenshots

Get a product review before creating a review

alt text

Create a review and star rating

alt text

Get product review after a creating a review

alt text

Delete a product review

alt text


Checklist

  • My code follows the project's coding style
  • I have commented my code, especially in complex areas
  • I have made relevant updates to the documentation (Swagger)
  • My changes do not introduce new warnings
  • I have added tests to validate the feature works as intended
  • All new and existing tests pass locally
  • Any dependent changes are already merged
  • I have attached screenshots for tests and documentation (where applicable)

Additional Notes

This implementation ensures the ProductResponseDto now includes the correct recentReviews, averageRating, and totalReviews fields, keeping them consistent across all relevant product responses. The review feature is self-contained within the products module for maintainability.


Suggested Commit Message

feat(products): add product reviews, star ratings, and comments feature

## Suggested Branch Name

feature/product-reviews


@incredible-phoenix246 incredible-phoenix246 merged commit 878c9c5 into hngprojects:dev Mar 1, 2025
1 check passed
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