refactor(tutorial-presents): promote static catalogue to seed-driven TutorialPresentEntries table

The five tutorial gifts every fresh viewer is given at signup used to live as a
static C# array in SVSim.Database/SeedData/TutorialPresents.cs — outside the
seed-JSON pipeline used by all 40+ other globals tables. Editing a gift required
a code change + rebuild instead of a JSON edit + bootstrap re-run.

Now authored in SVSim.Bootstrap/Data/seeds/tutorial-presents.json and loaded into
a new TutorialPresentEntries table via TutorialPresentsImporter (clear-and-rewrite,
mirroring HomeDialogs). ViewerRepository.RegisterAnonymousViewer reads the table
at signup and projects each row into a ViewerPresent with Source="tutorial".

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-06-09 09:53:10 -04:00
parent 7118b92522
commit 998402ebc3
12 changed files with 4434 additions and 39 deletions

View File

@@ -3,7 +3,6 @@ using Npgsql;
using SVSim.Database.Enums;
using SVSim.Database.Models;
using SVSim.Database.Models.Config;
using SVSim.Database.SeedData;
using SVSim.Database.Services;
namespace SVSim.Database.Repositories.Viewer;
@@ -114,10 +113,17 @@ public class ViewerRepository : IViewerRepository
// Eager-seed the tutorial gifts so the inbox is populated by the time the tutorial
// walks the user to it (which happens AFTER initial battles, per the gift-inbox
// design). The unique (ViewerId, PresentId) index is the backstop against
// double-seeding on a retried signup. Both inserts commit in a single SaveChanges.
// design). The catalogue lives in TutorialPresentEntries (loaded from
// SVSim.Bootstrap/Data/seeds/tutorial-presents.json); if the catalogue is empty
// (bootstrap not run) signup still succeeds with an empty inbox. The unique
// (ViewerId, PresentId) index is the backstop against double-seeding on a retried
// signup. Both inserts commit in a single SaveChanges.
var tutorialPresents = await _dbContext.Set<TutorialPresentEntry>()
.AsNoTracking()
.OrderBy(p => p.PresentId)
.ToListAsync();
var createdAt = DateTime.UtcNow;
foreach (var spec in TutorialPresents.All)
foreach (var spec in tutorialPresents)
{
_dbContext.Set<ViewerPresent>().Add(new ViewerPresent
{