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

@@ -204,7 +204,8 @@ public class PostgreSqlBotRepository : IBotRepository
string? ticker = null,
string? agentName = null,
BotSortableColumn sortBy = BotSortableColumn.CreateDate,
string sortDirection = "Desc")
string sortDirection = "Desc",
bool showOnlyProfitable = false)
{
// Build the query with filters
var query = _context.Bots
@@ -234,6 +235,12 @@ public class PostgreSqlBotRepository : IBotRepository
query = query.Where(b => b.User != null && EF.Functions.ILike(b.User.AgentName, $"%{agentName}%"));
}
// Apply profitable bots filtering if specified
if (showOnlyProfitable)
{
query = query.Where(b => b.Roi > 0);
}
// Get total count before applying pagination
var totalCount = await query.CountAsync().ConfigureAwait(false);