fix(guild): populate leader_name in search results (matches prod capture)
Add IViewerRepository.LoadDisplayNamesAsync (batch AsNoTracking select), extend GuildSearchEntry with LeaderName, enrich GuildService.SearchAsync with a leader-id batch lookup, and thread the name through the controller's ToDetailDto call. Adds a leader_name assertion to GuildSearchFlowTests. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -286,6 +286,16 @@ public class ViewerRepository : IViewerRepository
|
||||
await _dbContext.SaveChangesAsync(ct);
|
||||
}
|
||||
|
||||
public async Task<Dictionary<long, string>> LoadDisplayNamesAsync(IReadOnlyCollection<long> viewerIds, CancellationToken ct = default)
|
||||
{
|
||||
if (viewerIds.Count == 0) return new Dictionary<long, string>();
|
||||
return await _dbContext.Set<Models.Viewer>()
|
||||
.AsNoTracking()
|
||||
.Where(v => viewerIds.Contains(v.Id))
|
||||
.Select(v => new { v.Id, v.DisplayName })
|
||||
.ToDictionaryAsync(v => v.Id, v => v.DisplayName, ct);
|
||||
}
|
||||
|
||||
private async Task<Models.Viewer> BuildDefaultViewer(string displayName, int initialTutorialState = 1)
|
||||
{
|
||||
Models.Viewer viewer = new Models.Viewer
|
||||
|
||||
Reference in New Issue
Block a user