Fix DbUpdateException in TradeRepository and Polymarket API 400 on max offset
This commit is contained in:
@@ -69,7 +69,20 @@ public class TradeRepository : ITradeRepository
|
||||
{
|
||||
try { _db.Entry(t).State = EntityState.Detached; } catch { }
|
||||
}
|
||||
throw;
|
||||
|
||||
// Fallback to inserting one by one to avoid losing the entire batch due to a single duplicate
|
||||
foreach (var t in trades)
|
||||
{
|
||||
try
|
||||
{
|
||||
_db.Trades.Add(t);
|
||||
await _db.SaveChangesAsync(ct);
|
||||
}
|
||||
catch
|
||||
{
|
||||
try { _db.Entry(t).State = EntityState.Detached; } catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -200,7 +200,7 @@ public class CopytradingEstimator : ICopytradingEstimator
|
||||
int limit = 1000;
|
||||
int offset = 0;
|
||||
|
||||
while (offset <= 3000)
|
||||
while (offset <= 1000)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -322,7 +322,7 @@ public class CopytradingEstimator : ICopytradingEstimator
|
||||
int limit = 1000;
|
||||
int offset = 0;
|
||||
|
||||
while (offset <= 3000)
|
||||
while (offset <= 1000)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user