Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use classic score in total score processor #157

Merged
merged 5 commits into from
Oct 4, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private BeatmapStore(IEnumerable<KeyValuePair<BlacklistEntry, byte>> blacklist)
/// <param name="connection">The <see cref="MySqlConnection"/>.</param>
/// <param name="transaction">An existing transaction.</param>
/// <returns>The created <see cref="BeatmapStore"/>.</returns>
public static async Task<BeatmapStore> CreateAsync(MySqlConnection? connection, MySqlTransaction? transaction = null)
public static async Task<BeatmapStore> CreateAsync(MySqlConnection connection, MySqlTransaction? transaction = null)
{
var dbBlacklist = await connection.QueryAsync<PerformanceBlacklistEntry>("SELECT * FROM osu_beatmap_performance_blacklist", transaction: transaction);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private BuildStore(IEnumerable<KeyValuePair<int, Build>> builds)
/// <param name="connection">The <see cref="MySqlConnection"/>.</param>
/// <param name="transaction">An existing transaction.</param>
/// <returns>The created <see cref="BuildStore"/>.</returns>
public static async Task<BuildStore> CreateAsync(MySqlConnection? connection, MySqlTransaction? transaction = null)
public static async Task<BuildStore> CreateAsync(MySqlConnection connection, MySqlTransaction? transaction = null)
{
var dbBuilds = await connection.QueryAsync<Build>("SELECT * FROM osu_builds WHERE `allow_ranking` = TRUE OR `allow_performance` = TRUE", transaction: transaction);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Dapper" Version="2.0.151" />
<PackageReference Include="Dapper" Version="2.1.4" />
<PackageReference Include="Dapper.Contrib" Version="2.0.78" />
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="4.1.0" />
<PackageReference Include="ppy.osu.Game" Version="2023.928.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Catch" Version="2023.928.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Mania" Version="2023.928.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Osu" Version="2023.928.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Taiko" Version="2023.928.0" />
<PackageReference Include="ppy.osu.Game" Version="2023.1004.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Catch" Version="2023.1004.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Mania" Version="2023.1004.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Osu" Version="2023.1004.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Taiko" Version="2023.1004.0" />
<PackageReference Include="ppy.osu.Server.OsuQueueProcessor" Version="2023.822.0" />
</ItemGroup>

Expand Down