Replace live/batch Rating calculation with denormalized RatingSum/RatingCount counters on School #519 - #512
Conversation
|
🤖 AI Generated Review This review was generated automatically and does not replace human review. Review chunk 1/4SummaryThe pull request primarily focuses on undoing the previous decoupling of school Rating/Rank and renaming the "RankScore" to "Score" across various parts of the codebase. It updates data transfer objects (DTOs), domain entities, specifications, and also adjusts migration scripts to reflect this change. Potential Issues
Suggestions
Positive Feedback
Review chunk 2/4SummaryThis pull request reverts changes related to the decoupling of school Rate/Rank fields and renames a property from Potential Issues
Suggestions
Positive Feedback
Review chunk 3/4SummaryThis pull request primarily focuses on undoing the decoupling of school Rate/Rank and renaming Score to RankScore. It involves changes to multiple entity configurations and database mappings within the GamaEdtech application. Potential Issues
Suggestions
Positive Feedback
These changes are well-organized and adhere to best practices for using Entity Framework Core in terms of setting up relationships and database mappings. Review chunk 4/4SummaryThis pull request addresses several changes: it undoes the decoupling of school Rate/Rank, renames the Potential Issues
Suggestions
Positive Feedback
|
|
🤖 AI Generated Review This review was generated automatically and does not replace human review. Review chunk 1/4SummaryThe pull request updates the existing school rate/rank feature to undo a previous decoupling of rate and rank, and renames "Score" to "RankScore". It involves changes across multiple files, including several database migrations and modifications to service classes, DTOs, and controllers to reflect these changes. Potential Issues
Suggestions
Positive Feedback
Review chunk 2/4SummaryThe pull request includes the addition of multiple entity configurations for the Potential Issues
Suggestions
Positive Feedback
Review chunk 3/4SummaryThis pull request involves modifications related to the database schema mapping in Entity Framework. New entities and associations are defined for various domain models, including Potential Issues
Suggestions
Positive Feedback
Review chunk 4/4SummaryThe pull request involves significant changes related to the renaming of Potential Issues
Suggestions
Positive Feedback
|
gamadev1
left a comment
There was a problem hiding this comment.
Review: #512 — requesting changes
Thanks for looking into Rating's performance — that's a legitimate concern (the live .Average() in GetSchoolsListAsync does get evaluated for every matching row before pagination, since it's part of the same projection that OrderBy/Skip/Take run on top of).
But this PR does more than optimize Rating — it merges Rating back into RankScore (renaming the column, reusing it for both the public rating and the internal ranking formula). That reverses the split made on 2026-07-10 (docs/business/school-scoring-analysis.md) for a real reason: Rating is meant to be "what reviewers actually said" (0–5), while RankScore is a 0–150 blend of reviews and profile completeness (website, coordinates, contact info, photos) used only for ordering. Combining them means a school with zero reviews but a filled-out profile would show a nonzero "rating" it didn't earn from anyone.
It also has a concrete bug as written: UpdateSchoolScoreAsync's final UPDATE sets s.Rating = rc.Rating, but rc never produces a Rating column (only CommentRating and Score exist in the CTE) — this throws Invalid column name 'Rating' every time the ranking job runs, which will break CountryRank/StateRank/CityRank recalculation entirely once merged.
Could we split this into two separate concerns?
- Keep
RatingandRankScoreas separate, independent values — don't rename/merge the column. - Solve the performance problem on its own terms: e.g. add a persisted, indexed
Ratingcolumn that's just the plain review average, updated incrementally whenever aSchoolCommentis added/edited/deleted (not via the periodicRankScorebatch job) — that gets you the O(1) read you're after without reintroducing staleness or conflating it with ranking.
Happy to pair on the incremental-update approach if useful. Would rather not merge the Rating/RankScore recombination as-is — can you confirm with whoever's driving #500 whether that merge is actually the intended fix, or if it was really just the performance angle that mattered?
…ingCount counters on School GamaEdtech#519
Pull Request Template
Description
Fixes #(issue number)
Type of Change
Checklist
Additional Notes
Any other information or context here.