mirror of
https://github.com/bitwarden/server
synced 2025-12-16 16:23:31 +00:00
Add delete batch for playwright worker cleanup
This commit is contained in:
@@ -65,6 +65,43 @@ public class SeedController : Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpDelete("/seed/batch")]
|
||||||
|
public async Task<IActionResult> DeleteBatch([FromBody] List<Guid> seedIds)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Deleting batch of seeded data with IDs: {SeedIds}", string.Join(", ", seedIds));
|
||||||
|
|
||||||
|
var aggregateException = new AggregateException();
|
||||||
|
|
||||||
|
await Task.Run(async () =>
|
||||||
|
{
|
||||||
|
foreach (var seedId in seedIds)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _recipeService.DestroyRecipe(seedId);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
aggregateException = new AggregateException(aggregateException, ex);
|
||||||
|
_logger.LogError(ex, "Error deleting seeded data: {SeedId}", seedId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (aggregateException.InnerExceptions.Count > 0)
|
||||||
|
{
|
||||||
|
return BadRequest(new
|
||||||
|
{
|
||||||
|
Error = "One or more errors occurred while deleting seeded data",
|
||||||
|
Details = aggregateException.InnerExceptions.Select(e => e.Message).ToList()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return Ok(new
|
||||||
|
{
|
||||||
|
Message = "Batch delete completed successfully"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
[HttpDelete("/seed/{seedId}")]
|
[HttpDelete("/seed/{seedId}")]
|
||||||
public async Task<IActionResult> Delete([FromRoute] Guid seedId)
|
public async Task<IActionResult> Delete([FromRoute] Guid seedId)
|
||||||
{
|
{
|
||||||
@@ -100,6 +137,7 @@ public class SeedController : Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[HttpDelete("/seed")]
|
[HttpDelete("/seed")]
|
||||||
public async Task<IActionResult> DeleteAll()
|
public async Task<IActionResult> DeleteAll()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -65,7 +65,8 @@ public class RecipeService : IRecipeService
|
|||||||
var seededData = _databaseContext.SeededData.FirstOrDefault(s => s.Id == seedId);
|
var seededData = _databaseContext.SeededData.FirstOrDefault(s => s.Id == seedId);
|
||||||
if (seededData == null)
|
if (seededData == null)
|
||||||
{
|
{
|
||||||
throw new RecipeExecutionException($"Seeded data with ID {seedId} not found");
|
_logger.LogInformation("No seeded data found with ID {SeedId}, skipping", seedId);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var trackedEntities = JsonSerializer.Deserialize<Dictionary<string, List<Guid>>>(seededData.Data);
|
var trackedEntities = JsonSerializer.Deserialize<Dictionary<string, List<Guid>>>(seededData.Data);
|
||||||
|
|||||||
Reference in New Issue
Block a user