Fix bot TOP 3

This commit is contained in:
2025-09-25 11:08:28 +07:00
parent 253c448acb
commit c297429b18
7 changed files with 128 additions and 30 deletions

View File

@@ -239,4 +239,32 @@ public class PostgreSqlBotRepository : IBotRepository
var bots = PostgreSqlMappers.Map(entities);
return (bots, totalCount);
}
public async Task<IEnumerable<Bot>> GetTopBotsByPnLAsync(IEnumerable<BotStatus> statuses, int count = 3)
{
var entities = await _context.Bots
.AsNoTracking()
.Include(m => m.User)
.Where(b => statuses.Contains(b.Status))
.OrderByDescending(b => b.Pnl)
.Take(count)
.ToListAsync()
.ConfigureAwait(false);
return PostgreSqlMappers.Map(entities);
}
public async Task<IEnumerable<Bot>> GetTopBotsByRoiAsync(IEnumerable<BotStatus> statuses, int count = 3)
{
var entities = await _context.Bots
.AsNoTracking()
.Include(m => m.User)
.Where(b => statuses.Contains(b.Status))
.OrderByDescending(b => b.Roi)
.Take(count)
.ToListAsync()
.ConfigureAwait(false);
return PostgreSqlMappers.Map(entities);
}
}