Add stats for kaigen
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using Managing.Application.Abstractions;
|
||||
using Managing.Application.ManageBot.Commands;
|
||||
using MediatR;
|
||||
|
||||
namespace Managing.Application.ManageBot
|
||||
{
|
||||
/// <summary>
|
||||
/// Handler for retrieving a specific strategy owned by a user
|
||||
/// </summary>
|
||||
public class GetUserStrategyCommandHandler : IRequestHandler<GetUserStrategyCommand, ITradingBot>
|
||||
{
|
||||
private readonly IBotService _botService;
|
||||
|
||||
public GetUserStrategyCommandHandler(IBotService botService)
|
||||
{
|
||||
_botService = botService;
|
||||
}
|
||||
|
||||
public Task<ITradingBot> Handle(GetUserStrategyCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var allActiveBots = _botService.GetActiveBots();
|
||||
|
||||
// Find the specific strategy that matches both user and strategy name
|
||||
var strategy = allActiveBots
|
||||
.FirstOrDefault(bot =>
|
||||
bot.User != null &&
|
||||
bot.User.Name == request.AgentName &&
|
||||
bot.Name == request.StrategyName);
|
||||
|
||||
return Task.FromResult(strategy);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user