Fix concurrent on userStrategies
This commit is contained in:
@@ -268,17 +268,26 @@ public class PostgreSqlTradingRepository : ITradingRepository
|
||||
|
||||
public async Task<Position> GetPositionByIdentifierAsync(Guid identifier)
|
||||
{
|
||||
var position = await _context.Positions
|
||||
.AsNoTracking()
|
||||
.Include(p => p.User)
|
||||
.Include(p => p.OpenTrade)
|
||||
.Include(p => p.StopLossTrade)
|
||||
.Include(p => p.TakeProfit1Trade)
|
||||
.Include(p => p.TakeProfit2Trade)
|
||||
.FirstOrDefaultAsync(p => p.Identifier == identifier)
|
||||
.ConfigureAwait(false);
|
||||
try
|
||||
{
|
||||
await PostgreSqlConnectionHelper.EnsureConnectionOpenAsync(_context);
|
||||
|
||||
var position = await _context.Positions
|
||||
.AsNoTracking()
|
||||
.Include(p => p.User)
|
||||
.Include(p => p.OpenTrade)
|
||||
.Include(p => p.StopLossTrade)
|
||||
.Include(p => p.TakeProfit1Trade)
|
||||
.Include(p => p.TakeProfit2Trade)
|
||||
.FirstOrDefaultAsync(p => p.Identifier == identifier)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
return PostgreSqlMappers.Map(position);
|
||||
return PostgreSqlMappers.Map(position);
|
||||
}
|
||||
finally
|
||||
{
|
||||
await PostgreSqlConnectionHelper.SafeCloseConnectionAsync(_context);
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Position> GetPositions(PositionInitiator positionInitiator)
|
||||
@@ -413,6 +422,28 @@ public class PostgreSqlTradingRepository : ITradingRepository
|
||||
return PostgreSqlMappers.Map(positions);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Position>> GetPositionsByInitiatorIdentifiersAsync(IEnumerable<Guid> initiatorIdentifiers)
|
||||
{
|
||||
var identifiersList = initiatorIdentifiers.ToList();
|
||||
if (!identifiersList.Any())
|
||||
{
|
||||
return Enumerable.Empty<Position>();
|
||||
}
|
||||
|
||||
var positions = await _context.Positions
|
||||
.AsNoTracking()
|
||||
.Include(p => p.User)
|
||||
.Include(p => p.OpenTrade)
|
||||
.Include(p => p.StopLossTrade)
|
||||
.Include(p => p.TakeProfit1Trade)
|
||||
.Include(p => p.TakeProfit2Trade)
|
||||
.Where(p => identifiersList.Contains(p.InitiatorIdentifier))
|
||||
.ToListAsync()
|
||||
.ConfigureAwait(false);
|
||||
|
||||
return PostgreSqlMappers.Map(positions);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Position>> GetAllPositionsAsync()
|
||||
{
|
||||
var positions = await _context.Positions
|
||||
|
||||
Reference in New Issue
Block a user