feat(inventory): add Source to InventoryLoadConfig

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 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-06-09 14:13:56 -04:00
parent 645c32e11c
commit 82dc877639
2 changed files with 26 additions and 0 deletions

View File

@@ -9,11 +9,23 @@ namespace SVSim.Database.Services.Inventory;
/// Caller-supplied extra <c>.Include</c> chains on top of the canonical viewer-inventory query
/// in <see cref="IInventoryService.BeginAsync"/>. Use to bring in extra collections needed by
/// the calling controller (e.g. <c>MissionData</c>, <c>BuildDeckPurchases</c>).
/// <para>
/// Also carries the <see cref="Source"/> tag that <see cref="IInventoryTransaction.CommitAsync"/>
/// stamps onto every <c>viewer_acquire_history</c> row written from this transaction. Callers
/// that don't set <see cref="Source"/> end up with <see cref="GrantSource.Unknown"/> rows;
/// grep for <c>acquire_type=0</c> in dev to find unmigrated sites.
/// </para>
/// </summary>
public sealed class InventoryLoadConfig
{
internal List<Func<IQueryable<Viewer>, IQueryable<Viewer>>> Includes { get; } = new();
/// <summary>
/// Logical source of every grant queued in this transaction. Defaults to
/// <see cref="GrantSource.Unknown"/>.
/// </summary>
public GrantSource Source { get; set; } = GrantSource.Unknown;
public InventoryLoadConfig WithInclude<TProperty>(
Expression<Func<Viewer, TProperty>> path)
{

View File

@@ -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));
}
}