refactor(dotnet): separate collection read model service
This commit is contained in:
@@ -7,11 +7,11 @@ namespace QuantEngine.Web.Endpoints;
|
||||
|
||||
public class GetCollectionStateEndpoint : EndpointWithoutRequest<CollectionDashboardStateRecord>
|
||||
{
|
||||
private readonly ICollectionRepository _repo;
|
||||
private readonly ICollectionReadModelService _readModelService;
|
||||
|
||||
public GetCollectionStateEndpoint(ICollectionRepository repo)
|
||||
public GetCollectionStateEndpoint(ICollectionReadModelService readModelService)
|
||||
{
|
||||
_repo = repo;
|
||||
_readModelService = readModelService;
|
||||
}
|
||||
|
||||
public override void Configure()
|
||||
@@ -27,7 +27,7 @@ public class GetCollectionStateEndpoint : EndpointWithoutRequest<CollectionDashb
|
||||
{
|
||||
try
|
||||
{
|
||||
var state = await _repo.GetDashboardStateAsync();
|
||||
var state = await _readModelService.GetDashboardStateAsync();
|
||||
await SendOkAsync(state, ct);
|
||||
}
|
||||
catch
|
||||
@@ -50,11 +50,11 @@ public class GetRecentRunsResponse
|
||||
|
||||
public class GetRecentRunsEndpoint : Endpoint<GetRecentRunsRequest, GetRecentRunsResponse>
|
||||
{
|
||||
private readonly ICollectionRepository _repo;
|
||||
private readonly ICollectionReadModelService _readModelService;
|
||||
|
||||
public GetRecentRunsEndpoint(ICollectionRepository repo)
|
||||
public GetRecentRunsEndpoint(ICollectionReadModelService readModelService)
|
||||
{
|
||||
_repo = repo;
|
||||
_readModelService = readModelService;
|
||||
}
|
||||
|
||||
public override void Configure()
|
||||
@@ -70,7 +70,7 @@ public class GetRecentRunsEndpoint : Endpoint<GetRecentRunsRequest, GetRecentRun
|
||||
{
|
||||
try
|
||||
{
|
||||
var runs = await _repo.GetRecentRunsAsync(req.Limit);
|
||||
var runs = await _readModelService.GetRecentRunsAsync(req.Limit);
|
||||
await SendOkAsync(new GetRecentRunsResponse { Runs = runs, Count = runs.Count }, ct);
|
||||
}
|
||||
catch
|
||||
@@ -94,11 +94,11 @@ public class GetRunSnapshotsResponse
|
||||
|
||||
public class GetRunSnapshotsEndpoint : Endpoint<GetRunSnapshotsRequest, GetRunSnapshotsResponse>
|
||||
{
|
||||
private readonly ICollectionRepository _repo;
|
||||
private readonly ICollectionReadModelService _readModelService;
|
||||
|
||||
public GetRunSnapshotsEndpoint(ICollectionRepository repo)
|
||||
public GetRunSnapshotsEndpoint(ICollectionReadModelService readModelService)
|
||||
{
|
||||
_repo = repo;
|
||||
_readModelService = readModelService;
|
||||
}
|
||||
|
||||
public override void Configure()
|
||||
@@ -115,7 +115,7 @@ public class GetRunSnapshotsEndpoint : Endpoint<GetRunSnapshotsRequest, GetRunSn
|
||||
{
|
||||
try
|
||||
{
|
||||
var snapshots = await _repo.GetRunSnapshotsAsync(req.RunId);
|
||||
var snapshots = await _readModelService.GetRunSnapshotsAsync(req.RunId);
|
||||
await SendOkAsync(new GetRunSnapshotsResponse { RunId = req.RunId, Snapshots = snapshots, Count = snapshots.Count }, ct);
|
||||
}
|
||||
catch
|
||||
@@ -140,11 +140,11 @@ public class GetRunErrorsResponse
|
||||
|
||||
public class GetRunErrorsEndpoint : Endpoint<GetRunErrorsRequest, GetRunErrorsResponse>
|
||||
{
|
||||
private readonly ICollectionRepository _repo;
|
||||
private readonly ICollectionReadModelService _readModelService;
|
||||
|
||||
public GetRunErrorsEndpoint(ICollectionRepository repo)
|
||||
public GetRunErrorsEndpoint(ICollectionReadModelService readModelService)
|
||||
{
|
||||
_repo = repo;
|
||||
_readModelService = readModelService;
|
||||
}
|
||||
|
||||
public override void Configure()
|
||||
@@ -161,7 +161,7 @@ public class GetRunErrorsEndpoint : Endpoint<GetRunErrorsRequest, GetRunErrorsRe
|
||||
{
|
||||
try
|
||||
{
|
||||
var errors = await _repo.GetRunErrorsAsync(req.RunId, req.Limit);
|
||||
var errors = await _readModelService.GetRunErrorsAsync(req.RunId, req.Limit);
|
||||
await SendOkAsync(new GetRunErrorsResponse { RunId = req.RunId, Errors = errors, Count = errors.Count }, ct);
|
||||
}
|
||||
catch
|
||||
@@ -186,11 +186,11 @@ public class GetLatestSnapshotsResponse
|
||||
|
||||
public class GetLatestSnapshotsEndpoint : Endpoint<GetLatestSnapshotsRequest, GetLatestSnapshotsResponse>
|
||||
{
|
||||
private readonly ICollectionRepository _repo;
|
||||
private readonly ICollectionReadModelService _readModelService;
|
||||
|
||||
public GetLatestSnapshotsEndpoint(ICollectionRepository repo)
|
||||
public GetLatestSnapshotsEndpoint(ICollectionReadModelService readModelService)
|
||||
{
|
||||
_repo = repo;
|
||||
_readModelService = readModelService;
|
||||
}
|
||||
|
||||
public override void Configure()
|
||||
@@ -206,7 +206,7 @@ public class GetLatestSnapshotsEndpoint : Endpoint<GetLatestSnapshotsRequest, Ge
|
||||
{
|
||||
try
|
||||
{
|
||||
var snapshots = await _repo.GetLatestSnapshotsForTickerAsync(req.Ticker, req.Limit);
|
||||
var snapshots = await _readModelService.GetLatestSnapshotsForTickerAsync(req.Ticker, req.Limit);
|
||||
await SendOkAsync(new GetLatestSnapshotsResponse { Ticker = req.Ticker, Snapshots = snapshots, Count = snapshots.Count }, ct);
|
||||
}
|
||||
catch
|
||||
@@ -223,12 +223,12 @@ public class GetPriceHistorySummaryResponse
|
||||
|
||||
public class GetPriceHistorySummaryEndpoint : EndpointWithoutRequest<GetPriceHistorySummaryResponse>
|
||||
{
|
||||
private readonly ICollectionRepository _repo;
|
||||
private readonly ICollectionReadModelService _readModelService;
|
||||
private readonly ILogger<GetPriceHistorySummaryEndpoint> _logger;
|
||||
|
||||
public GetPriceHistorySummaryEndpoint(ICollectionRepository repo, ILogger<GetPriceHistorySummaryEndpoint> logger)
|
||||
public GetPriceHistorySummaryEndpoint(ICollectionReadModelService readModelService, ILogger<GetPriceHistorySummaryEndpoint> logger)
|
||||
{
|
||||
_repo = repo;
|
||||
_readModelService = readModelService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
@@ -245,7 +245,7 @@ public class GetPriceHistorySummaryEndpoint : EndpointWithoutRequest<GetPriceHis
|
||||
{
|
||||
try
|
||||
{
|
||||
var summary = await _repo.GetPriceHistorySummaryAsync();
|
||||
var summary = await _readModelService.GetPriceHistorySummaryAsync();
|
||||
await SendOkAsync(new GetPriceHistorySummaryResponse { Tickers = summary }, ct);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
Reference in New Issue
Block a user