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
@@ -30,29 +30,33 @@ impl<'a> ClientDb<'a> {
self.find_many(HttpResponseIden::WorkspaceId, workspace_id, limit)
}
/// Returns the number of responses deleted.
pub fn delete_all_http_responses_for_request(
&self,
request_id: &str,
source: &UpdateSource,
) -> Result<()> {
) -> Result<usize> {
let responses = self.list_http_responses_for_request(request_id, None)?;
let count = responses.len();
for m in responses {
self.delete(&m, source)?;
}
Ok(())
Ok(count)
}
/// Returns the number of responses deleted.
pub fn delete_all_http_responses_for_workspace(
&self,
workspace_id: &str,
source: &UpdateSource,
) -> Result<()> {
) -> Result<usize> {
let responses =
self.find_many::<HttpResponse>(HttpResponseIden::WorkspaceId, workspace_id, None)?;
let count = responses.len();
for m in responses {
self.delete(&m, source)?;
}
Ok(())
Ok(count)
}
pub fn delete_http_response(