1
0
mirror of https://github.com/bitwarden/server synced 2025-12-16 08:13:33 +00:00

Add delete batch for playwright worker cleanup

This commit is contained in:
Matt Gibson
2025-10-10 08:55:31 -07:00
parent ec828943a4
commit a7340c905b
2 changed files with 40 additions and 1 deletions

View File

@@ -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}")]
public async Task<IActionResult> Delete([FromRoute] Guid seedId)
{
@@ -100,6 +137,7 @@ public class SeedController : Controller
}
}
[HttpDelete("/seed")]
public async Task<IActionResult> DeleteAll()
{