Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backend/controllers/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func GoogleLogin(ctx *gin.Context) {
Email: email,
Password: "", // No password for Google users
Nickname: nickname,
EloRating: 1200,
Rating: 1200,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Field rename looks good - verify consistency across codebase.

The change from EloRating to Rating is consistent with the broader refactoring effort. The initialization value of 1200 remains unchanged, which preserves existing functionality.


🏁 Script executed:

#!/bin/bash
# Verify that all references to EloRating have been updated to Rating
rg -i "elorating" --type go

Length of output: 1213


Remaining EloRating references need to be updated or justified

I ran a global search and found several places where EloRating still appears in code or BSON mappings:

• backend/routes/rooms.go
  – Struct tag uses bson:"eloRating" on Rating field
• backend/controllers/leaderboard.go
  – Sort key {"eloRating", -1}
• backend/controllers/profile_controller.go
  – Function name calculateEloRating(...)
  – Sort key SetSort(bson.D{{"eloRating", -1}})
  – Struct tag bson:"eloRating" on Rating
  – Update payloads and query filters still reference "eloRating"

Please either:

  • Fully rename these references to use Rating (and, if you’re changing the MongoDB field name, plan a migration),
  • Or clarify why the BSON field and helper function must retain eloRating/calculateEloRating.

— once resolved, we can approve the refactor.

🤖 Prompt for AI Agents
In backend/controllers/auth.go at line 78 and related files
backend/routes/rooms.go, backend/controllers/leaderboard.go, and
backend/controllers/profile_controller.go, the code still uses the old
`EloRating` naming in BSON tags, sort keys, function names, and update payloads.
You need to consistently rename all these references from `EloRating` or
`eloRating` to `Rating` and update the BSON field names accordingly. If changing
the MongoDB field name, plan and implement a migration to update existing
documents. Alternatively, if you decide to keep the old naming for
compatibility, add comments explaining why these references remain unchanged.
Ensure all related code and database mappings are aligned for consistency.

IsVerified: true, // Google-verified emails are trusted
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
Expand Down Expand Up @@ -144,7 +144,7 @@ func SignUp(ctx *gin.Context) {
Email: request.Email,
Password: string(hashedPassword),
Nickname: utils.ExtractNameFromEmail(request.Email),
EloRating: 1200,
Rating: 1200,
IsVerified: false,
VerificationCode: verificationCode,
CreatedAt: time.Now(),
Expand Down
4 changes: 2 additions & 2 deletions backend/controllers/leaderboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func GetLeaderboard(c *gin.Context) {
return
}

// Query users sorted by EloRating (descending)
// Query users sorted by Rating (descending)
collection := db.MongoDatabase.Collection("users")
findOptions := options.Find().SetSort(bson.D{{"eloRating", -1}})
cursor, err := collection.Find(c, bson.M{}, findOptions)
Expand Down Expand Up @@ -83,7 +83,7 @@ func GetLeaderboard(c *gin.Context) {
ID: user.ID.Hex(),
Rank: i + 1,
Name: name,
Score: user.EloRating,
Score: int(user.Rating),
AvatarURL: avatarURL,
CurrentUser: isCurrentUser,
})
Expand Down
Loading