Include 'world' in tags

This commit is contained in:
Liza 2024-04-27 14:16:49 +02:00
parent 06b2085638
commit 6c5aedc99f
Signed by: liza
GPG Key ID: 7199F8D727D55F67
5 changed files with 14 additions and 1 deletions

View File

@ -21,6 +21,7 @@ internal sealed class Character
ClassJob = (byte)_delegate.GetType().GetField("ClassJob")!.GetValue(_delegate)!;
OwnerId = (ulong)_delegate.GetType().GetField("OwnerId")!.GetValue(_delegate)!;
FreeCompanyId = (ulong)_delegate.GetType().GetField("FreeCompanyId")!.GetValue(_delegate)!;
WorldId = (uint)_delegate.GetType().GetField("WorldId")!.GetValue(_delegate)!;
}
public ulong CharacterId { get; }
@ -28,6 +29,7 @@ internal sealed class Character
public byte ClassJob { get; }
public ulong OwnerId { get; }
public ulong FreeCompanyId { get; }
public uint WorldId { get; }
public string Name => (string)_name.GetValue(_delegate)!;
public uint Level => (uint)_level.GetValue(_delegate)!;
}

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<Version>0.14</Version>
<Version>0.15</Version>
<LangVersion>12</LangVersion>
<Nullable>enable</Nullable>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

View File

@ -26,6 +26,7 @@ internal sealed class InfluxStatisticsClient : IDisposable
private readonly IReadOnlyDictionary<byte, string> _classJobNames;
private readonly IReadOnlyDictionary<sbyte, ClassJobDetail> _expToJobs;
private readonly ReadOnlyDictionary<uint, PriceInfo> _prices;
private readonly ReadOnlyDictionary<uint, string> _worldNames;
public InfluxStatisticsClient(IChatGui chatGui, Configuration configuration, IDataManager dataManager,
IClientState clientState, IPluginLog pluginLog)
@ -53,6 +54,10 @@ internal sealed class InfluxStatisticsClient : IDisposable
UiCategory = x.ItemUICategory.Row,
})
.AsReadOnly();
_worldNames = dataManager.GetExcelSheet<World>()!
.Where(x => x.RowId > 0 && x.IsPublic)
.ToDictionary(x => x.RowId, x => x.Name.ToString())
.AsReadOnly();
}
public bool Enabled => _configuration.Server.Enabled &&
@ -118,6 +123,7 @@ internal sealed class InfluxStatisticsClient : IDisposable
{
values.Add(PointData.Measurement("submersibles")
.Tag("id", fc.CharacterId.ToString(CultureInfo.InvariantCulture))
.Tag("world", _worldNames[fc.WorldId])
.Tag("fc_name", fc.Name)
.Tag("sub_id", $"{fc.CharacterId}_{sub.Id}")
.Tag("sub_name", sub.Name)
@ -164,6 +170,7 @@ internal sealed class InfluxStatisticsClient : IDisposable
Func<string, PointData> pointData = s => PointData.Measurement(s)
.Tag("id", character.CharacterId.ToString(CultureInfo.InvariantCulture))
.Tag("player_name", character.Name)
.Tag("world", _worldNames[character.WorldId])
.Tag("type", character.CharacterType.ToString())
.Tag("fc_id", includeFc ? character.FreeCompanyId.ToString(CultureInfo.InvariantCulture) : null)
.Timestamp(date, WritePrecision.S);
@ -242,6 +249,7 @@ internal sealed class InfluxStatisticsClient : IDisposable
.Tag("id", character.CharacterId.ToString(CultureInfo.InvariantCulture))
.Tag("player_name", owner.Name)
.Tag("player_id", character.OwnerId.ToString(CultureInfo.InvariantCulture))
.Tag("world", _worldNames[character.WorldId])
.Tag("type", character.CharacterType.ToString())
.Tag("retainer_name", character.Name)
.Timestamp(date, WritePrecision.S);
@ -306,6 +314,7 @@ internal sealed class InfluxStatisticsClient : IDisposable
Func<string, PointData> pointData = s => PointData.Measurement(s)
.Tag("id", character.CharacterId.ToString(CultureInfo.InvariantCulture))
.Tag("fc_name", character.Name)
.Tag("world", _worldNames[character.WorldId])
.Tag("type", character.CharacterType.ToString())
.Timestamp(date, WritePrecision.S);

View File

@ -6,6 +6,7 @@ internal sealed class SubmarineStats
{
public required string Name { get; init; }
public required int Id { get; init; }
public required uint WorldId { get; init; }
public bool Enabled { get; set; } = true;
public required ushort Level { get; init; }
public required ushort PredictedLevel { get; init; }

View File

@ -48,6 +48,7 @@ internal sealed class SubmarineTrackerIpc
{
Id = x.Subs.IndexOf(y),
Name = y.Name,
WorldId = x.Fc!.WorldId,
Level = y.Level,
PredictedLevel = y.PredictedLevel,
Hull = y.Build.HullIdentifier,