Fix BacktestCount
This commit is contained in:
@@ -3,6 +3,7 @@ using Managing.Application.Abstractions.Grains;
|
||||
using Managing.Application.Abstractions.Repositories;
|
||||
using Managing.Application.Abstractions.Services;
|
||||
using Managing.Application.Hubs;
|
||||
using Managing.Core;
|
||||
using Managing.Domain.Accounts;
|
||||
using Managing.Domain.Backtests;
|
||||
using Managing.Domain.Bots;
|
||||
@@ -10,6 +11,7 @@ using Managing.Domain.Candles;
|
||||
using Managing.Domain.Scenarios;
|
||||
using Managing.Domain.Users;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using static Managing.Common.Enums;
|
||||
using LightBacktestResponse = Managing.Domain.Backtests.LightBacktest; // Use the domain model for notification
|
||||
@@ -19,6 +21,7 @@ namespace Managing.Application.Backtests
|
||||
public class Backtester : IBacktester
|
||||
{
|
||||
private readonly IBacktestRepository _backtestRepository;
|
||||
private readonly IServiceScopeFactory _serviceScopeFactory;
|
||||
private readonly ILogger<Backtester> _logger;
|
||||
private readonly IExchangeService _exchangeService;
|
||||
private readonly IScenarioService _scenarioService;
|
||||
@@ -27,7 +30,6 @@ namespace Managing.Application.Backtests
|
||||
private readonly IKaigenService _kaigenService;
|
||||
private readonly IHubContext<BacktestHub> _hubContext;
|
||||
private readonly IGrainFactory _grainFactory;
|
||||
private readonly IAgentService _agentService;
|
||||
|
||||
public Backtester(
|
||||
IExchangeService exchangeService,
|
||||
@@ -39,7 +41,7 @@ namespace Managing.Application.Backtests
|
||||
IKaigenService kaigenService,
|
||||
IHubContext<BacktestHub> hubContext,
|
||||
IGrainFactory grainFactory,
|
||||
IAgentService agentService)
|
||||
IServiceScopeFactory serviceScopeFactory)
|
||||
{
|
||||
_exchangeService = exchangeService;
|
||||
_backtestRepository = backtestRepository;
|
||||
@@ -50,7 +52,7 @@ namespace Managing.Application.Backtests
|
||||
_kaigenService = kaigenService;
|
||||
_hubContext = hubContext;
|
||||
_grainFactory = grainFactory;
|
||||
_agentService = agentService;
|
||||
_serviceScopeFactory = serviceScopeFactory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -199,7 +201,8 @@ namespace Managing.Application.Backtests
|
||||
{
|
||||
try
|
||||
{
|
||||
await _agentService.IncrementBacktestCountAsync(user.Id);
|
||||
await ServiceScopeHelpers.WithScopedService<IAgentService>(_serviceScopeFactory,
|
||||
async (agentService) => await agentService.IncrementBacktestCountAsync(user.Id));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user