Implement profitable bots filtering in BotController and DataController

- Added IConfiguration dependency to BotController for accessing environment variables.
- Updated GetBotsPaginatedAsync method in BotService and IBotService to include a flag for filtering profitable bots.
- Modified DataController to utilize the new filtering option for agent summaries and bot retrieval.
- Enhanced PostgreSqlBotRepository to apply filtering based on profitability when querying bots.
This commit is contained in:
2025-11-22 14:02:29 +07:00
parent e69dd43ace
commit 2a354bd7d2
6 changed files with 42 additions and 18 deletions

View File

@@ -711,10 +711,10 @@ public class DataController : ControllerBase
}
// Check environment variable for filtering profitable agents only
var showOnlyProfitableAgent = _configuration.GetValue<bool>("showOnlyProfitableAgent", false);
var showOnlyProfitable = _configuration.GetValue<bool>("showOnlyProfitable", false);
// Get paginated results from database
var command = new GetPaginatedAgentSummariesCommand(page, pageSize, sortBy, sortOrder, agentNamesList, showOnlyProfitableAgent);
var command = new GetPaginatedAgentSummariesCommand(page, pageSize, sortBy, sortOrder, agentNamesList, showOnlyProfitable);
var result = await _mediator.Send(command);
var agentSummaries = result.Results;
var totalCount = result.TotalCount;
@@ -928,6 +928,9 @@ public class DataController : ControllerBase
try
{
// Check environment variable for filtering profitable strategies only
var showOnlyProfitable = _configuration.GetValue<bool>("showOnlyProfitable", false);
// Get paginated bots excluding Saved status
var (bots, totalCount) = await _botService.GetBotsPaginatedAsync(
pageNumber,
@@ -937,7 +940,8 @@ public class DataController : ControllerBase
ticker,
agentName,
sortBy,
sortDirection);
sortDirection,
showOnlyProfitable);
// Filter out Saved status bots
var filteredBots = bots.Where(bot => bot.Status != BotStatus.Saved).ToList();