mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-10-04 07:09:58 +00:00
Fix memory leak in GameServer (#731)
* Convert entities to serializable after aggregating rather before * Cache instances of CustomXmlSerializer and create readonly constants for reused settings * Change CustomXmlSerializer and serializer cache to work with deserializer
This commit is contained in:
parent
0253864f5e
commit
2210541894
16 changed files with 125 additions and 147 deletions
|
@ -1,6 +1,7 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Servers.API.Responses;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
@ -35,11 +36,10 @@ public class SlotEndpoints : ApiEndpointController
|
|||
if (limit < 0) limit = 0;
|
||||
limit = Math.Min(ServerStatics.PageSize, limit);
|
||||
|
||||
IEnumerable<ApiSlot> minimalSlots = await this.database.Slots.OrderByDescending(s => s.FirstUploaded)
|
||||
List<ApiSlot> minimalSlots = (await this.database.Slots.OrderByDescending(s => s.FirstUploaded)
|
||||
.Skip(skip)
|
||||
.Take(limit)
|
||||
.Select(s => ApiSlot.CreateFromEntity(s))
|
||||
.ToListAsync();
|
||||
.ToListAsync()).ToSerializableList(ApiSlot.CreateFromEntity);
|
||||
|
||||
return this.Ok(minimalSlots);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Servers.API.Responses;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
|
@ -63,13 +64,12 @@ public class UserEndpoints : ApiEndpointController
|
|||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public async Task<IActionResult> SearchUsers(string query)
|
||||
{
|
||||
List<ApiUser> users = await this.database.Users
|
||||
List<ApiUser> users = (await this.database.Users
|
||||
.Where(u => u.PermissionLevel != PermissionLevel.Banned && u.Username.Contains(query))
|
||||
.Where(u => u.ProfileVisibility == PrivacyType.All) // TODO: change check for when user is logged in
|
||||
.OrderByDescending(b => b.UserId)
|
||||
.Take(20)
|
||||
.Select(u => ApiUser.CreateFromEntity(u))
|
||||
.ToListAsync();
|
||||
.ToListAsync()).ToSerializableList(ApiUser.CreateFromEntity);
|
||||
if (!users.Any()) return this.NotFound();
|
||||
|
||||
return this.Ok(users);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue