update stats data
This commit is contained in:
@@ -73,6 +73,8 @@ public class PostgreSqlBotRepository : IBotRepository
|
||||
existingEntity.Volume = bot.Volume;
|
||||
existingEntity.Fees = bot.Fees;
|
||||
existingEntity.UpdatedAt = DateTime.UtcNow;
|
||||
existingEntity.LongPositionCount = bot.LongPositionCount;
|
||||
existingEntity.ShortPositionCount = bot.ShortPositionCount;
|
||||
|
||||
await _context.SaveChangesAsync().ConfigureAwait(false);
|
||||
}
|
||||
@@ -158,13 +160,13 @@ public class PostgreSqlBotRepository : IBotRepository
|
||||
}
|
||||
|
||||
public async Task<(IEnumerable<Bot> Bots, int TotalCount)> GetBotsPaginatedAsync(
|
||||
int pageNumber,
|
||||
int pageSize,
|
||||
BotStatus? status = null,
|
||||
string? name = null,
|
||||
string? ticker = null,
|
||||
string? agentName = null,
|
||||
string sortBy = "CreateDate",
|
||||
int pageNumber,
|
||||
int pageSize,
|
||||
BotStatus? status = null,
|
||||
string? name = null,
|
||||
string? ticker = null,
|
||||
string? agentName = null,
|
||||
string sortBy = "CreateDate",
|
||||
string sortDirection = "Desc")
|
||||
{
|
||||
// Build the query with filters
|
||||
@@ -200,29 +202,29 @@ public class PostgreSqlBotRepository : IBotRepository
|
||||
// Apply sorting
|
||||
query = sortBy.ToLower() switch
|
||||
{
|
||||
"name" => sortDirection.ToLower() == "asc"
|
||||
? query.OrderBy(b => b.Name)
|
||||
"name" => sortDirection.ToLower() == "asc"
|
||||
? query.OrderBy(b => b.Name)
|
||||
: query.OrderByDescending(b => b.Name),
|
||||
"ticker" => sortDirection.ToLower() == "asc"
|
||||
? query.OrderBy(b => b.Ticker)
|
||||
"ticker" => sortDirection.ToLower() == "asc"
|
||||
? query.OrderBy(b => b.Ticker)
|
||||
: query.OrderByDescending(b => b.Ticker),
|
||||
"status" => sortDirection.ToLower() == "asc"
|
||||
? query.OrderBy(b => b.Status)
|
||||
"status" => sortDirection.ToLower() == "asc"
|
||||
? query.OrderBy(b => b.Status)
|
||||
: query.OrderByDescending(b => b.Status),
|
||||
"startuptime" => sortDirection.ToLower() == "asc"
|
||||
? query.OrderBy(b => b.StartupTime)
|
||||
"startuptime" => sortDirection.ToLower() == "asc"
|
||||
? query.OrderBy(b => b.StartupTime)
|
||||
: query.OrderByDescending(b => b.StartupTime),
|
||||
"pnl" => sortDirection.ToLower() == "asc"
|
||||
? query.OrderBy(b => b.Pnl)
|
||||
"pnl" => sortDirection.ToLower() == "asc"
|
||||
? query.OrderBy(b => b.Pnl)
|
||||
: query.OrderByDescending(b => b.Pnl),
|
||||
"winrate" => sortDirection.ToLower() == "asc"
|
||||
? query.OrderBy(b => b.TradeWins / (b.TradeWins + b.TradeLosses))
|
||||
"winrate" => sortDirection.ToLower() == "asc"
|
||||
? query.OrderBy(b => b.TradeWins / (b.TradeWins + b.TradeLosses))
|
||||
: query.OrderByDescending(b => b.TradeWins / (b.TradeWins + b.TradeLosses)),
|
||||
"agentname" => sortDirection.ToLower() == "asc"
|
||||
? query.OrderBy(b => b.User.AgentName)
|
||||
"agentname" => sortDirection.ToLower() == "asc"
|
||||
? query.OrderBy(b => b.User.AgentName)
|
||||
: query.OrderByDescending(b => b.User.AgentName),
|
||||
_ => sortDirection.ToLower() == "asc"
|
||||
? query.OrderBy(b => b.CreateDate)
|
||||
_ => sortDirection.ToLower() == "asc"
|
||||
? query.OrderBy(b => b.CreateDate)
|
||||
: query.OrderByDescending(b => b.CreateDate) // Default to CreateDate
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user