Stop all reads/writes to the admin_log_entity table (#21186)

This commit is contained in:
DrSmugleaf
2023-10-22 21:24:03 -07:00
committed by GitHub
parent 43d5c00648
commit 52e1d64ee2
3 changed files with 9 additions and 22 deletions

View File

@@ -517,6 +517,7 @@ namespace Content.Server.Database
public List<AdminLogPlayer> Players { get; set; } = default!;
// Unused
public List<AdminLogEntity> Entities { get; set; } = default!;
}
@@ -530,6 +531,7 @@ namespace Content.Server.Database
[ForeignKey("LogId,RoundId")] public AdminLog Log { get; set; } = default!;
}
// Unused
public class AdminLogEntity
{
[Required, Key] public int Uid { get; set; }

View File

@@ -2,7 +2,6 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Content.Server.Administration.Logs.Converters;
using Content.Server.Database;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Map;
@@ -34,10 +33,9 @@ public sealed partial class AdminLogManager
_sawmill.Debug($"Admin log converters found: {string.Join(" ", converterNames)}");
}
private (JsonDocument Json, HashSet<Guid> Players, List<AdminLogEntity> Entities) ToJson(
private (JsonDocument Json, HashSet<Guid> Players) ToJson(
Dictionary<string, object?> properties)
{
var entities = new Dictionary<EntityUid, AdminLogEntity>();
var players = new HashSet<Guid>();
var parsed = new Dictionary<string, object?>();
@@ -63,24 +61,12 @@ public sealed partial class AdminLogManager
_ => null
};
if (entityId is not { } uid)
{
continue;
}
var entityName = _entityManager.TryGetComponent(uid, out MetaDataComponent? metadata)
? metadata.EntityName
: null;
// TODO set the id too whenever we feel like running a migration for 10 hours
entities.TryAdd(uid, new AdminLogEntity { Name = entityName });
if (_entityManager.TryGetComponent(uid, out ActorComponent? actor))
if (_entityManager.TryGetComponent(entityId, out ActorComponent? actor))
{
players.Add(actor.PlayerSession.UserId.UserId);
}
}
return (JsonSerializer.SerializeToDocument(parsed, _jsonOptions), players, entities.Values.ToList());
return (JsonSerializer.SerializeToDocument(parsed, _jsonOptions), players);
}
}

View File

@@ -278,7 +278,7 @@ public sealed partial class AdminLogManager : SharedAdminLogManager, IAdminLogMa
}
}
private void Add(LogType type, LogImpact impact, string message, JsonDocument json, HashSet<Guid> players, List<AdminLogEntity> entities)
private void Add(LogType type, LogImpact impact, string message, JsonDocument json, HashSet<Guid> players)
{
var preRound = _runLevel == GameRunLevel.PreRoundLobby;
var count = preRound ? _preRoundLogQueue.Count : _logQueue.Count;
@@ -297,8 +297,7 @@ public sealed partial class AdminLogManager : SharedAdminLogManager, IAdminLogMa
Date = DateTime.UtcNow,
Message = message,
Json = json,
Players = new List<AdminLogPlayer>(players.Count),
Entities = entities
Players = new List<AdminLogPlayer>(players.Count)
};
foreach (var id in players)
@@ -331,10 +330,10 @@ public sealed partial class AdminLogManager : SharedAdminLogManager, IAdminLogMa
return;
}
var (json, players, entities) = ToJson(handler.Values);
var (json, players) = ToJson(handler.Values);
var message = handler.ToStringAndClear();
Add(type, impact, message, json, players, entities);
Add(type, impact, message, json, players);
}
public override void Add(LogType type, ref LogStringHandler handler)