Add min and max balance filters to bot management
- Introduced optional parameters for minimum and maximum BotTradingBalance in BotController, DataController, and related services. - Updated interfaces and repository methods to support filtering by BotTradingBalance. - Enhanced TradingBotResponse and BotEntity models to include BotTradingBalance property. - Adjusted database schema to accommodate new BotTradingBalance field. - Ensured proper mapping and handling of BotTradingBalance in PostgreSQL repository and mappers.
This commit is contained in:
@@ -205,6 +205,8 @@ public class PostgreSqlBotRepository : IBotRepository
|
||||
string? name = null,
|
||||
string? ticker = null,
|
||||
string? agentName = null,
|
||||
decimal? minBalance = null,
|
||||
decimal? maxBalance = null,
|
||||
BotSortableColumn sortBy = BotSortableColumn.CreateDate,
|
||||
SortDirection sortDirection = SortDirection.Desc,
|
||||
bool showOnlyProfitable = false)
|
||||
@@ -237,6 +239,17 @@ public class PostgreSqlBotRepository : IBotRepository
|
||||
query = query.Where(b => b.User != null && EF.Functions.ILike(b.User.AgentName, $"%{agentName}%"));
|
||||
}
|
||||
|
||||
// Apply balance filtering if specified
|
||||
if (minBalance.HasValue)
|
||||
{
|
||||
query = query.Where(b => b.BotTradingBalance >= minBalance.Value);
|
||||
}
|
||||
|
||||
if (maxBalance.HasValue)
|
||||
{
|
||||
query = query.Where(b => b.BotTradingBalance <= maxBalance.Value);
|
||||
}
|
||||
|
||||
// Apply profitable bots filtering if specified
|
||||
if (showOnlyProfitable)
|
||||
{
|
||||
@@ -275,6 +288,9 @@ public class PostgreSqlBotRepository : IBotRepository
|
||||
BotSortableColumn.AgentName => sortDirection == SortDirection.Asc
|
||||
? query.OrderBy(b => b.User.AgentName)
|
||||
: query.OrderByDescending(b => b.User.AgentName),
|
||||
BotSortableColumn.BotTradingBalance => sortDirection == SortDirection.Asc
|
||||
? query.OrderBy(b => b.BotTradingBalance)
|
||||
: query.OrderByDescending(b => b.BotTradingBalance),
|
||||
_ => sortDirection == SortDirection.Asc
|
||||
? query.OrderBy(b => b.CreateDate)
|
||||
: query.OrderByDescending(b => b.CreateDate)
|
||||
|
||||
Reference in New Issue
Block a user