Implement property dependency injection for the website (#806)

* Remove most non DI usages of DbContext

* Optimize website queries and refactor startup to use top level statements

* Remove unused functions in UserEntity and SlotEntity

* Optimize LBP1 LevelTags
This commit is contained in:
Josh 2023-06-20 00:02:24 -05:00 committed by GitHub
parent 727dd4e903
commit e43397ac6a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
47 changed files with 333 additions and 430 deletions

View file

@ -98,17 +98,22 @@ public class MatchController : ControllerBase
case FindBestRoom diveInData when MatchHelper.UserLocations.Count > 1:
#endif
{
FindBestRoomResponse? response = RoomHelper.FindBestRoom
(user, token.GameVersion, diveInData.RoomSlot, token.Platform, token.UserLocation);
FindBestRoomResponse? response = RoomHelper.FindBestRoom(this.database,
user,
token.GameVersion,
diveInData.RoomSlot,
token.Platform,
token.UserLocation);
if (response == null) return this.NotFound();
string serialized = JsonSerializer.Serialize(response, typeof(FindBestRoomResponse));
foreach (Player player in response.Players) MatchHelper.AddUserRecentlyDivedIn(user.UserId, player.User.UserId);
foreach (Player player in response.Players)
MatchHelper.AddUserRecentlyDivedIn(user.UserId, player.User.UserId);
return this.Ok($"[{{\"StatusCode\":200}},{serialized}]");
}
case CreateRoom createRoom when MatchHelper.UserLocations.Count >= 1:
case CreateRoom createRoom when !MatchHelper.UserLocations.IsEmpty:
{
List<int> users = new();
foreach (string playerUsername in createRoom.Players)
@ -139,9 +144,8 @@ public class MatchController : ControllerBase
}
room.PlayerIds = users.Select(u => u.UserId).ToList();
await RoomHelper.CleanupRooms(null, room);
await RoomHelper.CleanupRooms(this.database, null, room);
}
break;
}
}