refactor(bp): flatten BattlePassLevelEntry — drop misnamed RewardData jsonb
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
using System.Text.Json;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SVSim.Bootstrap.Models.Seed;
|
||||
using SVSim.Database;
|
||||
@@ -8,7 +7,7 @@ namespace SVSim.Bootstrap.Importers;
|
||||
|
||||
/// <summary>
|
||||
/// Idempotent upsert of battle-pass level rows from <c>seeds/battle-pass-levels.json</c>.
|
||||
/// Per-level <c>reward_data</c> blob preserved verbatim (shape varies per level).
|
||||
/// Curve is global; rows missing from the seed are LEFT INTACT.
|
||||
/// </summary>
|
||||
public class BattlePassImporter
|
||||
{
|
||||
@@ -21,12 +20,10 @@ public class BattlePassImporter
|
||||
int created = 0, updated = 0;
|
||||
foreach (var s in seed)
|
||||
{
|
||||
if (s.Id == 0) continue;
|
||||
var entry = existing.TryGetValue(s.Id, out var ex) ? ex : new BattlePassLevelEntry { Id = s.Id };
|
||||
entry.RewardData = s.RewardData.ValueKind == JsonValueKind.Undefined
|
||||
? "{}"
|
||||
: JsonSerializer.Serialize(s.RewardData);
|
||||
if (ex is null) { context.BattlePassLevels.Add(entry); existing[s.Id] = entry; created++; }
|
||||
if (s.Level == 0) continue;
|
||||
var entry = existing.TryGetValue(s.Level, out var ex) ? ex : new BattlePassLevelEntry { Level = s.Level };
|
||||
entry.RequiredPoint = s.RequiredPoint;
|
||||
if (ex is null) { context.BattlePassLevels.Add(entry); existing[s.Level] = entry; created++; }
|
||||
else updated++;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user