mirror of
https://github.com/9ParsonsB/Pulsar.git
synced 2025-04-12 14:54:44 -04:00
Update Faction handling
some database stuff in progress, to allow for complex querying of the journal
This commit is contained in:
parent
f5e6f63d73
commit
3846f0c8ef
@ -10,14 +10,14 @@ public class Loadout : JournalBase
|
|||||||
public ulong ShipID { get; init; }
|
public ulong ShipID { get; init; }
|
||||||
public string ShipName { get; init; }
|
public string ShipName { get; init; }
|
||||||
public string ShipIdent { get; init; }
|
public string ShipIdent { get; init; }
|
||||||
public int CargoCapacity { get; init; }
|
public int? CargoCapacity { get; init; }
|
||||||
public ulong HullValue { get; init; }
|
public ulong? HullValue { get; init; }
|
||||||
public ulong ModulesValue { get; init; }
|
public ulong? ModulesValue { get; init; }
|
||||||
public double HullHealth { get; init; }
|
public double? HullHealth { get; init; }
|
||||||
public double UnladenMass { get; init; }
|
public double? UnladenMass { get; init; }
|
||||||
public FuelCapacity FuelCapacity { get; init; }
|
public FuelCapacity? FuelCapacity { get; init; }
|
||||||
public double MaxJumpRange { get; init; }
|
public double? MaxJumpRange { get; init; }
|
||||||
public ulong Rebuy { get; init; }
|
public ulong? Rebuy { get; init; }
|
||||||
public bool Hot { get; init; }
|
public bool? Hot { get; init; }
|
||||||
public List<Modules> Modules { get; init; }
|
public List<Modules> Modules { get; init; }
|
||||||
}
|
}
|
@ -19,8 +19,8 @@ public class FSDJump : JournalBase
|
|||||||
public double FuelUsed { get; init; }
|
public double FuelUsed { get; init; }
|
||||||
public double FuelLevel { get; init; }
|
public double FuelLevel { get; init; }
|
||||||
public int BoostUsed { get; init; }
|
public int BoostUsed { get; init; }
|
||||||
[JsonConverter(typeof(LegacyFactionConverter<SystemFaction>))]
|
[JsonConverter(typeof(LegacyFactionConverter<Faction>))]
|
||||||
public SystemFaction SystemFaction { get; init; }
|
public Faction SystemFaction { get; init; }
|
||||||
|
|
||||||
public string SystemAllegiance { get; init; }
|
public string SystemAllegiance { get; init; }
|
||||||
public string SystemEconomy { get; init; }
|
public string SystemEconomy { get; init; }
|
||||||
@ -33,7 +33,7 @@ public class FSDJump : JournalBase
|
|||||||
public string SystemSecurity_Localised { get; init; }
|
public string SystemSecurity_Localised { get; init; }
|
||||||
public long Population { get; init; }
|
public long Population { get; init; }
|
||||||
public bool Wanted { get; init; }
|
public bool Wanted { get; init; }
|
||||||
public List<SystemFaction> Factions { get; init; }
|
public List<Faction> Factions { get; init; }
|
||||||
public List<Conflict> Conflicts { get; init; }
|
public List<Conflict> Conflicts { get; init; }
|
||||||
public IList<string> Powers { get; init; }
|
public IList<string> Powers { get; init; }
|
||||||
public string PowerplayState { get; init; }
|
public string PowerplayState { get; init; }
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Immutable;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using Observatory.Framework.Files.Converters;
|
using Observatory.Framework.Files.Converters;
|
||||||
using Observatory.Framework.Files.ParameterTypes;
|
using Observatory.Framework.Files.ParameterTypes;
|
||||||
@ -12,30 +13,30 @@ public class Location : JournalBase
|
|||||||
[JsonConverter(typeof(IntBoolFlexConverter))]
|
[JsonConverter(typeof(IntBoolFlexConverter))]
|
||||||
public bool Docked { get; init; }
|
public bool Docked { get; init; }
|
||||||
|
|
||||||
public double DistFromStarLS { get; init; }
|
public double? DistFromStarLS { get; init; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Name of the station at which this event occurred.
|
/// Name of the station at which this event occurred.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string StationName { get; init; }
|
public string? StationName { get; init; }
|
||||||
|
|
||||||
public string StationType { get; init; }
|
public string? StationType { get; init; }
|
||||||
public float Longitude { get; init; }
|
public float? Longitude { get; init; }
|
||||||
public float Latitude { get; init; }
|
public float? Latitude { get; init; }
|
||||||
public ulong MarketID { get; init; }
|
public ulong? MarketID { get; init; }
|
||||||
|
|
||||||
[JsonConverter(typeof(LegacyFactionConverter<Faction>))]
|
[JsonConverter(typeof(LegacyFactionConverter<Faction>))]
|
||||||
public Faction StationFaction { get; init; }
|
public Faction? StationFaction { get; init; }
|
||||||
|
|
||||||
public string StationGovernment { get; init; }
|
public string? StationGovernment { get; init; }
|
||||||
public string StationGovernment_Localised { get; init; }
|
public string? StationGovernment_Localised { get; init; }
|
||||||
public string StationAllegiance { get; init; }
|
public string? StationAllegiance { get; init; }
|
||||||
public IList<string> StationServices { get; init; }
|
public List<string>? StationServices { get; init; }
|
||||||
public string StationEconomy { get; init; }
|
public string? StationEconomy { get; init; }
|
||||||
public string StationEconomy_Localised { get; init; }
|
public string? StationEconomy_Localised { get; init; }
|
||||||
public List<StationEconomy> StationEconomies { get; init; }
|
public List<StationEconomy> StationEconomies { get; init; }
|
||||||
public string StarSystem { get; init; }
|
public string StarSystem { get; init; }
|
||||||
public ulong SystemAddress { get; init; }
|
public ulong? SystemAddress { get; init; }
|
||||||
|
|
||||||
[JsonConverter(typeof(StarPosConverter))]
|
[JsonConverter(typeof(StarPosConverter))]
|
||||||
public StarPos StarPos { get; init; }
|
public StarPos StarPos { get; init; }
|
||||||
@ -43,29 +44,30 @@ public class Location : JournalBase
|
|||||||
public string SystemAllegiance { get; init; }
|
public string SystemAllegiance { get; init; }
|
||||||
public string SystemEconomy { get; init; }
|
public string SystemEconomy { get; init; }
|
||||||
public string SystemEconomy_Localised { get; init; }
|
public string SystemEconomy_Localised { get; init; }
|
||||||
public string SystemSecondEconomy { get; init; }
|
public string? SystemSecondEconomy { get; init; }
|
||||||
public string SystemSecondEconomy_Localised { get; init; }
|
public string? SystemSecondEconomy_Localised { get; init; }
|
||||||
public string SystemGovernment { get; init; }
|
public string SystemGovernment { get; init; }
|
||||||
public string SystemGovernment_Localised { get; init; }
|
public string SystemGovernment_Localised { get; init; }
|
||||||
public string SystemSecurity { get; init; }
|
public string SystemSecurity { get; init; }
|
||||||
public string SystemSecurity_Localised { get; init; }
|
public string SystemSecurity_Localised { get; init; }
|
||||||
public long Population { get; init; }
|
public long? Population { get; init; }
|
||||||
public string Body { get; init; }
|
public string Body { get; init; }
|
||||||
public int BodyID { get; init; }
|
public int? BodyID { get; init; }
|
||||||
public string BodyType { get; init; }
|
public string BodyType { get; init; }
|
||||||
public List<DetailedFaction> Factions { get; init; }
|
public List<Faction>? Factions { get; init; }
|
||||||
|
|
||||||
[JsonConverter(typeof(LegacyFactionConverter<DetailedFaction>))]
|
[JsonConverter(typeof(LegacyFactionConverter<Faction>))]
|
||||||
public DetailedFaction SystemFaction { get; init; }
|
[NotMapped]
|
||||||
|
public Faction? SystemFaction { get; init; }
|
||||||
|
|
||||||
public List<Conflict> Conflicts { get; init; }
|
public List<Conflict>? Conflicts { get; init; }
|
||||||
public IList<string> Powers { get; init; }
|
public List<string>? Powers { get; init; }
|
||||||
public string PowerplayState { get; init; }
|
public string? PowerplayState { get; init; }
|
||||||
public bool Taxi { get; init; }
|
public bool? Taxi { get; init; }
|
||||||
public bool Multicrew { get; init; }
|
public bool? Multicrew { get; init; }
|
||||||
public bool OnFoot { get; init; }
|
public bool? OnFoot { get; init; }
|
||||||
public bool InSRV { get; init; }
|
public bool? InSRV { get; init; }
|
||||||
public ThargoidWar ThargoidWar { get; init; }
|
public ThargoidWar? ThargoidWar { get; init; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class StarPos
|
public class StarPos
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
using System.Collections.Immutable;
|
|
||||||
|
|
||||||
namespace Observatory.Framework.Files.ParameterTypes;
|
|
||||||
|
|
||||||
public class DetailedFaction : Faction
|
|
||||||
{
|
|
||||||
public string Government { get; init; }
|
|
||||||
public float Influence { get; init; }
|
|
||||||
public string Allegiance { get; init; }
|
|
||||||
public string Happiness { get; init; }
|
|
||||||
public string Happiness_Localised { get; init; }
|
|
||||||
public float MyReputation { get; init; }
|
|
||||||
public List<FactionStateTrend> RecoveringStates { get; init; }
|
|
||||||
public List<FactionState> ActiveStates { get; init; }
|
|
||||||
}
|
|
@ -3,6 +3,17 @@
|
|||||||
public class Faction
|
public class Faction
|
||||||
{
|
{
|
||||||
public string Name { get; init; }
|
public string Name { get; init; }
|
||||||
|
|
||||||
public string FactionState { get; init; }
|
public string FactionState { get; init; }
|
||||||
|
public string? Government { get; init; }
|
||||||
|
public float? Influence { get; init; }
|
||||||
|
public string? Allegiance { get; init; }
|
||||||
|
public string? Happiness { get; init; }
|
||||||
|
public string? Happiness_Localised { get; init; }
|
||||||
|
public float? MyReputation { get; init; }
|
||||||
|
public List<FactionStateTrend>? RecoveringStates { get; init; }
|
||||||
|
public List<FactionState>? ActiveStates { get; init; }
|
||||||
|
public List<FactionStateTrend>? PendingStates { get; init; }
|
||||||
|
public bool? SquadronFaction { get; init; }
|
||||||
|
public bool? HappiestSystem { get; init; }
|
||||||
|
public bool? HomeSystem { get; init; }
|
||||||
}
|
}
|
@ -3,6 +3,6 @@
|
|||||||
public class Material
|
public class Material
|
||||||
{
|
{
|
||||||
public string Name { get; init; }
|
public string Name { get; init; }
|
||||||
public string Name_Localised { get; init; }
|
public string? Name_Localised { get; init; }
|
||||||
public int Count { get; init; }
|
public int Count { get; init; }
|
||||||
}
|
}
|
@ -32,6 +32,12 @@ public class NumberOrString
|
|||||||
DoubleValue = value;
|
DoubleValue = value;
|
||||||
IsDouble = true;
|
IsDouble = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return IsString ? StringValue : DoubleValue.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
public string? StringValue { get; init; }
|
public string? StringValue { get; init; }
|
||||||
public bool IsString { get; init; }
|
public bool IsString { get; init; }
|
||||||
public double? DoubleValue { get; init; }
|
public double? DoubleValue { get; init; }
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
using System.Collections.Immutable;
|
|
||||||
|
|
||||||
namespace Observatory.Framework.Files.ParameterTypes;
|
|
||||||
|
|
||||||
public class SystemFaction : Faction
|
|
||||||
{
|
|
||||||
public string Government { get; init; }
|
|
||||||
|
|
||||||
public double Influence { get; init; }
|
|
||||||
|
|
||||||
public string Happiness { get; init; }
|
|
||||||
|
|
||||||
public string Happiness_Localised { get; init; }
|
|
||||||
|
|
||||||
public double MyReputation { get; init; }
|
|
||||||
|
|
||||||
public List<FactionStateTrend> PendingStates { get; init; }
|
|
||||||
|
|
||||||
public List<FactionStateTrend> RecoveringStates { get; init; }
|
|
||||||
|
|
||||||
public List<FactionState> ActiveStates { get; init; }
|
|
||||||
|
|
||||||
public bool? SquadronFaction { get; init; }
|
|
||||||
|
|
||||||
public bool? HappiestSystem { get; init; }
|
|
||||||
|
|
||||||
public bool? HomeSystem { get; init; }
|
|
||||||
}
|
|
@ -2,6 +2,7 @@ namespace Pulsar.Features.Journal;
|
|||||||
|
|
||||||
using Observatory.Framework;
|
using Observatory.Framework;
|
||||||
using Observatory.Framework.Files.Journal;
|
using Observatory.Framework.Files.Journal;
|
||||||
|
using Observatory.Framework.Files.Journal.Travel;
|
||||||
using Observatory.Framework.Files.Journal.Startup;
|
using Observatory.Framework.Files.Journal.Startup;
|
||||||
using Observatory.Framework.Files.Journal.StationServices;
|
using Observatory.Framework.Files.Journal.StationServices;
|
||||||
|
|
||||||
@ -43,9 +44,10 @@ public class JournalProcessor(
|
|||||||
line = newLine;
|
line = newLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JournalBase? journal = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var journal = JsonSerializer.Deserialize<JournalBase>(new ReadOnlySpan<byte>(line.ToArray()), options);
|
journal = JsonSerializer.Deserialize<JournalBase>(new ReadOnlySpan<byte>(line.ToArray()), options);
|
||||||
if (journal == null)
|
if (journal == null)
|
||||||
{
|
{
|
||||||
//return ValueTask.CompletedTask;
|
//return ValueTask.CompletedTask;
|
||||||
@ -84,7 +86,6 @@ public class JournalProcessor(
|
|||||||
await context.Reputation.AddAsync(reputation, token);
|
await context.Reputation.AddAsync(reputation, token);
|
||||||
await context.SaveChangesAsync(token);
|
await context.SaveChangesAsync(token);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EngineerProgress engineerProgress
|
case EngineerProgress engineerProgress
|
||||||
when context.EngineerProgress.Any(e => e.Timestamp == engineerProgress.Timestamp):
|
when context.EngineerProgress.Any(e => e.Timestamp == engineerProgress.Timestamp):
|
||||||
continue;
|
continue;
|
||||||
@ -98,15 +99,30 @@ public class JournalProcessor(
|
|||||||
await context.LoadGames.AddAsync(loadGame, token);
|
await context.LoadGames.AddAsync(loadGame, token);
|
||||||
await context.SaveChangesAsync(token);
|
await context.SaveChangesAsync(token);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case Statistics statistics when context.Statistics.Any(s => s.Timestamp == statistics.Timestamp):
|
case Statistics statistics when context.Statistics.Any(s => s.Timestamp == statistics.Timestamp):
|
||||||
continue;
|
continue;
|
||||||
case Statistics statistics:
|
case Statistics statistics:
|
||||||
await context.Statistics.AddAsync(statistics, token);
|
await context.Statistics.AddAsync(statistics, token);
|
||||||
await context.SaveChangesAsync(token);
|
await context.SaveChangesAsync(token);
|
||||||
break;
|
break;
|
||||||
|
case Missions missions when context.Missions.Any(m => m.Timestamp == missions.Timestamp):
|
||||||
|
continue;
|
||||||
|
case Missions missions:
|
||||||
|
await context.Missions.AddAsync(missions, token);
|
||||||
|
await context.SaveChangesAsync(token);
|
||||||
|
break;
|
||||||
|
case Location location when context.Locations.Any(l => l.Timestamp == location.Timestamp):
|
||||||
|
continue;
|
||||||
|
case Location location:
|
||||||
|
await context.Locations.AddAsync(location, token);
|
||||||
|
await context.SaveChangesAsync(token);
|
||||||
|
break;
|
||||||
|
case Loadout loadout when context.Loadout.Any(l => l.Timestamp == loadout.Timestamp):
|
||||||
|
continue;
|
||||||
|
case Loadout loadout:
|
||||||
|
await context.Loadout.AddAsync(loadout, token);
|
||||||
|
await context.SaveChangesAsync(token);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
newJournals.Add(journal);
|
newJournals.Add(journal);
|
||||||
@ -115,10 +131,14 @@ public class JournalProcessor(
|
|||||||
{
|
{
|
||||||
logger.LogError(ex, "Error deserializing journal file: '{File}', line: {Line}", filePath, line);
|
logger.LogError(ex, "Error deserializing journal file: '{File}', line: {Line}", filePath, line);
|
||||||
}
|
}
|
||||||
|
catch (DbUpdateException ex)
|
||||||
|
{
|
||||||
|
logger.LogError(ex, "Error updating database with journal file: '{File}', line: {Line}", filePath, line);
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
logger.LogError(ex, "Error processing journal file: '{File}', line# {LineNumber}, line: {Line}",
|
logger.LogError(ex, "Error processing journal file: '{File}', line# {LineNumber}, line: {Line}, type?: {Type}",
|
||||||
filePath, index, Encoding.UTF8.GetString(line.ToArray()));
|
filePath, index, Encoding.UTF8.GetString(line.ToArray()), journal?.GetType());
|
||||||
}
|
}
|
||||||
|
|
||||||
//return ValueTask.CompletedTask;
|
//return ValueTask.CompletedTask;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user