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