Rewrite gameserver slot filter system (#763)

* Initial implementation of new slot sorting and filtering system

* Initial implementation of filtering for lbp3 community tab

* Add support for organization on lbp3

* Add playlist and user categories

* Implement unit tests for all filters
Refactor more systems to use PaginationData

* Fix PlayerCountFilter test

* Add more unit tests and integration tests for the filter system

* Fix LBP2 move filter and gameFilterType

* Fix sort by likes in LBP3 category

* Add sort for total plays

* Remove extra whitespace and make styling more consistent

* Order hearted and queued levels by primary key ID

* Fix query without order warnings
This commit is contained in:
Josh 2023-05-31 16:33:39 -05:00 committed by GitHub
parent de228cb242
commit 0c1e350fa3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
106 changed files with 4040 additions and 1183 deletions

View file

@ -4,6 +4,7 @@ using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
using LBPUnion.ProjectLighthouse.Types.Filter;
using LBPUnion.ProjectLighthouse.Types.Levels;
using LBPUnion.ProjectLighthouse.Types.Serialization;
using LBPUnion.ProjectLighthouse.Types.Users;
@ -42,12 +43,10 @@ public class CommentController : ControllerBase
[HttpGet("comments/{slotType}/{slotId:int}")]
[HttpGet("userComments/{username}")]
public async Task<IActionResult> GetComments([FromQuery] int pageStart, [FromQuery] int pageSize, string? username, string? slotType, int slotId)
public async Task<IActionResult> GetComments(string? username, string? slotType, int slotId)
{
GameTokenEntity token = this.GetToken();
if (pageSize <= 0 || pageStart < 0) return this.BadRequest();
if ((slotId == 0 || SlotHelper.IsTypeInvalid(slotType)) == (username == null)) return this.BadRequest();
if (slotType == "developer") slotId = await SlotHelper.GetPlaceholderSlotId(this.database, slotId, SlotType.Developer);
@ -55,6 +54,8 @@ public class CommentController : ControllerBase
int targetId;
CommentType type = username == null ? CommentType.Level : CommentType.Profile;
PaginationData pageData = this.Request.GetPaginationData();
if (type == CommentType.Level)
{
targetId = await this.database.Slots.Where(s => s.SlotId == slotId)
@ -82,8 +83,7 @@ public class CommentController : ControllerBase
.Where(p => !blockedUsers.Contains(p.PosterUserId))
.Include(c => c.Poster)
.Where(p => p.Poster.PermissionLevel != PermissionLevel.Banned)
.Skip(Math.Max(0, pageStart - 1))
.Take(Math.Min(pageSize, 30))
.ApplyPagination(pageData)
.ToListAsync()).ToSerializableList(c => GameComment.CreateFromEntity(c, token.UserId));
return this.Ok(new CommentListResponse(comments));