feat(missions): /load/index materializes viewer mission/achievement state

EnsureCurrentAsync now takes viewerId (was Viewer), so it works with
LoadController's AsNoTracking-loaded detached viewers.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-05-27 10:45:31 -04:00
parent 640a77ec6c
commit 5693ec0302
6 changed files with 27 additions and 18 deletions

View File

@@ -44,7 +44,7 @@ public class ViewerMissionStateServiceTests
.FirstAsync(x => x.Id == vid);
var svc = scope.ServiceProvider.GetRequiredService<IViewerMissionStateService>();
await svc.EnsureCurrentAsync(viewer);
await svc.EnsureCurrentAsync(viewer.Id);
await db.SaveChangesAsync();
int catalogTypeCount = await db.AchievementCatalog
@@ -67,10 +67,10 @@ public class ViewerMissionStateServiceTests
.FirstAsync(x => x.Id == vid);
var svc = scope.ServiceProvider.GetRequiredService<IViewerMissionStateService>();
await svc.EnsureCurrentAsync(viewer);
await svc.EnsureCurrentAsync(viewer.Id);
await db.SaveChangesAsync();
int after1 = await db.ViewerAchievements.CountAsync(a => a.ViewerId == vid);
await svc.EnsureCurrentAsync(viewer);
await svc.EnsureCurrentAsync(viewer.Id);
await db.SaveChangesAsync();
int after2 = await db.ViewerAchievements.CountAsync(a => a.ViewerId == vid);
Assert.That(after2, Is.EqualTo(after1));
@@ -90,7 +90,7 @@ public class ViewerMissionStateServiceTests
.FirstAsync(x => x.Id == vid);
var svc = scope.ServiceProvider.GetRequiredService<IViewerMissionStateService>();
await svc.EnsureCurrentAsync(viewer);
await svc.EnsureCurrentAsync(viewer.Id);
await db.SaveChangesAsync();
var slots = await db.ViewerMissions
@@ -117,7 +117,7 @@ public class ViewerMissionStateServiceTests
.FirstAsync(x => x.Id == vid);
var svc = scope.ServiceProvider.GetRequiredService<IViewerMissionStateService>();
await svc.EnsureCurrentAsync(viewer);
await svc.EnsureCurrentAsync(viewer.Id);
await db.SaveChangesAsync();
var weeklyIds = await db.ViewerMissions