From 622df8501dffdbbb8b3f15257a11e456884f53cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 28 Sep 2023 12:46:51 +0200 Subject: [PATCH 1/3] Use classic score in total score processor --- .../DatabaseTest.cs | 5 +++++ .../TotalScoreProcessorTests.cs | 8 ++++---- .../Processors/TotalScoreProcessor.cs | 6 ++++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/osu.Server.Queues.ScoreStatisticsProcessor.Tests/DatabaseTest.cs b/osu.Server.Queues.ScoreStatisticsProcessor.Tests/DatabaseTest.cs index 7be5a506..dc1f706e 100644 --- a/osu.Server.Queues.ScoreStatisticsProcessor.Tests/DatabaseTest.cs +++ b/osu.Server.Queues.ScoreStatisticsProcessor.Tests/DatabaseTest.cs @@ -132,6 +132,11 @@ public static ScoreItem CreateTestScore(int? rulesetId = null, int? beatmapId = { HitResult.Perfect, 5 }, { HitResult.LargeBonus, 0 } }, + MaximumStatistics = + { + { HitResult.Perfect, 5 }, + { HitResult.LargeBonus, 2 } + }, Passed = true }; diff --git a/osu.Server.Queues.ScoreStatisticsProcessor.Tests/TotalScoreProcessorTests.cs b/osu.Server.Queues.ScoreStatisticsProcessor.Tests/TotalScoreProcessorTests.cs index f93f0f78..06c27352 100644 --- a/osu.Server.Queues.ScoreStatisticsProcessor.Tests/TotalScoreProcessorTests.cs +++ b/osu.Server.Queues.ScoreStatisticsProcessor.Tests/TotalScoreProcessorTests.cs @@ -12,10 +12,10 @@ public void TestTotalScoreIncrease() WaitForDatabaseState("SELECT total_score FROM osu_user_stats WHERE user_id = 2", (int?)null, CancellationToken); PushToQueueAndWaitForProcess(CreateTestScore()); - WaitForDatabaseState("SELECT total_score FROM osu_user_stats WHERE user_id = 2", 100000, CancellationToken); + WaitForDatabaseState("SELECT total_score FROM osu_user_stats WHERE user_id = 2", 10081, CancellationToken); PushToQueueAndWaitForProcess(CreateTestScore()); - WaitForDatabaseState("SELECT total_score FROM osu_user_stats WHERE user_id = 2", 200000, CancellationToken); + WaitForDatabaseState("SELECT total_score FROM osu_user_stats WHERE user_id = 2", 20162, CancellationToken); } [Fact] @@ -45,12 +45,12 @@ public void TestTotalScoreReprocessDoesntIncrease() WaitForDatabaseState("SELECT total_score FROM osu_user_stats WHERE user_id = 2", (int?)null, CancellationToken); PushToQueueAndWaitForProcess(score); - WaitForDatabaseState("SELECT total_score FROM osu_user_stats WHERE user_id = 2", 100000, CancellationToken); + WaitForDatabaseState("SELECT total_score FROM osu_user_stats WHERE user_id = 2", 10081, CancellationToken); score.MarkProcessed(); PushToQueueAndWaitForProcess(score); - WaitForDatabaseState("SELECT total_score FROM osu_user_stats WHERE user_id = 2", 100000, CancellationToken); + WaitForDatabaseState("SELECT total_score FROM osu_user_stats WHERE user_id = 2", 10081, CancellationToken); } } } diff --git a/osu.Server.Queues.ScoreStatisticsProcessor/Processors/TotalScoreProcessor.cs b/osu.Server.Queues.ScoreStatisticsProcessor/Processors/TotalScoreProcessor.cs index 2d94f4aa..dd3c477d 100644 --- a/osu.Server.Queues.ScoreStatisticsProcessor/Processors/TotalScoreProcessor.cs +++ b/osu.Server.Queues.ScoreStatisticsProcessor/Processors/TotalScoreProcessor.cs @@ -4,6 +4,8 @@ using JetBrains.Annotations; using MySqlConnector; using osu.Game.Online.API.Requests.Responses; +using osu.Game.Rulesets.Scoring; +using osu.Game.Scoring.Legacy; using osu.Server.Queues.ScoreStatisticsProcessor.Models; namespace osu.Server.Queues.ScoreStatisticsProcessor.Processors @@ -19,12 +21,12 @@ public class TotalScoreProcessor : IProcessor public void RevertFromUserStats(SoloScoreInfo score, UserStats userStats, int previousVersion, MySqlConnection conn, MySqlTransaction transaction) { if (previousVersion >= 2) - userStats.total_score -= score.TotalScore; + userStats.total_score -= score.GetDisplayScore(ScoringMode.Classic); } public void ApplyToUserStats(SoloScoreInfo score, UserStats userStats, MySqlConnection conn, MySqlTransaction transaction) { - userStats.total_score += score.TotalScore; + userStats.total_score += score.GetDisplayScore(ScoringMode.Classic); } public void ApplyGlobal(SoloScoreInfo score, MySqlConnection conn) From b80d274b0188d8bbf107f729c936f7d2ad2baf08 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 4 Oct 2023 15:41:12 +0900 Subject: [PATCH 2/3] Update packages --- ...osu.Server.Queues.ScoreStatisticsProcessor.csproj | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Server.Queues.ScoreStatisticsProcessor/osu.Server.Queues.ScoreStatisticsProcessor.csproj b/osu.Server.Queues.ScoreStatisticsProcessor/osu.Server.Queues.ScoreStatisticsProcessor.csproj index e0afedf9..b6e9b4a1 100644 --- a/osu.Server.Queues.ScoreStatisticsProcessor/osu.Server.Queues.ScoreStatisticsProcessor.csproj +++ b/osu.Server.Queues.ScoreStatisticsProcessor/osu.Server.Queues.ScoreStatisticsProcessor.csproj @@ -9,14 +9,14 @@ - + - - - - - + + + + + From 93a1b2687622ff0e567309ff94dd402ad64864e9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 4 Oct 2023 15:57:34 +0900 Subject: [PATCH 3/3] Remove weird nullability on `MySqlConnection` --- .../Stores/BeatmapStore.cs | 2 +- osu.Server.Queues.ScoreStatisticsProcessor/Stores/BuildStore.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Server.Queues.ScoreStatisticsProcessor/Stores/BeatmapStore.cs b/osu.Server.Queues.ScoreStatisticsProcessor/Stores/BeatmapStore.cs index 50936562..df9c940e 100644 --- a/osu.Server.Queues.ScoreStatisticsProcessor/Stores/BeatmapStore.cs +++ b/osu.Server.Queues.ScoreStatisticsProcessor/Stores/BeatmapStore.cs @@ -44,7 +44,7 @@ private BeatmapStore(IEnumerable> blacklist) /// The . /// An existing transaction. /// The created . - public static async Task CreateAsync(MySqlConnection? connection, MySqlTransaction? transaction = null) + public static async Task CreateAsync(MySqlConnection connection, MySqlTransaction? transaction = null) { var dbBlacklist = await connection.QueryAsync("SELECT * FROM osu_beatmap_performance_blacklist", transaction: transaction); diff --git a/osu.Server.Queues.ScoreStatisticsProcessor/Stores/BuildStore.cs b/osu.Server.Queues.ScoreStatisticsProcessor/Stores/BuildStore.cs index 1552e566..e08529cc 100644 --- a/osu.Server.Queues.ScoreStatisticsProcessor/Stores/BuildStore.cs +++ b/osu.Server.Queues.ScoreStatisticsProcessor/Stores/BuildStore.cs @@ -28,7 +28,7 @@ private BuildStore(IEnumerable> builds) /// The . /// An existing transaction. /// The created . - public static async Task CreateAsync(MySqlConnection? connection, MySqlTransaction? transaction = null) + public static async Task CreateAsync(MySqlConnection connection, MySqlTransaction? transaction = null) { var dbBuilds = await connection.QueryAsync("SELECT * FROM osu_builds WHERE `allow_ranking` = TRUE OR `allow_performance` = TRUE", transaction: transaction);