feat(packs): PackImporter stubs pass + IsEnabled gate in active-packs
PackImporter now runs a second pass over pack-stubs.json, inserting PackConfigEntry placeholders for any pack_id NOT already present from the live-capture packs.json pass. Synthesized stubs default IsEnabled=false; live-capture rows default IsEnabled=true. PackRepository.GetActivePacks filters by IsEnabled in addition to the date window, so synthesized stubs stay hidden until an operator opts them in (UPDATE Packs SET IsEnabled=true WHERE Id=...). Bundles Task 6 + Task 11 because adding pack-stubs.json to the test-fixture set surfaces an extra row in PackControllerFullCatalogTests' 35-pack count assertion; the filter is what makes the test resilient. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
54
SVSim.Bootstrap/Data/test-fixtures/seeds/pack-stubs.json
Normal file
54
SVSim.Bootstrap/Data/test-fixtures/seeds/pack-stubs.json
Normal file
@@ -0,0 +1,54 @@
|
||||
[
|
||||
{
|
||||
"parent_gacha_id": 10001,
|
||||
"base_pack_id": 10001,
|
||||
"gacha_type": 1,
|
||||
"pack_category": 0,
|
||||
"poster_type": 0,
|
||||
"commence_date": "2016-06-17 00:00:00",
|
||||
"complete_date": "2026-06-30 23:59:59",
|
||||
"sleeve_id": 0,
|
||||
"special_sleeve_id": 0,
|
||||
"override_draw_effect_pack_id": 0,
|
||||
"override_ui_effect_pack_id": 0,
|
||||
"gacha_detail": "STUB CLC",
|
||||
"is_hide": false,
|
||||
"is_new": false,
|
||||
"is_pre_release": false,
|
||||
"open_count_limit": 0,
|
||||
"sales_period_time": null,
|
||||
"gacha_point": null,
|
||||
"child_gachas": [
|
||||
{ "gacha_id": 100011, "type_detail": 2, "cost": 200, "card_count": 1 },
|
||||
{ "gacha_id": 100012, "type_detail": 2, "cost": 1800, "card_count": 10 }
|
||||
],
|
||||
"banners": [],
|
||||
"is_enabled": false
|
||||
},
|
||||
{
|
||||
"parent_gacha_id": 95001,
|
||||
"base_pack_id": 95001,
|
||||
"gacha_type": 1,
|
||||
"pack_category": 2,
|
||||
"poster_type": 0,
|
||||
"commence_date": "2016-06-17 00:00:00",
|
||||
"complete_date": "2026-06-30 23:59:59",
|
||||
"sleeve_id": 0,
|
||||
"special_sleeve_id": 0,
|
||||
"override_draw_effect_pack_id": 0,
|
||||
"override_ui_effect_pack_id": 0,
|
||||
"gacha_detail": "7th Anniv stub",
|
||||
"is_hide": false,
|
||||
"is_new": false,
|
||||
"is_pre_release": false,
|
||||
"open_count_limit": 0,
|
||||
"sales_period_time": null,
|
||||
"gacha_point": null,
|
||||
"child_gachas": [
|
||||
{ "gacha_id": 950011, "type_detail": 2, "cost": 200, "card_count": 1 },
|
||||
{ "gacha_id": 950012, "type_detail": 2, "cost": 1800, "card_count": 10 }
|
||||
],
|
||||
"banners": [],
|
||||
"is_enabled": false
|
||||
}
|
||||
]
|
||||
@@ -61,6 +61,7 @@ public class PackImporter
|
||||
ExchangeablePoint = s.GachaPoint.ExchangeablePoint,
|
||||
IncreaseGachaPoint = s.GachaPoint.IncreaseGachaPoint,
|
||||
};
|
||||
pack.IsEnabled = s.IsEnabled;
|
||||
|
||||
// Owned collections -- clear and rehydrate (matches the previous wholesale-replace semantics).
|
||||
pack.ChildGachas.Clear();
|
||||
@@ -101,7 +102,75 @@ public class PackImporter
|
||||
}
|
||||
|
||||
await context.SaveChangesAsync();
|
||||
Console.WriteLine($"[PackImporter] +{created}/~{updated}");
|
||||
return created + updated;
|
||||
Console.WriteLine($"[PackImporter] capture: +{created}/~{updated}");
|
||||
|
||||
// Second pass: synthesized stubs from pack-stubs.json. Skip any pack_id that already
|
||||
// exists from the live-capture pass (capture wins on conflict).
|
||||
var stubs = SeedLoader.LoadList<PackSeed>(Path.Combine(seedDir, "pack-stubs.json"));
|
||||
int stubsAdded = 0;
|
||||
foreach (var s in stubs)
|
||||
{
|
||||
if (s.ParentGachaId == 0) continue;
|
||||
if (existing.ContainsKey(s.ParentGachaId)) continue;
|
||||
|
||||
var pack = new PackConfigEntry
|
||||
{
|
||||
Id = s.ParentGachaId,
|
||||
BasePackId = s.BasePackId,
|
||||
GachaType = s.GachaType,
|
||||
PackCategory = (PackCategory)s.PackCategory,
|
||||
PosterType = s.PosterType,
|
||||
CommenceDate = ParseWireDateTime(s.CommenceDate),
|
||||
CompleteDate = ParseWireDateTime(s.CompleteDate),
|
||||
SleeveId = s.SleeveId,
|
||||
SpecialSleeveId = s.SpecialSleeveId,
|
||||
OverrideDrawEffectPackId = s.OverrideDrawEffectPackId,
|
||||
OverrideUiEffectPackId = s.OverrideUiEffectPackId,
|
||||
GachaDetail = s.GachaDetail,
|
||||
IsHide = s.IsHide,
|
||||
IsNew = s.IsNew,
|
||||
IsPreRelease = s.IsPreRelease,
|
||||
OpenCountLimit = s.OpenCountLimit,
|
||||
SalesPeriodTime = string.IsNullOrEmpty(s.SalesPeriodTime) ? null : ParseWireDateTime(s.SalesPeriodTime),
|
||||
GachaPointConfig = s.GachaPoint is null ? null : new PackGachaPointConfig
|
||||
{
|
||||
ExchangeablePoint = s.GachaPoint.ExchangeablePoint,
|
||||
IncreaseGachaPoint = s.GachaPoint.IncreaseGachaPoint,
|
||||
},
|
||||
IsEnabled = s.IsEnabled,
|
||||
};
|
||||
foreach (var c in s.ChildGachas)
|
||||
{
|
||||
pack.ChildGachas.Add(new PackChildGachaEntry
|
||||
{
|
||||
GachaId = c.GachaId,
|
||||
TypeDetail = c.TypeDetail,
|
||||
Cost = c.Cost,
|
||||
CardCount = c.CardCount,
|
||||
ItemId = c.ItemId,
|
||||
IsDailySingle = c.IsDailySingle,
|
||||
OverrideIncreaseGachaPoint = c.OverrideIncreaseGachaPoint,
|
||||
PurchaseLimitCount = c.PurchaseLimitCount,
|
||||
FreeGachaCampaignId = c.FreeGachaCampaignId,
|
||||
CampaignName = c.CampaignName,
|
||||
});
|
||||
}
|
||||
foreach (var b in s.Banners)
|
||||
{
|
||||
pack.Banners.Add(new PackBannerEntry
|
||||
{
|
||||
BannerName = b.BannerName,
|
||||
DialogTitle = b.DialogTitle,
|
||||
});
|
||||
}
|
||||
context.Packs.Add(pack);
|
||||
existing[s.ParentGachaId] = pack;
|
||||
stubsAdded++;
|
||||
}
|
||||
|
||||
await context.SaveChangesAsync();
|
||||
Console.WriteLine($"[PackImporter] stubs: +{stubsAdded}");
|
||||
|
||||
return created + updated + stubsAdded;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user