refactor(dotnet): remove aggregate collection repository contract
This commit is contained in:
@@ -12,12 +12,12 @@ namespace QuantEngine.Application.Services;
|
||||
public sealed class JsonSeedIngestionService
|
||||
{
|
||||
private readonly GatherTradingDataParser _parser;
|
||||
private readonly ICollectionRepository _repository;
|
||||
private readonly ICollectionWriteRepository _repository;
|
||||
private readonly ILogger<JsonSeedIngestionService> _logger;
|
||||
|
||||
public JsonSeedIngestionService(
|
||||
GatherTradingDataParser parser,
|
||||
ICollectionRepository repository,
|
||||
ICollectionWriteRepository repository,
|
||||
ILogger<JsonSeedIngestionService> logger)
|
||||
{
|
||||
_parser = parser;
|
||||
|
||||
@@ -24,9 +24,8 @@ public class KisDataCollectionOrchestratorTests
|
||||
public KisDataCollectionOrchestratorTests()
|
||||
{
|
||||
_kisApiClientMock = new Mock<IKisApiClient>();
|
||||
var repositoryMock = new Mock<ICollectionRepository>();
|
||||
_writeRepositoryMock = repositoryMock.As<ICollectionWriteRepository>();
|
||||
_readRepositoryMock = repositoryMock.As<ICollectionReadRepository>();
|
||||
_writeRepositoryMock = new Mock<ICollectionWriteRepository>();
|
||||
_readRepositoryMock = new Mock<ICollectionReadRepository>();
|
||||
_loggerMock = new Mock<ILogger<KisDataCollectionOrchestrator>>();
|
||||
_auditTrailMock = new Mock<IRuntimeAuditTrailService>();
|
||||
_priorityResolver = new SourcePriorityResolver();
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
namespace QuantEngine.Core.Interfaces;
|
||||
|
||||
/// <summary>
|
||||
/// Data collection repository (Dapper + PostgreSQL).
|
||||
/// Higher-level abstraction over IDataCollectionStore for Web API consumers.
|
||||
/// </summary>
|
||||
public interface ICollectionRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// Save new collection run.
|
||||
/// </summary>
|
||||
Task SaveRunAsync(CollectionRunRecord run);
|
||||
|
||||
/// <summary>
|
||||
/// Update run with completion status.
|
||||
/// </summary>
|
||||
Task UpdateRunStatusAsync(string runId, string status, string? finishedAt = null, int? totalSnapshots = null, int? totalErrors = null);
|
||||
|
||||
/// <summary>
|
||||
/// Save collection snapshot.
|
||||
/// </summary>
|
||||
Task SaveSnapshotAsync(CollectionSnapshotRecord snapshot);
|
||||
|
||||
/// <summary>
|
||||
/// Save collection error.
|
||||
/// </summary>
|
||||
Task SaveErrorAsync(CollectionErrorRecord error);
|
||||
|
||||
/// <summary>
|
||||
/// Fetch recent collection runs for UI dashboard.
|
||||
/// </summary>
|
||||
/// <param name="limit">Number of runs to return (default: 20)</param>
|
||||
Task<List<CollectionRunRecord>> GetRecentRunsAsync(int limit = 20);
|
||||
|
||||
/// <summary>
|
||||
/// Fetch snapshots for a specific run.
|
||||
/// </summary>
|
||||
Task<List<CollectionSnapshotRecord>> GetRunSnapshotsAsync(string runId);
|
||||
|
||||
/// <summary>
|
||||
/// Fetch errors for a specific run.
|
||||
/// </summary>
|
||||
/// <param name="runId">Run ID</param>
|
||||
/// <param name="limit">Max errors to return (default: 50)</param>
|
||||
Task<List<CollectionErrorRecord>> GetRunErrorsAsync(string runId, int limit = 50);
|
||||
|
||||
/// <summary>
|
||||
/// Get collection pipeline dashboard state for Web UI.
|
||||
/// </summary>
|
||||
Task<CollectionDashboardStateRecord> GetDashboardStateAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Fetch latest snapshots for a ticker across all datasets.
|
||||
/// </summary>
|
||||
Task<List<CollectionSnapshotRecord>> GetLatestSnapshotsForTickerAsync(string ticker, int limit = 10);
|
||||
|
||||
/// <summary>
|
||||
/// Save daily price history bar (OHLCV). Idempotent via ON CONFLICT DO NOTHING.
|
||||
/// </summary>
|
||||
Task SavePriceHistoryDailyAsync(PriceHistoryDailyRecord record);
|
||||
|
||||
/// <summary>
|
||||
/// Get price history summary per ticker (row count, first/last dates).
|
||||
/// </summary>
|
||||
Task<List<PriceHistorySummaryRecord>> GetPriceHistorySummaryAsync();
|
||||
}
|
||||
@@ -8,7 +8,7 @@ using QuantEngine.Infrastructure.Data;
|
||||
|
||||
namespace QuantEngine.Infrastructure.Repositories
|
||||
{
|
||||
public class CollectionRepository : ICollectionRepository, ICollectionReadRepository, ICollectionWriteRepository
|
||||
public class CollectionRepository : ICollectionReadRepository, ICollectionWriteRepository
|
||||
{
|
||||
private readonly IDbConnectionFactory _connectionFactory;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using QuantEngine.Core.Interfaces;
|
||||
using QuantEngine.Application.Interfaces;
|
||||
using QuantEngine.Web.Services;
|
||||
|
||||
namespace QuantEngine.Web.Pages.Admin.Collection;
|
||||
@@ -9,12 +10,12 @@ namespace QuantEngine.Web.Pages.Admin.Collection;
|
||||
[Authorize(AuthenticationSchemes = AdminAuthDefaults.Scheme)]
|
||||
public class DetailModel : PageModel
|
||||
{
|
||||
private readonly ICollectionRepository _collectionRepository;
|
||||
private readonly ICollectionReadRepository _collectionRepository;
|
||||
private readonly ILogger<DetailModel> _logger;
|
||||
|
||||
public CollectionRunRecord? Run { get; set; }
|
||||
|
||||
public DetailModel(ICollectionRepository collectionRepository, ILogger<DetailModel> logger)
|
||||
public DetailModel(ICollectionReadRepository collectionRepository, ILogger<DetailModel> logger)
|
||||
{
|
||||
_collectionRepository = collectionRepository;
|
||||
_logger = logger;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using QuantEngine.Core.Interfaces;
|
||||
using QuantEngine.Application.Interfaces;
|
||||
using QuantEngine.Web.Services;
|
||||
|
||||
namespace QuantEngine.Web.Pages.Admin.Collection;
|
||||
@@ -8,13 +9,13 @@ namespace QuantEngine.Web.Pages.Admin.Collection;
|
||||
[Authorize(AuthenticationSchemes = AdminAuthDefaults.Scheme)]
|
||||
public class ErrorsModel : PageModel
|
||||
{
|
||||
private readonly ICollectionRepository _collectionRepository;
|
||||
private readonly ICollectionReadRepository _collectionRepository;
|
||||
private readonly ILogger<ErrorsModel> _logger;
|
||||
|
||||
public string? RunId { get; set; }
|
||||
public List<CollectionErrorRecord>? Errors { get; set; }
|
||||
|
||||
public ErrorsModel(ICollectionRepository collectionRepository, ILogger<ErrorsModel> logger)
|
||||
public ErrorsModel(ICollectionReadRepository collectionRepository, ILogger<ErrorsModel> logger)
|
||||
{
|
||||
_collectionRepository = collectionRepository;
|
||||
_logger = logger;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using QuantEngine.Core.Interfaces;
|
||||
using QuantEngine.Application.Interfaces;
|
||||
using QuantEngine.Web.Services;
|
||||
|
||||
namespace QuantEngine.Web.Pages.Admin.Collection;
|
||||
@@ -8,13 +9,13 @@ namespace QuantEngine.Web.Pages.Admin.Collection;
|
||||
[Authorize(AuthenticationSchemes = AdminAuthDefaults.Scheme)]
|
||||
public class SnapshotsModel : PageModel
|
||||
{
|
||||
private readonly ICollectionRepository _collectionRepository;
|
||||
private readonly ICollectionReadRepository _collectionRepository;
|
||||
private readonly ILogger<SnapshotsModel> _logger;
|
||||
|
||||
public string? RunId { get; set; }
|
||||
public List<CollectionSnapshotRecord>? Snapshots { get; set; }
|
||||
|
||||
public SnapshotsModel(ICollectionRepository collectionRepository, ILogger<SnapshotsModel> logger)
|
||||
public SnapshotsModel(ICollectionReadRepository collectionRepository, ILogger<SnapshotsModel> logger)
|
||||
{
|
||||
_collectionRepository = collectionRepository;
|
||||
_logger = logger;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using QuantEngine.Core.Interfaces;
|
||||
using QuantEngine.Application.Interfaces;
|
||||
using QuantEngine.Web.Services;
|
||||
|
||||
namespace QuantEngine.Web.Pages.Admin.Monitoring;
|
||||
@@ -8,7 +9,7 @@ namespace QuantEngine.Web.Pages.Admin.Monitoring;
|
||||
[Authorize(AuthenticationSchemes = AdminAuthDefaults.Scheme)]
|
||||
public class IndexModel : PageModel
|
||||
{
|
||||
private readonly ICollectionRepository _collectionRepository;
|
||||
private readonly ICollectionReadRepository _collectionRepository;
|
||||
private readonly ILogger<IndexModel> _logger;
|
||||
|
||||
public List<CollectionRunRecord>? OngoingRuns { get; set; }
|
||||
@@ -19,7 +20,7 @@ public class IndexModel : PageModel
|
||||
public List<CollectionErrorRecord>? RecentErrors { get; set; }
|
||||
public bool IsDatabaseConnected { get; set; }
|
||||
|
||||
public IndexModel(ICollectionRepository collectionRepository, ILogger<IndexModel> logger)
|
||||
public IndexModel(ICollectionReadRepository collectionRepository, ILogger<IndexModel> logger)
|
||||
{
|
||||
_collectionRepository = collectionRepository;
|
||||
_logger = logger;
|
||||
|
||||
@@ -108,7 +108,6 @@ try
|
||||
builder.Services.AddScoped<IPostgresqlHistorySnapshotReader, PostgresqlHistorySnapshotReader>();
|
||||
builder.Services.AddScoped<HistoryIngestionService>();
|
||||
builder.Services.AddScoped<CollectionRepository>();
|
||||
builder.Services.AddScoped<ICollectionRepository>(sp => sp.GetRequiredService<CollectionRepository>());
|
||||
builder.Services.AddScoped<ICollectionReadRepository>(sp => sp.GetRequiredService<CollectionRepository>());
|
||||
builder.Services.AddScoped<ICollectionWriteRepository>(sp => sp.GetRequiredService<CollectionRepository>());
|
||||
builder.Services.AddSingleton<ICollectionSchemaInitializer, CollectionSchemaInitializer>();
|
||||
@@ -151,7 +150,7 @@ try
|
||||
{
|
||||
var migrator = scope.ServiceProvider.GetRequiredService<DbMigrator>();
|
||||
var workspaceRepo = scope.ServiceProvider.GetRequiredService<IWorkspaceRepository>();
|
||||
var collectionRepo = scope.ServiceProvider.GetRequiredService<ICollectionRepository>();
|
||||
var collectionRepo = scope.ServiceProvider.GetRequiredService<ICollectionReadRepository>();
|
||||
var collectionSchemaInitializer = scope.ServiceProvider.GetRequiredService<ICollectionSchemaInitializer>();
|
||||
var tokenCache = scope.ServiceProvider.GetRequiredService<ITokenCache>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user