Merge pull request #3792 from peppy/fix-score-datatypes

Fix some data types on ScoreInfo
This commit is contained in:
Dean Herbert 2018-12-01 09:26:18 +09:00 committed by GitHub
commit 8f1d53400e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 14 additions and 21 deletions

View File

@ -38,7 +38,6 @@ public void TestBasicImport()
Rank = ScoreRank.B,
TotalScore = 987654,
Accuracy = 0.8,
Health = 0.8,
MaxCombo = 500,
Combo = 250,
User = new User { Username = "Test user" },
@ -51,7 +50,6 @@ public void TestBasicImport()
Assert.AreEqual(toImport.Rank, imported.Rank);
Assert.AreEqual(toImport.TotalScore, imported.TotalScore);
Assert.AreEqual(toImport.Accuracy, imported.Accuracy);
Assert.AreEqual(toImport.Health, imported.Health);
Assert.AreEqual(toImport.MaxCombo, imported.MaxCombo);
Assert.AreEqual(toImport.Combo, imported.Combo);
Assert.AreEqual(toImport.User.Username, imported.User.Username);

View File

@ -9,7 +9,7 @@
namespace osu.Game.Migrations
{
[DbContext(typeof(OsuDbContext))]
[Migration("20181130084152_AddScoreInfoTables")]
[Migration("20181130113755_AddScoreInfoTables")]
partial class AddScoreInfoTables
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -309,7 +309,8 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
b.Property<int>("ID")
.ValueGeneratedOnAdd();
b.Property<double>("Accuracy");
b.Property<double>("Accuracy")
.HasColumnType("DECIMAL(1,4)");
b.Property<int>("BeatmapInfoID");
@ -321,8 +322,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
b.Property<string>("Hash");
b.Property<double>("Health");
b.Property<int>("MaxCombo");
b.Property<string>("ModsJson")
@ -339,7 +338,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
b.Property<string>("StatisticsJson")
.HasColumnName("Statistics");
b.Property<double>("TotalScore");
b.Property<int>("TotalScore");
b.Property<string>("UserString")
.HasColumnName("User");

View File

@ -14,9 +14,8 @@ protected override void Up(MigrationBuilder migrationBuilder)
ID = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Rank = table.Column<int>(nullable: false),
TotalScore = table.Column<double>(nullable: false),
Accuracy = table.Column<double>(nullable: false),
Health = table.Column<double>(nullable: false),
TotalScore = table.Column<int>(nullable: false),
Accuracy = table.Column<double>(type: "DECIMAL(1,4)", nullable: false),
PP = table.Column<double>(nullable: true),
MaxCombo = table.Column<int>(nullable: false),
Combo = table.Column<int>(nullable: false),

View File

@ -307,7 +307,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<int>("ID")
.ValueGeneratedOnAdd();
b.Property<double>("Accuracy");
b.Property<double>("Accuracy")
.HasColumnType("DECIMAL(1,4)");
b.Property<int>("BeatmapInfoID");
@ -319,8 +320,6 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<string>("Hash");
b.Property<double>("Health");
b.Property<int>("MaxCombo");
b.Property<string>("ModsJson")
@ -337,7 +336,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<string>("StatisticsJson")
.HasColumnName("Statistics");
b.Property<double>("TotalScore");
b.Property<int>("TotalScore");
b.Property<string>("UserString")
.HasColumnName("User");

View File

@ -16,7 +16,7 @@ namespace osu.Game.Online.API.Requests.Responses
public class APIScoreInfo : ScoreInfo
{
[JsonProperty(@"score")]
private double totalScore
private int totalScore
{
set => TotalScore = value;
}

View File

@ -160,13 +160,12 @@ protected void NotifyNewJudgement(JudgementResult result)
/// </summary>
public virtual void PopulateScore(ScoreInfo score)
{
score.TotalScore = TotalScore;
score.TotalScore = (int)Math.Round(TotalScore);
score.Combo = Combo;
score.MaxCombo = HighestCombo;
score.Accuracy = Accuracy;
score.Accuracy = Math.Round(Accuracy, 4);
score.Rank = Rank;
score.Date = DateTimeOffset.Now;
score.Health = Health;
}
}

View File

@ -21,12 +21,11 @@ public class ScoreInfo : IHasFiles<ScoreFileInfo>, IHasPrimaryKey, ISoftDelete
public ScoreRank Rank { get; set; }
public double TotalScore { get; set; }
public int TotalScore { get; set; }
[Column(TypeName="DECIMAL(1,4)")]
public double Accuracy { get; set; }
public double Health { get; set; } = 1;
public double? PP { get; set; }
public int MaxCombo { get; set; }