Skip to content

fix: track and persist elo rating changes history#267

Open
VishalPainjane wants to merge 2 commits intoAOSSIE-Org:mainfrom
VishalPainjane:fix/elo-rating-tracking
Open

fix: track and persist elo rating changes history#267
VishalPainjane wants to merge 2 commits intoAOSSIE-Org:mainfrom
VishalPainjane:fix/elo-rating-tracking

Conversation

@VishalPainjane
Copy link

@VishalPainjane VishalPainjane commented Jan 24, 2026

Description

This PR implements the missing functionality for storing and retrieving Elo rating changes for each debate match. Previously, the "Recent Debates" section in user profiles displayed a "0" change for all matches because the rating delta was not being persisted.

Changes

  • Data Model: Added EloChange (float64) field to the SavedDebateTranscript struct in backend/models/transcript.go.
  • Service Logic: Refactored transcriptservice.go to calculate ratings before saving the transcript. This ensures the rating delta is captured and saved with the debate record.
  • Controllers: Updated profile_controller.go to return the actual stored Elo change instead of a hardcoded placeholder. Updated debatevsbot_controller.go and transcript_controller.go to support the new function signature.

Fixes

  • Fixes the issue where users could not see the impact of individual matches on their rating.
  • Replaces the TODO: Add actual Elo change tracking placeholder in the profile controller.

Testing

  • Verified that the EloChange field is correctly marshaled and stored using a model verification script.
  • Verified that the backend compiles successfully with the new changes.

closes #265

Summary by CodeRabbit

  • New Features
    • Debate transcripts now track and display Elo rating changes for participants.
    • User profiles now show actual rating changes from recent debates instead of placeholder values.
    • Both participants' rating changes are properly recorded and persisted.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 24, 2026

📝 Walkthrough

Walkthrough

This PR implements Elo rating change tracking in debate history by adding an EloChange field to saved transcripts, extending the SaveDebateTranscript function signature to accept and persist the rating delta, updating all call sites to pass the calculated value, and implementing logic to compute per-user rating changes during rating workflows.

Changes

Cohort / File(s) Summary
Data Model
backend/models/transcript.go
Added EloChange float64 field to SavedDebateTranscript struct with BSON/JSON tags for serialization and persistence.
Service Logic
backend/services/transcriptservice.go
Extended SaveDebateTranscript signature to accept eloChange float64 parameter; implemented tracking and conditional persistence of EloChange values; enhanced SubmitTranscripts to compute per-user EloChange values and save transcripts for both participants with their respective deltas.
Controller Updates
backend/controllers/debatevsbot_controller.go, backend/controllers/profile_controller.go, backend/controllers/transcript_controller.go
Updated JudgeDebate and ConcedeDebate calls to SaveDebateTranscript with 0.0 parameter; changed GetProfile to use transcript.EloChange instead of hardcoded 0.

Sequence Diagram

sequenceDiagram
    participant Controller
    participant Service as TranscriptService
    participant DB as Database
    
    Controller->>Service: SubmitTranscripts(ratingUpdates)
    activate Service
    Service->>Service: UpdateRatings()
    Note over Service: Returns RatingChange for each user
    Service->>Service: Compute forUser EloChange
    Service->>Service: Compute againstUser EloChange
    Service->>DB: Save User A's Transcript<br/>(with eloChange)
    Service->>DB: Save User B's Transcript<br/>(with eloChange)
    Service->>DB: Persist Debate Record
    deactivate Service
    Service-->>Controller: Return ratingSummary
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 wiggles nose with glee
No more zeros in the score,
EloChange is tracked with care!
Each debate now has its due,
Rating shifts displayed so true,
Fuzzy logic wins the day! 🏆

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 44.44% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately and concisely summarizes the main change—adding Elo rating change tracking and persistence.
Linked Issues check ✅ Passed All four coding objectives from issue #265 are met: EloChange field added to SavedDebateTranscript, SaveDebateTranscript function accepts eloChange parameter, UpdateRatings reordered before SaveDebateTranscript, and profile controller returns stored EloChange.
Out of Scope Changes check ✅ Passed All changes are directly aligned with tracking and persisting Elo rating changes across models, services, and controllers as specified in issue #265.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Abhishek2005-ard
Copy link
Contributor

hello @VishalPainjane i am already generate pr on this issue

@VishalPainjane
Copy link
Author

@Abhishek2005-ard please read the issue description properly and follow the guidelines, I was working over the issue

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.

[BUG]: Elo rating changes are not tracked in debate history

2 participants