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]: Fetch Top-Rated Testimonials #1142

Open
mikemando opened this issue Feb 28, 2025 · 0 comments · May be fixed by #1171
Open

[FEAT]: Fetch Top-Rated Testimonials #1142

mikemando opened this issue Feb 28, 2025 · 0 comments · May be fixed by #1171

Comments

@mikemando
Copy link

Description:

This feature would allow users to fetch testimonials with the highest ratings and this would increase the visibility for top-rated feedback.

Endpoint Details:

  • Method: GET
  • Endpoint: /api/v1/testimonials/top-rated
  • Description: Fetches a list of top-rated testimonials, sorted by rating in descending order.

Request Example:

GET "/api/v1/testimonials/top-rated"

Response Example:

Success Response:

{
  "status": "success",
  "status_code": 200,
  "message": "Top-rated testimonials retrieved successfully.",
  "data": [
    {
      "id": "1",
      "content": "Great service!",
      "ratings": 5,
      "author_id": "123",
      "created_at": "2024-02-28T10:00:00Z"
    },
    {
      "id": "2",
      "content": "Amazing experience!",
      "ratings": 5,
      "author_id": "456",
      "created_at": "2024-02-27T15:30:00Z"
    }
  ]
}

No Testimonials Found:

{
  "status": "success",
  "status_code": 200,
  "message": "No testimonials found.",
  "data": []
}

Server Error:

{
  "status": "error",
   "status_code": 500,
  "message": "An unexpected error occurred.",
  "data": null
}

Tasks:

  • Add a fetch_top_rated method in TestimonialService that:
    • Queries testimonials ordered by rating (descending order).
    • Supports pagination (page, per_page).
  • Handle edge cases such as an empty testimonial list.

Testing:

Write unit tests for:

  1. Fetching top-rated testimonials with valid data.
  2. Handling cases where no testimonials exist.
  3. Validating pagination parameters.
@mikemando mikemando linked a pull request Mar 1, 2025 that will close this issue
9 tasks
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 a pull request may close this issue.

1 participant