Improve workers for backtests

This commit is contained in:
2025-11-10 01:44:33 +07:00
parent 97f2b8229b
commit 7e52b7a734
18 changed files with 740 additions and 144 deletions

View File

@@ -75,9 +75,10 @@ public class PostgreSqlGeneticRepository : IGeneticRepository
public async Task UpdateGeneticRequestAsync(GeneticRequest geneticRequest)
{
var existingEntity = _context.GeneticRequests
var existingEntity = await _context.GeneticRequests
.AsTracking() // Explicitly enable tracking to ensure entity is tracked
.Include(gr => gr.User)
.FirstOrDefault(gr => gr.RequestId == geneticRequest.RequestId);
.FirstOrDefaultAsync(gr => gr.RequestId == geneticRequest.RequestId);
if (existingEntity != null)
{
@@ -110,9 +111,13 @@ public class PostgreSqlGeneticRepository : IGeneticRepository
existingEntity.EligibleIndicatorsJson = "[]";
}
// Only update the tracked entity, do not attach a new one
// Save changes - entity is tracked so changes will be persisted
await _context.SaveChangesAsync();
}
else
{
throw new InvalidOperationException($"Genetic request with RequestId '{geneticRequest.RequestId}' not found in database");
}
}
public void DeleteGeneticRequestByIdForUser(User user, string id)