mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-06 11:58:38 +00:00
implemented pages in the queue list, hearted levels and hearted users
not the page button but the actual size thing
This commit is contained in:
parent
a78623b6ab
commit
1856cf7264
1 changed files with 19 additions and 6 deletions
|
@ -1,4 +1,5 @@
|
||||||
#nullable enable
|
#nullable enable
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -26,7 +27,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
||||||
#region Level Queue (lolcatftw)
|
#region Level Queue (lolcatftw)
|
||||||
|
|
||||||
[HttpGet("slots/lolcatftw/{username}")]
|
[HttpGet("slots/lolcatftw/{username}")]
|
||||||
public async Task<IActionResult> GetLevelQueue(string username)
|
public async Task<IActionResult> GetLevelQueue(string username, [FromQuery] int pageSize, [FromQuery] int pageStart)
|
||||||
{
|
{
|
||||||
Token? token = await this.database.TokenFromRequest(this.Request);
|
Token? token = await this.database.TokenFromRequest(this.Request);
|
||||||
if (token == null) return this.BadRequest();
|
if (token == null) return this.BadRequest();
|
||||||
|
@ -39,11 +40,15 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
||||||
.Include(q => q.Slot.Creator)
|
.Include(q => q.Slot.Creator)
|
||||||
.Where(q => q.Slot.GameVersion <= gameVersion)
|
.Where(q => q.Slot.GameVersion <= gameVersion)
|
||||||
.Where(q => q.User.Username == username)
|
.Where(q => q.User.Username == username)
|
||||||
|
.Skip(pageStart - 1)
|
||||||
|
.Take(Math.Min(pageSize, 30))
|
||||||
.AsEnumerable();
|
.AsEnumerable();
|
||||||
|
|
||||||
|
int lolcatftwLength = this.database.QueuedLevels.Include(q => q.User).Where(q => q.User.Username == username).Count();
|
||||||
|
|
||||||
string response = queuedLevels.Aggregate(string.Empty, (current, q) => current + q.Slot.Serialize());
|
string response = queuedLevels.Aggregate(string.Empty, (current, q) => current + q.Slot.Serialize());
|
||||||
|
|
||||||
return this.Ok(LbpSerializer.TaggedStringElement("slots", response, "total", queuedLevels.Count()));
|
return this.Ok(LbpSerializer.TaggedStringElement("slots", response, "total", lolcatftwLength));
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("lolcatftw/add/user/{id:int}")]
|
[HttpPost("lolcatftw/add/user/{id:int}")]
|
||||||
|
@ -88,7 +93,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
||||||
#region Hearted Levels
|
#region Hearted Levels
|
||||||
|
|
||||||
[HttpGet("favouriteSlots/{username}")]
|
[HttpGet("favouriteSlots/{username}")]
|
||||||
public async Task<IActionResult> GetFavouriteSlots(string username)
|
public async Task<IActionResult> GetFavouriteSlots(string username, [FromQuery] int pageSize, [FromQuery] int pageStart)
|
||||||
{
|
{
|
||||||
Token? token = await this.database.TokenFromRequest(this.Request);
|
Token? token = await this.database.TokenFromRequest(this.Request);
|
||||||
if (token == null) return this.BadRequest();
|
if (token == null) return this.BadRequest();
|
||||||
|
@ -101,11 +106,15 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
||||||
.Include(q => q.Slot.Creator)
|
.Include(q => q.Slot.Creator)
|
||||||
.Where(q => q.Slot.GameVersion <= gameVersion)
|
.Where(q => q.Slot.GameVersion <= gameVersion)
|
||||||
.Where(q => q.User.Username == username)
|
.Where(q => q.User.Username == username)
|
||||||
|
.Skip(pageStart - 1)
|
||||||
|
.Take(Math.Min(pageSize, 30))
|
||||||
.AsEnumerable();
|
.AsEnumerable();
|
||||||
|
|
||||||
|
int favouriteSlotsLength = this.database.HeartedLevels.Include(q => q.User).Where(q => q.User.Username == username).Count();
|
||||||
|
|
||||||
string response = heartedLevels.Aggregate(string.Empty, (current, q) => current + q.Slot.Serialize());
|
string response = heartedLevels.Aggregate(string.Empty, (current, q) => current + q.Slot.Serialize());
|
||||||
|
|
||||||
return this.Ok(LbpSerializer.TaggedStringElement("favouriteSlots", response, "total", heartedLevels.Count()));
|
return this.Ok(LbpSerializer.TaggedStringElement("favouriteSlots", response, "total", favouriteSlotsLength));
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("favourite/slot/user/{id:int}")]
|
[HttpPost("favourite/slot/user/{id:int}")]
|
||||||
|
@ -152,7 +161,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
||||||
#region Users
|
#region Users
|
||||||
|
|
||||||
[HttpGet("favouriteUsers/{username}")]
|
[HttpGet("favouriteUsers/{username}")]
|
||||||
public async Task<IActionResult> GetFavouriteUsers(string username)
|
public async Task<IActionResult> GetFavouriteUsers(string username, [FromQuery] int pageSize, [FromQuery] int pageStart)
|
||||||
{
|
{
|
||||||
Token? token = await this.database.TokenFromRequest(this.Request);
|
Token? token = await this.database.TokenFromRequest(this.Request);
|
||||||
if (token == null) return this.StatusCode(403, "");
|
if (token == null) return this.StatusCode(403, "");
|
||||||
|
@ -162,11 +171,15 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
||||||
.Include(q => q.HeartedUser)
|
.Include(q => q.HeartedUser)
|
||||||
.Include(q => q.HeartedUser.Location)
|
.Include(q => q.HeartedUser.Location)
|
||||||
.Where(q => q.User.Username == username)
|
.Where(q => q.User.Username == username)
|
||||||
|
.Skip(pageStart - 1)
|
||||||
|
.Take(Math.Min(pageSize, 30))
|
||||||
.AsEnumerable();
|
.AsEnumerable();
|
||||||
|
|
||||||
|
int favouriteUsersLength = this.database.HeartedProfiles.Include(q => q.User).Where(q => q.User.Username == username).Count();
|
||||||
|
|
||||||
string response = heartedProfiles.Aggregate(string.Empty, (current, q) => current + q.HeartedUser.Serialize(token.GameVersion));
|
string response = heartedProfiles.Aggregate(string.Empty, (current, q) => current + q.HeartedUser.Serialize(token.GameVersion));
|
||||||
|
|
||||||
return this.Ok(LbpSerializer.TaggedStringElement("favouriteUsers", response, "total", heartedProfiles.Count()));
|
return this.Ok(LbpSerializer.TaggedStringElement("favouriteUsers", response, "total", heartedProfiles));
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("favourite/user/{username}")]
|
[HttpPost("favourite/user/{username}")]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue