Update all existing usages of `AuthorString`/`AuthorId`

Unfortunately the getters need to be left in place else EF breaks.
This commit is contained in:
Dean Herbert 2021-11-04 18:46:26 +09:00
parent 7acc4a4708
commit ed07ee8c61
12 changed files with 19 additions and 21 deletions

View File

@ -112,7 +112,7 @@ public void TestDecodeBeatmapMetadata()
Assert.AreEqual("Renatus", metadata.TitleUnicode);
Assert.AreEqual("Soleily", metadata.Artist);
Assert.AreEqual("Soleily", metadata.ArtistUnicode);
Assert.AreEqual("Gamu", metadata.AuthorString);
Assert.AreEqual("Gamu", metadata.Author.Username);
Assert.AreEqual("Insane", beatmapInfo.Version);
Assert.AreEqual(string.Empty, metadata.Source);
Assert.AreEqual("MBC7 Unisphere 地球ヤバイEP Chikyu Yabai", metadata.Tags);
@ -547,7 +547,7 @@ public void TestFallbackDecoderForCorruptedHeader()
Assert.DoesNotThrow(() => beatmap = decoder.Decode(stream));
Assert.IsNotNull(beatmap);
Assert.AreEqual("Beatmap with corrupted header", beatmap.Metadata.Title);
Assert.AreEqual("Evil Hacker", beatmap.Metadata.AuthorString);
Assert.AreEqual("Evil Hacker", beatmap.Metadata.Author.Username);
}
}
@ -565,7 +565,7 @@ public void TestFallbackDecoderForMissingHeader()
Assert.DoesNotThrow(() => beatmap = decoder.Decode(stream));
Assert.IsNotNull(beatmap);
Assert.AreEqual("Beatmap with no header", beatmap.Metadata.Title);
Assert.AreEqual("Incredibly Evil Hacker", beatmap.Metadata.AuthorString);
Assert.AreEqual("Incredibly Evil Hacker", beatmap.Metadata.Author.Username);
}
}
@ -583,7 +583,7 @@ public void TestDecodeFileWithEmptyLinesAtStart()
Assert.DoesNotThrow(() => beatmap = decoder.Decode(stream));
Assert.IsNotNull(beatmap);
Assert.AreEqual("Empty lines at start", beatmap.Metadata.Title);
Assert.AreEqual("Edge Case Hunter", beatmap.Metadata.AuthorString);
Assert.AreEqual("Edge Case Hunter", beatmap.Metadata.Author.Username);
}
}
@ -601,7 +601,7 @@ public void TestDecodeFileWithEmptyLinesAndNoHeader()
Assert.DoesNotThrow(() => beatmap = decoder.Decode(stream));
Assert.IsNotNull(beatmap);
Assert.AreEqual("The dog ate the file header", beatmap.Metadata.Title);
Assert.AreEqual("Why does this keep happening", beatmap.Metadata.AuthorString);
Assert.AreEqual("Why does this keep happening", beatmap.Metadata.Author.Username);
}
}
@ -619,7 +619,7 @@ public void TestDecodeFileWithContentImmediatelyAfterHeader()
Assert.DoesNotThrow(() => beatmap = decoder.Decode(stream));
Assert.IsNotNull(beatmap);
Assert.AreEqual("No empty line delimiting header from contents", beatmap.Metadata.Title);
Assert.AreEqual("Edge Case Hunter", beatmap.Metadata.AuthorString);
Assert.AreEqual("Edge Case Hunter", beatmap.Metadata.Author.Username);
}
}

View File

@ -35,7 +35,7 @@ public void TestDecodeMetadata()
Assert.AreEqual("Soleily", meta.Artist);
Assert.AreEqual("Soleily", meta.ArtistUnicode);
Assert.AreEqual("03. Renatus - Soleily 192kbps.mp3", meta.AudioFile);
Assert.AreEqual("Gamu", meta.AuthorString);
Assert.AreEqual("Gamu", meta.Author.Username);
Assert.AreEqual("machinetop_background.jpg", meta.BackgroundFile);
Assert.AreEqual(164471, meta.PreviewTime);
Assert.AreEqual(string.Empty, meta.Source);

View File

@ -60,7 +60,7 @@ public void TestReadMetadata()
Assert.AreEqual("Soleily", meta.Artist);
Assert.AreEqual("Soleily", meta.ArtistUnicode);
Assert.AreEqual("03. Renatus - Soleily 192kbps.mp3", meta.AudioFile);
Assert.AreEqual("Deif", meta.AuthorString);
Assert.AreEqual("Deif", meta.Author.Username);
Assert.AreEqual("machinetop_background.jpg", meta.BackgroundFile);
Assert.AreEqual(164471, meta.PreviewTime);
Assert.AreEqual(string.Empty, meta.Source);

View File

@ -400,7 +400,7 @@ public void TestSorting()
loadBeatmaps();
AddStep("Sort by author", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Author }, false));
AddAssert("Check zzzzz is at bottom", () => carousel.BeatmapSets.Last().Metadata.AuthorString == "zzzzz");
AddAssert("Check zzzzz is at bottom", () => carousel.BeatmapSets.Last().Metadata.Author.Username == "zzzzz");
AddStep("Sort by artist", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Artist }, false));
AddAssert($"Check #{set_count} is at bottom", () => carousel.BeatmapSets.Last().Metadata.Title.EndsWith($"#{set_count}!", StringComparison.Ordinal));
}

View File

@ -49,7 +49,7 @@ public class BeatmapMetadata : IEquatable<BeatmapMetadata>, IHasPrimaryKey, IBea
[Column("AuthorID")]
public int AuthorID
{
get => Author.Id;
get => Author.Id; // This should not be used, but is required to make EF work correctly.
set => Author.Id = value;
}
@ -60,7 +60,7 @@ public int AuthorID
[Column("Author")]
public string AuthorString
{
get => Author.Username;
get => Author.Username; // This should not be used, but is required to make EF work correctly.
set => Author.Username = value;
}

View File

@ -129,7 +129,7 @@ private void handleMetadata(TextWriter writer)
if (!string.IsNullOrEmpty(beatmap.Metadata.TitleUnicode)) writer.WriteLine(FormattableString.Invariant($"TitleUnicode: {beatmap.Metadata.TitleUnicode}"));
writer.WriteLine(FormattableString.Invariant($"Artist: {beatmap.Metadata.Artist}"));
if (!string.IsNullOrEmpty(beatmap.Metadata.ArtistUnicode)) writer.WriteLine(FormattableString.Invariant($"ArtistUnicode: {beatmap.Metadata.ArtistUnicode}"));
writer.WriteLine(FormattableString.Invariant($"Creator: {beatmap.Metadata.AuthorString}"));
writer.WriteLine(FormattableString.Invariant($"Creator: {beatmap.Metadata.Author.Username}"));
writer.WriteLine(FormattableString.Invariant($"Version: {beatmap.BeatmapInfo.Version}"));
if (!string.IsNullOrEmpty(beatmap.Metadata.Source)) writer.WriteLine(FormattableString.Invariant($"Source: {beatmap.Metadata.Source}"));
if (!string.IsNullOrEmpty(beatmap.Metadata.Tags)) writer.WriteLine(FormattableString.Invariant($"Tags: {beatmap.Metadata.Tags}"));

View File

@ -46,7 +46,7 @@ private void load()
Empty(),
creatorTextBox = createTextBox<LabelledTextBox>("Creator", metadata.AuthorString),
creatorTextBox = createTextBox<LabelledTextBox>("Creator", metadata.Author.Username),
difficultyTextBox = createTextBox<LabelledTextBox>("Difficulty Name", Beatmap.BeatmapInfo.Version),
sourceTextBox = createTextBox<LabelledTextBox>("Source", metadata.Source),
tagsTextBox = createTextBox<LabelledTextBox>("Tags", metadata.Tags)

View File

@ -164,7 +164,7 @@ private void load(BeatmapDifficultyCache difficultyCache)
new Drawable[]
{
new MetadataLineLabel("Mapper"),
new MetadataLineInfo(metadata.AuthorString)
new MetadataLineInfo(metadata.Author.Username)
}
}
},

View File

@ -49,7 +49,7 @@ public override void Filter(FilterCriteria criteria)
match &= !criteria.BeatDivisor.HasFilter || criteria.BeatDivisor.IsInRange(BeatmapInfo.BeatDivisor);
match &= !criteria.OnlineStatus.HasFilter || criteria.OnlineStatus.IsInRange(BeatmapInfo.Status);
match &= !criteria.Creator.HasFilter || criteria.Creator.Matches(BeatmapInfo.Metadata.AuthorString);
match &= !criteria.Creator.HasFilter || criteria.Creator.Matches(BeatmapInfo.Metadata.Author.Username);
match &= !criteria.Artist.HasFilter || criteria.Artist.Matches(BeatmapInfo.Metadata.Artist) ||
criteria.Artist.Matches(BeatmapInfo.Metadata.ArtistUnicode);

View File

@ -77,6 +77,6 @@ public override ISample GetSample(ISampleInfo sampleInfo)
}
private static SkinInfo createSkinInfo(BeatmapInfo beatmapInfo) =>
new SkinInfo { Name = beatmapInfo.ToString(), Creator = beatmapInfo.Metadata?.AuthorString };
new SkinInfo { Name = beatmapInfo.ToString(), Creator = beatmapInfo.Metadata?.Author.Username };
}
}

View File

@ -240,8 +240,8 @@ private List<RealmBeatmap> createBeatmapDifficulties(IList<RealmNamedFileUsage>
ArtistUnicode = decoded.Metadata.ArtistUnicode,
Author =
{
OnlineID = decoded.Metadata.AuthorID,
Username = decoded.Metadata.AuthorString
OnlineID = decoded.Metadata.Author.Id,
Username = decoded.Metadata.Author.Username
},
Source = decoded.Metadata.Source,
Tags = decoded.Metadata.Tags,

View File

@ -216,8 +216,6 @@ protected APIBeatmapSet CreateAPIBeatmapSet(RulesetInfo ruleset = null)
Artist = beatmap.BeatmapSet.Metadata.Artist,
ArtistUnicode = beatmap.BeatmapSet.Metadata.ArtistUnicode,
Author = beatmap.BeatmapSet.Metadata.Author,
AuthorID = beatmap.BeatmapSet.Metadata.AuthorID,
AuthorString = beatmap.BeatmapSet.Metadata.AuthorString,
Source = beatmap.BeatmapSet.Metadata.Source,
Tags = beatmap.BeatmapSet.Metadata.Tags,
Beatmaps = new[]
@ -228,7 +226,7 @@ protected APIBeatmapSet CreateAPIBeatmapSet(RulesetInfo ruleset = null)
OnlineBeatmapSetID = beatmap.BeatmapSet.OnlineID,
Status = beatmap.Status,
Checksum = beatmap.MD5Hash,
AuthorID = beatmap.Metadata.AuthorID,
AuthorID = beatmap.Metadata.Author.OnlineID,
RulesetID = beatmap.RulesetID,
StarRating = beatmap.StarDifficulty,
DifficultyName = beatmap.Version,