Conversation
…l rating statistics
…overall rating statistics
…, and overall rating statistics
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces new analytics functionality for the ratings system, including endpoints for retrieving rating distribution, recent ratings, and overall rating statistics. It also adds corresponding data transfer objects (DTOs) and implements the necessary logic in the service and repository layers.
New Analytics Endpoints:
rating_endpoints.py:/distribution: Returns the distribution of ratings across values 1-5 using theRatingDistributionDTO./recent: Retrieves the most recent ratings, including user and item information, using theRecentRatingDTO./stats: Provides overall rating statistics, such as the average rating, total count, and top category, using theRatingStatsDTO.Data Transfer Objects (DTOs):
rating_dto.py:RatingDistributionDTO: Represents the count of ratings for each value (1-5).RecentRatingDTO: Represents recent ratings with fields for rating value, item name, user name, and creation date.RatingStatsDTO: Encapsulates average rating, total count, and the top category (usingTopCategoryDTO).Service Layer Enhancements:
RatingService:get_rating_distribution: Fetches the distribution of ratings.get_recent_ratings: Retrieves the most recent ratings with user and item details.get_rating_stats: Computes overall rating statistics, including average rating and top category.Repository Layer Enhancements:
RatingRepository:get_rating_distribution: Queries the database for the count of ratings grouped by value (1-5) and ensures all values are represented.get_recent_ratings: Retrieves the most recent ratings with associated user and item information using SQLAlchemy joins.get_rating_stats: Calculates average rating, total count, and identifies the category with the most ratings.