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

Feature retrieves total likes dislikes by author #1228

Draft
wants to merge 7 commits into
base: dev
Choose a base branch
from

Conversation

baydre
Copy link

@baydre baydre commented Mar 2, 2025

Description

This PR implements a GET endpoint to retrieve the total number of likes and dislikes for all blog posts written by a specific author. The feature allows users to gain an overview of the total reactions (likes & dislikes) received by an author across all their posts.

Endpoint Details

  • Method: GET
  • URL: /api/v1/authors/{author_id}/likes-dislikes
  • Functionality: Fetches the total count of likes and dislikes for all posts by a given author.

Request Example

GET /api/v1/authors/789/likes-dislikes

Success Response Example

{
  "status": "success",
  "message": "Likes and dislikes for the author retrieved successfully",
  "data": {
    "author_id": "789",
    "total_likes": 350,
    "total_dislikes": 25
  }
}

Error Handling Examples
Author Not Found

{
  "status": "error",
  "message": "Author not found",
  "data": null
}

Invalid Author ID

{
  "status": "error",
  "message": "Invalid author ID format",
  "data": null
}

Related Issue (Link to issue ticket)

Closes #1128

Motivation and Context

  • ​Provides an overview of user engagement with an author’s content.
  • Helps in tracking the author’s content performance across all blog posts.
  • Ensures proper error handling when retrieving author-related statistics.

How Has This Been Tested?

​✅ Unit Testing:

  • Implemented unit tests using pytest to validate the correctness of the endpoint.

✅ Manual Testing (Postman):

  • Sent test requests to verify correct responses for valid, missing, and invalid author IDs.

✅ Database Validation:

  • Queried the database to ensure that likes & dislikes are correctly aggregated per author.

✅ Test Environment:

  • OS: Ubuntu 20.04
  • Python Version: 3.10
  • Database: PostgreSQL

Screenshots (if appropriate - Postman, etc):


Screenshot from 2025-03-01 15-05-48
Screenshot from 2025-03-01 15-01-41

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.

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.

[FEAT] Retrieves the Total Likes and Dislikes for All Posts by an Author
1 participant