refactor(dotnet): separate collection read model service
Validators (Pushes and Pull Requests) / validate-ui-and-storage (push) Successful in 16s
Validators (Pushes and Pull Requests) / validate-core (push) Successful in 2m3s

This commit is contained in:
2026-07-13 00:44:43 +09:00
parent d610ecb57c
commit bccefed35e
6 changed files with 70 additions and 33 deletions
@@ -2,6 +2,7 @@ using System.IO;
using System.Reflection;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc.RazorPages;
using QuantEngine.Application.Interfaces;
using QuantEngine.Core.Interfaces;
using QuantEngine.Web.Services;
@@ -11,7 +12,7 @@ namespace QuantEngine.Web.Pages.Admin.Dashboard;
public class IndexModel : PageModel
{
private readonly IWorkspaceRepository _workspaceRepository;
private readonly ICollectionRepository _collectionRepository;
private readonly ICollectionReadModelService _collectionReadModelService;
private readonly IWebHostEnvironment _environment;
private readonly ILogger<IndexModel> _logger;
@@ -95,12 +96,12 @@ public class IndexModel : PageModel
public IndexModel(
IWorkspaceRepository workspaceRepository,
ICollectionRepository collectionRepository,
ICollectionReadModelService collectionReadModelService,
IWebHostEnvironment environment,
ILogger<IndexModel> logger)
{
_workspaceRepository = workspaceRepository;
_collectionRepository = collectionRepository;
_collectionReadModelService = collectionReadModelService;
_environment = environment;
_logger = logger;
}
@@ -112,7 +113,7 @@ public class IndexModel : PageModel
var accounts = await _workspaceRepository.GetAccountsAsync();
ActiveUsersCount = accounts.Count(a => string.Equals(a.IsActive, "true", StringComparison.OrdinalIgnoreCase));
var dashboard = await _collectionRepository.GetDashboardStateAsync();
var dashboard = await _collectionReadModelService.GetDashboardStateAsync();
RecentRunsCount = string.IsNullOrEmpty(dashboard?.LastRunId) ? 0 : 1;
// These two queries only complete if the DB round-trip actually