Enhance DataController and BotService with new configuration and bot name checks
- Added IConfiguration dependency to DataController for environment variable access. - Updated GetPaginatedAgentSummariesCommand to include a flag for filtering profitable agents. - Implemented HasUserBotWithNameAsync method in IBotService and BotService to check for existing bots by name. - Modified StartBotCommandHandler and StartCopyTradingCommandHandler to prevent duplicate bot names during strategy creation.
This commit is contained in:
@@ -170,7 +170,8 @@ public class AgentSummaryRepository : IAgentSummaryRepository
|
||||
int pageSize,
|
||||
SortableFields sortBy,
|
||||
string sortOrder,
|
||||
IEnumerable<string>? agentNames = null)
|
||||
IEnumerable<string>? agentNames = null,
|
||||
bool showOnlyProfitableAgent = false)
|
||||
{
|
||||
// Start with base query
|
||||
var query = _context.AgentSummaries.Include(a => a.User).AsQueryable();
|
||||
@@ -181,6 +182,12 @@ public class AgentSummaryRepository : IAgentSummaryRepository
|
||||
query = query.Where(a => agentNames.Contains(a.AgentName));
|
||||
}
|
||||
|
||||
// Apply profitable agent filtering if specified
|
||||
if (showOnlyProfitableAgent)
|
||||
{
|
||||
query = query.Where(a => a.TotalROI > 0);
|
||||
}
|
||||
|
||||
// Get total count before applying pagination
|
||||
var totalCount = await query.CountAsync();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user