Average rating rounded#560
Conversation
|
""" WalkthroughThe change updates the Changes
Assessment against linked issues
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🔇 Additional comments (1)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
A1L13N
left a comment
There was a problem hiding this comment.
please run the pre-commit / lint
Head branch was pushed to by a user without write access
60d62bb to
63b638d
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
web/models.py(2 hunks)
🔇 Additional comments (1)
web/models.py (1)
9-9: Add import for database-level aggregation
TheAvgimport is correctly added to support the newaverage_ratingimplementation using Django’s ORM aggregation function.
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
web/models.py (1)
325-326: Efficient calculation with ORM aggregation and rounding.The updated
average_ratingproperty uses Django'saggregateto compute the average rating, defaults to0when there are no reviews, casts tofloat, and rounds to two decimal places, improving readability and performance.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
web/models.py(2 hunks)
🔇 Additional comments (1)
web/models.py (1)
9-9: ImportAvgfromdjango.db.models.This import is correctly placed and required for the new aggregation in
average_rating.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Head branch was pushed to by a user without write access
fix #554
Description
This PR fixes an issue where the course average rating was displayed with too many decimal places (e.g., 4.333333333333333). The average rating is now properly rounded to two decimal places.
Changes Made
Updated the average_rating property to round the result to 2 decimal points.
Before & After
Before: 4.333333333333333
After: 4.33
How to test
Open any course with reviews.
Confirm that the average rating is now shown with only two digits after the decimal.
Summary by CodeRabbit