mirror of
https://github.com/osukey/osukey.git
synced 2025-06-28 22:58:10 +09:00
Add concept of "initial items count" in paginated API requests
This commit is contained in:
parent
587f1e2c4f
commit
9d59cd408f
@ -13,8 +13,8 @@ namespace osu.Game.Online.API.Requests
|
|||||||
|
|
||||||
private readonly BeatmapSetType type;
|
private readonly BeatmapSetType type;
|
||||||
|
|
||||||
public GetUserBeatmapsRequest(long userId, BeatmapSetType type, int page = 0, int itemsPerPage = 6)
|
public GetUserBeatmapsRequest(long userId, BeatmapSetType type, int page, int itemsPerPage, int initialItems)
|
||||||
: base(page, itemsPerPage)
|
: base(page, itemsPerPage, initialItems)
|
||||||
{
|
{
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
@ -10,8 +10,8 @@ namespace osu.Game.Online.API.Requests
|
|||||||
{
|
{
|
||||||
private readonly long userId;
|
private readonly long userId;
|
||||||
|
|
||||||
public GetUserKudosuHistoryRequest(long userId, int page = 0, int itemsPerPage = 5)
|
public GetUserKudosuHistoryRequest(long userId, int page, int itemsPerPage, int initialItems)
|
||||||
: base(page, itemsPerPage)
|
: base(page, itemsPerPage, initialItems)
|
||||||
{
|
{
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,8 @@ namespace osu.Game.Online.API.Requests
|
|||||||
{
|
{
|
||||||
private readonly long userId;
|
private readonly long userId;
|
||||||
|
|
||||||
public GetUserMostPlayedBeatmapsRequest(long userId, int page = 0, int itemsPerPage = 5)
|
public GetUserMostPlayedBeatmapsRequest(long userId, int page, int itemsPerPage, int initialItems)
|
||||||
: base(page, itemsPerPage)
|
: base(page, itemsPerPage, initialItems)
|
||||||
{
|
{
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,8 @@ namespace osu.Game.Online.API.Requests
|
|||||||
{
|
{
|
||||||
private readonly long userId;
|
private readonly long userId;
|
||||||
|
|
||||||
public GetUserRecentActivitiesRequest(long userId, int page = 0, int itemsPerPage = 5)
|
public GetUserRecentActivitiesRequest(long userId, int page, int itemsPerPage, int initialItems)
|
||||||
: base(page, itemsPerPage)
|
: base(page, itemsPerPage, initialItems)
|
||||||
{
|
{
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,8 @@ namespace osu.Game.Online.API.Requests
|
|||||||
private readonly ScoreType type;
|
private readonly ScoreType type;
|
||||||
private readonly RulesetInfo ruleset;
|
private readonly RulesetInfo ruleset;
|
||||||
|
|
||||||
public GetUserScoresRequest(long userId, ScoreType type, int page = 0, int itemsPerPage = 5, RulesetInfo ruleset = null)
|
public GetUserScoresRequest(long userId, ScoreType type, int page, int itemsPerPage, int initialItems, RulesetInfo ruleset = null)
|
||||||
: base(page, itemsPerPage)
|
: base(page, itemsPerPage, initialItems)
|
||||||
{
|
{
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
@ -9,11 +9,13 @@ namespace osu.Game.Online.API.Requests
|
|||||||
public abstract class PaginatedAPIRequest<T> : APIRequest<T> where T : class
|
public abstract class PaginatedAPIRequest<T> : APIRequest<T> where T : class
|
||||||
{
|
{
|
||||||
private readonly int page;
|
private readonly int page;
|
||||||
|
private readonly int initialItems;
|
||||||
private readonly int itemsPerPage;
|
private readonly int itemsPerPage;
|
||||||
|
|
||||||
protected PaginatedAPIRequest(int page, int itemsPerPage)
|
protected PaginatedAPIRequest(int page, int itemsPerPage, int initialItems)
|
||||||
{
|
{
|
||||||
this.page = page;
|
this.page = page;
|
||||||
|
this.initialItems = initialItems;
|
||||||
this.itemsPerPage = itemsPerPage;
|
this.itemsPerPage = itemsPerPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,8 +23,13 @@ namespace osu.Game.Online.API.Requests
|
|||||||
{
|
{
|
||||||
var req = base.CreateWebRequest();
|
var req = base.CreateWebRequest();
|
||||||
|
|
||||||
req.AddParameter("offset", (page * itemsPerPage).ToString(CultureInfo.InvariantCulture));
|
if (page == 0)
|
||||||
req.AddParameter("limit", itemsPerPage.ToString(CultureInfo.InvariantCulture));
|
req.AddParameter("limit", initialItems.ToString(CultureInfo.InvariantCulture));
|
||||||
|
else
|
||||||
|
{
|
||||||
|
req.AddParameter("offset", (initialItems + (page - 1) * itemsPerPage).ToString(CultureInfo.InvariantCulture));
|
||||||
|
req.AddParameter("limit", itemsPerPage.ToString(CultureInfo.InvariantCulture));
|
||||||
|
}
|
||||||
|
|
||||||
return req;
|
return req;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user