Return a delete count from the delete-all response helpers

`response delete` had to run its own list first just to report how many
it removed, which duplicated the query the helper already does. Both
helpers now return the count instead.

`cmd_delete_all_http_responses` was returning the helper's value
directly, so it keeps its `()` result explicitly and the frontend
contract is unchanged.
This commit is contained in:
Gregory Schier
2026-08-13 22:09:08 -07:00
parent f53887a114
commit 6b0d553dc5
3 changed files with 11 additions and 15 deletions
@@ -117,13 +117,8 @@ fn delete(ctx: &CliContext, id: &str, yes: bool) -> CommandResult {
println!("Aborted");
return Ok(());
}
// The delete helpers return no count, so take one first to report honestly.
let count = ctx
.db()
.list_http_responses_for_request(id, None)
.map_err(|e| format!("Failed to list responses: {e}"))?
.len();
ctx.db()
.delete_all_http_responses_for_request(id, &UpdateSource::Sync)
.map_err(|e| format!("Failed to delete responses: {e}"))?;
println!("Deleted {count} responses for request {id}");
@@ -137,10 +132,6 @@ fn delete(ctx: &CliContext, id: &str, yes: bool) -> CommandResult {
}
let count = ctx
.db()
.list_http_responses(&workspace_id, None)
.map_err(|e| format!("Failed to list responses: {e}"))?
.len();
ctx.db()
.delete_all_http_responses_for_workspace(&workspace_id, &UpdateSource::Sync)
.map_err(|e| format!("Failed to delete responses: {e}"))?;
println!("Deleted {count} responses for workspace {workspace_id}");