fix: guard rating calculation when ratingCount is zero (fixes #780)#784
fix: guard rating calculation when ratingCount is zero (fixes #780)#784dolliecoder wants to merge 1 commit intoAOSSIE-Org:masterfrom
Conversation
|
🎉 Welcome @dolliecoder!
We appreciate your contribution! 🚀 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe changes fix a division by zero bug in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
@M4dhav please review this pr |
Description
Fixes #780
Guards the user rating calculation in
explore_story_controller.dartto prevent invalid numeric results whenratingCountis zero or null.Previously, the rating was calculated as:
If ratingCount was 0 or null, this could produce NaN or Infinity, leading to incorrect values being displayed in the UI.
The calculation now safely returns 0.0 when ratingCount is not greater than zero.
Type of change
Bug fix (non-breaking change which fixes an issue)
How Has This Been Tested?
Manually tested with ratingCount = 0
Manually tested with ratingCount = null
Verified valid division when ratingCount > 0
Confirmed no NaN or Infinity values are produced
Checklist:
My code follows the style guidelines of this project
I have performed a self-review of my own code
I have made corresponding changes to the documentation
I have added tests that prove my fix is effective
My changes generate no new warnings
Summary by CodeRabbit