1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 17:32:54 +08:00

More robust cursor parsing solution

> Change cursor request to return last response's entire cursor structure
This commit is contained in:
「空白」 2020-05-13 03:44:57 +09:00
parent 6a867caaaa
commit cabf3a89b1

View File

@ -2,10 +2,13 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.IO.Network;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Game.Overlays;
using osu.Game.Overlays.BeatmapListing;
using osu.Game.Rulesets;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
namespace osu.Game.Online.API.Requests
{
@ -13,32 +16,8 @@ namespace osu.Game.Online.API.Requests
{
public class Cursor
{
[JsonProperty("title.raw")]
public string Title;
[JsonProperty("artist.raw")]
public string Artist;
[JsonProperty("beatmaps.difficultyrating")]
public string Difficulty;
[JsonProperty("approved_date")]
public string Ranked;
[JsonProperty("rating")]
public string Rating;
[JsonProperty("play_count")]
public string Plays;
[JsonProperty("favourite_count")]
public string Favourites;
[JsonProperty("_score")]
public string Relevance;
[JsonProperty("_id")]
public string Id;
[JsonExtensionData]
public IDictionary<string, JToken> Properties;
}
public SearchCategory SearchCategory { get; set; }
@ -89,27 +68,10 @@ namespace osu.Game.Online.API.Requests
req.AddParameter("sort", $"{SortCriteria.ToString().ToLowerInvariant()}_{directionString}");
if (cursor != null)
cursor?.Properties.ForEach(x =>
{
if (cursor.Title != null)
req.AddParameter("cursor[title.raw]", cursor.Title);
if (cursor.Artist != null)
req.AddParameter("cursor[artist.raw]", cursor.Artist);
if (cursor.Difficulty != null)
req.AddParameter("cursor[beatmaps.difficultyrating]", cursor.Difficulty);
if (cursor.Ranked != null)
req.AddParameter("cursor[approved_date]", cursor.Ranked);
if (cursor.Rating != null)
req.AddParameter("cursor[rating]", cursor.Rating);
if (cursor.Plays != null)
req.AddParameter("cursor[play_count]", cursor.Plays);
if (cursor.Favourites != null)
req.AddParameter("cursor[favourite_count]", cursor.Favourites);
if (cursor.Relevance != null)
req.AddParameter("cursor[_score]", cursor.Relevance);
req.AddParameter("cursor[_id]", cursor.Id);
}
req.AddParameter("cursor[" + x.Key + "]", x.Value?.ToString());
});
return req;
}