feat(viewer-repo): add LoadForMatchContextAsync for battle-node ctx build
Focused AsNoTracking load with Info.SelectedEmblem/SelectedDegree includes for the new MatchContextBuilder. Single test locks the include graph. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -20,4 +20,11 @@ public interface IViewerRepository
|
||||
/// viewer's UDID to the target, then deletes the anonymous viewer.
|
||||
/// </summary>
|
||||
Task MergeAnonymousViewerInto(long anonymousViewerId, long targetViewerId);
|
||||
|
||||
/// <summary>
|
||||
/// Focused load for building a battle-node <c>MatchContext</c>: viewer + Info + Info's
|
||||
/// equipped Emblem/Degree nav refs. Read-only (AsNoTracking). Returns null if the viewer
|
||||
/// doesn't exist.
|
||||
/// </summary>
|
||||
Task<Models.Viewer?> LoadForMatchContextAsync(long viewerId);
|
||||
}
|
||||
|
||||
@@ -228,6 +228,15 @@ public class ViewerRepository : IViewerRepository
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task<Models.Viewer?> LoadForMatchContextAsync(long viewerId)
|
||||
{
|
||||
return await _dbContext.Set<Models.Viewer>()
|
||||
.AsNoTracking()
|
||||
.Include(v => v.Info.SelectedEmblem)
|
||||
.Include(v => v.Info.SelectedDegree)
|
||||
.FirstOrDefaultAsync(v => v.Id == viewerId);
|
||||
}
|
||||
|
||||
private async Task<Models.Viewer> BuildDefaultViewer(string displayName, int initialTutorialState = 1)
|
||||
{
|
||||
Models.Viewer viewer = new Models.Viewer
|
||||
|
||||
Reference in New Issue
Block a user