Add newest levels category

This commit is contained in:
jvyden 2021-10-29 15:42:06 -04:00
commit b340d4a955
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
2 changed files with 19 additions and 0 deletions

View file

@ -1,3 +1,4 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using LBPUnion.ProjectLighthouse.Serialization;
@ -38,5 +39,18 @@ namespace LBPUnion.ProjectLighthouse.Controllers {
return this.Ok(slot.Serialize());
}
[HttpGet("slots")]
public IActionResult NewestSlots([FromQuery] int pageStart, [FromQuery] int pageSize) {
string response = Enumerable.Aggregate(this.database.Slots
.Include(s => s.Creator)
.Include(s => s.Location)
.OrderBy(s => s.FirstUploaded)
.Skip(pageStart - 1)
.Take(Math.Min(pageSize, 30))
, string.Empty, (current, slot) => current + slot.Serialize());
return this.Ok(LbpSerializer.TaggedStringElement("slots", response, "total", 1));
}
}
}

View file

@ -28,6 +28,11 @@ namespace LBPUnion.ProjectLighthouse.Controllers {
return this.Ok(user.Serialize());
}
[HttpGet("users")]
public async Task<IActionResult> GetUserAlt([FromQuery] string u) {
return await GetUser(u);
}
// [HttpPost("user/{username}")]
// public async Task<IActionResult> CreateUser(string username) {
// await new Database().CreateUser(username);