diff --git a/Content.Server/Database/ServerDbSqlite.cs b/Content.Server/Database/ServerDbSqlite.cs index c975c25cb9..95374db165 100644 --- a/Content.Server/Database/ServerDbSqlite.cs +++ b/Content.Server/Database/ServerDbSqlite.cs @@ -3,13 +3,11 @@ using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; using System.Net; -using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Content.Server.Administration.Logs; using Content.Server.IP; using Content.Server.Preferences.Managers; -using Content.Shared.Administration.Logs; using Content.Shared.CCVar; using Microsoft.EntityFrameworkCore; using Robust.Shared.Configuration; @@ -250,18 +248,6 @@ namespace Content.Server.Database return (admins.Select(p => (p.a, p.LastSeenUserName)).ToArray(), adminRanks)!; } - private async Task NextId(DbSet set, Func selector) where TModel : class - { - var id = 1; - - if (await set.AnyAsync()) - { - id = set.Max(selector) + 1; - } - - return id; - } - public override async Task AddNewRound(params Guid[] playerIds) { await using var db = await GetDb(); @@ -270,9 +256,15 @@ namespace Content.Server.Database .Where(player => playerIds.Contains(player.UserId)) .ToListAsync(); + var nextId = 1; + if (await db.DbContext.Round.AnyAsync()) + { + nextId = db.DbContext.Round.Max(round => round.Id) + 1; + } + var round = new Round { - Id = await NextId(db.DbContext.Round, round => round.Id), + Id = nextId, Players = players }; @@ -287,7 +279,12 @@ namespace Content.Server.Database { await using var db = await GetDb(); - var nextId = await NextId(db.DbContext.AdminLog, log => log.Id); + var nextId = 1; + if (await db.DbContext.AdminLog.AnyAsync()) + { + nextId = db.DbContext.AdminLog.Max(round => round.Id) + 1; + } + var entities = new Dictionary(); foreach (var (log, entityData) in logs)