Skip to content

Commit

Permalink
Fix num matches not appearing (#571)
Browse files Browse the repository at this point in the history
  • Loading branch information
jauggy authored Feb 2, 2025
1 parent 5772e33 commit fc50996
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/teiserver/game/libs/match_rating_lib.ex
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,8 @@ defmodule Teiserver.Game.MatchRatingLib do
uncertainty: new_uncertainty,
rating_value_change: new_rating_value - user_rating.rating_value,
skill_change: new_skill - user_rating.skill,
uncertainty_change: new_uncertainty - user_rating.uncertainty
uncertainty_change: new_uncertainty - user_rating.uncertainty,
num_matches: new_num_matches
}
}
end
Expand Down
13 changes: 13 additions & 0 deletions test/teiserver/game/libs/match_rating_lib_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,22 @@ defmodule Teiserver.Game.MatchRatingLibTest do
assert ratings[user1.id].skill == 27.637760127073694
assert ratings[user2.id].skill == 22.362239872926306

# Check num_matches in teiserver_account_ratings table
assert ratings[user1.id].num_matches == 1
assert ratings[user1.id].num_matches == 1

# Check num_matches in teiserver_game_rating_logs table
rating_logs =
Game.list_rating_logs(
search: [
match_id: match.id
],
limit: :infinity
)

assert Enum.at(rating_logs, 0).value["num_matches"] == 1
assert Enum.at(rating_logs, 1).value["num_matches"] == 1

# Create another match
match = create_fake_match(user1.id, user2.id)
MatchRatingLib.rate_match(match.id)
Expand Down

0 comments on commit fc50996

Please sign in to comment.