From 82dc877639df76a8613e4e1d984c6cefe1476d9a Mon Sep 17 00:00:00 2001 From: gamer147 Date: Tue, 9 Jun 2026 14:13:56 -0400 Subject: [PATCH] feat(inventory): add Source to InventoryLoadConfig MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a `GrantSource Source { get; set; }` property (defaults to `GrantSource.Unknown`) to `InventoryLoadConfig`. Plumbing-only — no behavior change; callers that don't set `Source` get Unknown rows, greppable via `acquire_type=0` in dev. Co-Authored-By: Claude Sonnet 4.6 --- .../Services/Inventory/InventoryLoadConfig.cs | 12 ++++++++++++ .../Services/Inventory/InventoryHistoryTests.cs | 14 ++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/SVSim.Database/Services/Inventory/InventoryLoadConfig.cs b/SVSim.Database/Services/Inventory/InventoryLoadConfig.cs index b11997c..f9b4c51 100644 --- a/SVSim.Database/Services/Inventory/InventoryLoadConfig.cs +++ b/SVSim.Database/Services/Inventory/InventoryLoadConfig.cs @@ -9,11 +9,23 @@ namespace SVSim.Database.Services.Inventory; /// Caller-supplied extra .Include chains on top of the canonical viewer-inventory query /// in . Use to bring in extra collections needed by /// the calling controller (e.g. MissionData, BuildDeckPurchases). +/// +/// Also carries the tag that +/// stamps onto every viewer_acquire_history row written from this transaction. Callers +/// that don't set end up with rows; +/// grep for acquire_type=0 in dev to find unmigrated sites. +/// /// public sealed class InventoryLoadConfig { internal List, IQueryable>> Includes { get; } = new(); + /// + /// Logical source of every grant queued in this transaction. Defaults to + /// . + /// + public GrantSource Source { get; set; } = GrantSource.Unknown; + public InventoryLoadConfig WithInclude( Expression> path) { diff --git a/SVSim.UnitTests/Services/Inventory/InventoryHistoryTests.cs b/SVSim.UnitTests/Services/Inventory/InventoryHistoryTests.cs index 65d9dce..8e98bbf 100644 --- a/SVSim.UnitTests/Services/Inventory/InventoryHistoryTests.cs +++ b/SVSim.UnitTests/Services/Inventory/InventoryHistoryTests.cs @@ -23,4 +23,18 @@ public class InventoryHistoryTests $"GrantSource.{source} has no message defined."); } } + + [Test] + public void InventoryLoadConfig_Source_defaults_to_Unknown() + { + var cfg = new InventoryLoadConfig(); + Assert.That(cfg.Source, Is.EqualTo(GrantSource.Unknown)); + } + + [Test] + public void InventoryLoadConfig_Source_is_assignable() + { + var cfg = new InventoryLoadConfig { Source = GrantSource.PackOpen }; + Assert.That(cfg.Source, Is.EqualTo(GrantSource.PackOpen)); + } }