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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user