Enhance DataController to support status filtering in GetStrategiesPaginated method

- Added an optional status parameter to the GetStrategiesPaginated method, defaulting to Running if not provided.
- Updated the bot retrieval logic to apply the status filter directly, simplifying the filtering process and ensuring accurate bot status management.
This commit is contained in:
2026-01-09 03:54:20 +07:00
parent ae353aa0d5
commit 07fb67c535

View File

@@ -918,6 +918,7 @@ public class DataController : ControllerBase
public async Task<ActionResult<PaginatedResponse<TradingBotResponse>>> GetStrategiesPaginated(
int pageNumber = 1,
int pageSize = 10,
BotStatus? status = null,
string? name = null,
string? ticker = null,
string? agentName = null,
@@ -943,11 +944,14 @@ public class DataController : ControllerBase
// Check environment variable for filtering profitable strategies only
var showOnlyProfitable = _configuration.GetValue<bool>("showOnlyProfitable", false);
// Get paginated bots excluding Saved status
// Default to Running status if not provided
var statusFilter = status ?? BotStatus.Running;
// Get paginated bots with status filter
var (bots, totalCount) = await _botService.GetBotsPaginatedAsync(
pageNumber,
pageSize,
null, // No specific status filter - we'll exclude Saved in the service call
statusFilter,
name,
ticker,
agentName,
@@ -957,9 +961,9 @@ public class DataController : ControllerBase
sortDirection,
showOnlyProfitable);
// Filter out Saved status bots
var filteredBots = bots.Where(bot => bot.Status != BotStatus.Saved).ToList();
var filteredCount = totalCount - bots.Count(bot => bot.Status == BotStatus.Saved);
// No additional filtering needed since we're using the status filter directly
var filteredBots = bots.ToList();
var filteredCount = totalCount;
// Map to response objects
var tradingBotResponses = MapBotsToTradingBotResponse(filteredBots);