Merge pull request #1437 from peppy/direct-performance

Fix osu!direct panel load performance
This commit is contained in:
Dan Balasescu 2017-10-25 22:58:02 +09:00 committed by GitHub
commit 2ef906177a
4 changed files with 17 additions and 14 deletions

View File

@ -17,6 +17,7 @@ public class BeatmapMetadata
private int? onlineBeatmapSetID;
[NotMapped]
[JsonProperty(@"id")]
public int? OnlineBeatmapSetID
{
get { return onlineBeatmapSetID; }

View File

@ -9,7 +9,7 @@
namespace osu.Game.Online.API.Requests
{
public class GetBeatmapSetsResponse : BeatmapMetadata
public class GetBeatmapSetsResponse : BeatmapMetadata // todo: this is a bit wrong...
{
[JsonProperty(@"covers")]
private BeatmapSetOnlineCovers covers { get; set; }
@ -23,9 +23,6 @@ public class GetBeatmapSetsResponse : BeatmapMetadata
[JsonProperty(@"favourite_count")]
private int favouriteCount { get; set; }
[JsonProperty(@"id")]
private int onlineId { get; set; }
[JsonProperty(@"user_id")]
private long creatorId {
set { Author.Id = value; }
@ -38,7 +35,7 @@ public BeatmapSetInfo ToBeatmapSet(RulesetStore rulesets)
{
return new BeatmapSetInfo
{
OnlineBeatmapSetID = onlineId,
OnlineBeatmapSetID = OnlineBeatmapSetID,
Metadata = this,
OnlineInfo = new BeatmapSetOnlineInfo
{

View File

@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using OpenTK;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
@ -65,9 +66,7 @@ public IEnumerable<BeatmapSetInfo> BeatmapSets
ResultAmounts = new ResultCounts(distinctCount(artists), distinctCount(songs), distinctCount(tags));
if (beatmapSets.Any() && panels == null)
// real use case? currently only seems to be for test case
recreatePanels(Filter.DisplayStyleControl.DisplayStyle.Value);
recreatePanels(Filter.DisplayStyleControl.DisplayStyle.Value);
}
}
@ -274,13 +273,17 @@ private void updateSearch()
Filter.DisplayStyleControl.Dropdown.Current.Value,
Filter.Tabs.Current.Value); //todo: sort direction (?)
getSetsRequest.Success += r =>
getSetsRequest.Success += response =>
{
BeatmapSets = r?.
Select(response => response.ToBeatmapSet(rulesets)).
Where(b => beatmaps.QueryBeatmapSet(q => q.OnlineBeatmapSetID == b.OnlineBeatmapSetID) == null);
Task.Run(() =>
{
var onlineIds = response.Select(r => r.OnlineBeatmapSetID).ToList();
var presentOnlineIds = beatmaps.QueryBeatmapSets(s => onlineIds.Contains(s.OnlineBeatmapSetID)).Select(r => r.OnlineBeatmapSetID).ToList();
var sets = response.Select(r => r.ToBeatmapSet(rulesets)).Where(b => !presentOnlineIds.Contains(b.OnlineBeatmapSetID)).ToList();
recreatePanels(Filter.DisplayStyleControl.DisplayStyle.Value);
// may not need scheduling; loads async internally.
Schedule(() => BeatmapSets = sets);
});
};
api.Queue(getSetsRequest);

View File

@ -41,7 +41,7 @@ public RulesetStore(Func<OsuDbContext> factory)
/// <summary>
/// All available rulesets.
/// </summary>
public IEnumerable<RulesetInfo> AvailableRulesets => GetContext().RulesetInfo.Where(r => r.Available);
public IEnumerable<RulesetInfo> AvailableRulesets;
private static Assembly currentDomain_AssemblyResolve(object sender, ResolveEventArgs args) => loaded_assemblies.Keys.FirstOrDefault(a => a.FullName == args.Name);
@ -93,6 +93,8 @@ protected void AddMissingRulesets()
}
context.SaveChanges();
AvailableRulesets = context.RulesetInfo.Where(r => r.Available).ToList();
}
private static void loadRulesetFromFile(string file)