Skip to content

[244] Add Weighted Rating Calculation#304

Merged
Naomi-Gift merged 3 commits into
HubDApp:mainfrom
Goodnessukaigwe:fix/244-add-weighted-rating-calculation
Jul 2, 2026
Merged

[244] Add Weighted Rating Calculation#304
Naomi-Gift merged 3 commits into
HubDApp:mainfrom
Goodnessukaigwe:fix/244-add-weighted-rating-calculation

Conversation

@Goodnessukaigwe

Copy link
Copy Markdown
Contributor

Summary

  • Add Bayesian weighted rating getter get_weighted_rating using O(1) aggregate stats
  • Document formula in RatingCalculator::calculate_weighted
  • Preserve existing average_rating / get_project_stats behavior unchanged

Closes #244

Weighted rating formula

weighted = (C * m + rating_sum) / (C + review_count)
  • C = WEIGHTED_RATING_PRIOR_COUNT (5)
  • m = WEIGHTED_RATING_PRIOR_MEAN (350 = 3.50 stars)
  • rating_sum uses the existing scaled aggregate (rating * 100)

Edge cases: zero reviews → prior mean; single review → blended score; large datasets → converges to arithmetic mean.

Tests executed

  • cargo fmt
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo test --workspace (502 tests)

Backward compatibility

  • Storage unchanged; weighted rating is read-only
  • Existing average rating getter and aggregates untouched

Note: This PR builds on the contract restoration in #239; merge #239 first or expect overlap in shared files.

Made with Cursor

Goodnessukaigwe and others added 2 commits June 30, 2026 09:09
Preserve prior review revisions with ordered storage, revision count,
history getters, revision events, and tests while restoring the full
contract interface broken on main.

Closes HubDApp#239

Co-authored-by: Cursor <cursoragent@cursor.com>
Implement O(1) weighted rating from aggregate stats using a documented
prior formula while preserving the existing average rating getter.

Closes HubDApp#244

Co-authored-by: Cursor <cursoragent@cursor.com>
@drips-wave

drips-wave Bot commented Jun 30, 2026

Copy link
Copy Markdown

@Goodnessukaigwe Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Naomi-Gift Naomi-Gift merged commit 1195413 into HubDApp:main Jul 2, 2026
1 of 4 checks 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.

Add Weighted Rating Calculation

2 participants