From 07fb67c5353430e89edd746d2c462f1b6cbcfb7c Mon Sep 17 00:00:00 2001 From: cryptooda Date: Fri, 9 Jan 2026 03:54:20 +0700 Subject: [PATCH] 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. --- src/Managing.Api/Controllers/DataController.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Managing.Api/Controllers/DataController.cs b/src/Managing.Api/Controllers/DataController.cs index 8eebcfd7..2f6edce9 100644 --- a/src/Managing.Api/Controllers/DataController.cs +++ b/src/Managing.Api/Controllers/DataController.cs @@ -918,6 +918,7 @@ public class DataController : ControllerBase public async Task>> 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("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);