diff --git a/api/src/routes/rest/routes/metrics/delete_metric.rs b/api/src/routes/rest/routes/metrics/delete_metric.rs index ab0945bc2..73edbdb76 100644 --- a/api/src/routes/rest/routes/metrics/delete_metric.rs +++ b/api/src/routes/rest/routes/metrics/delete_metric.rs @@ -1,10 +1,7 @@ -use axum::{ - extract::Path, - http::StatusCode, - Json, - Extension, +use axum::{extract::Path, http::StatusCode, Extension, Json}; +use handlers::metrics::{ + delete_metric_handler, delete_metrics_handler, DeleteMetricsRequest, DeleteMetricsResponse, }; -use handlers::metrics::{delete_metric_handler, delete_metrics_handler, DeleteMetricsRequest, DeleteMetricsResponse}; use middleware::AuthenticatedUser; use uuid::Uuid; @@ -50,18 +47,21 @@ pub async fn delete_metrics_rest_handler( if response.failed_ids.is_empty() && !response.successful_ids.is_empty() { return Ok(ApiResponse::NoContent); } - + // Return 207 Multi-Status if there were mixed results if !response.failed_ids.is_empty() { - return Ok(ApiResponse::custom(StatusCode::MULTI_STATUS, response)); + return Ok(ApiResponse::JsonData(response)); } - + // Return 200 OK for other cases (like empty list) - Ok(ApiResponse::Ok(response)) - }, + Ok(ApiResponse::JsonData(response)) + } Err(e) => { tracing::error!("Error in bulk metric deletion: {}", e); - Err((StatusCode::INTERNAL_SERVER_ERROR, format!("Failed to delete metrics: {}", e))) + Err(( + StatusCode::INTERNAL_SERVER_ERROR, + format!("Failed to delete metrics: {}", e), + )) } } -} \ No newline at end of file +} diff --git a/web/src/api/buster_rest/metrics/requests.ts b/web/src/api/buster_rest/metrics/requests.ts index 5bc0769bd..d7cfa7d59 100644 --- a/web/src/api/buster_rest/metrics/requests.ts +++ b/web/src/api/buster_rest/metrics/requests.ts @@ -52,7 +52,7 @@ export const updateMetric = async (params: UpdateMetricParams) => { }; export const deleteMetrics = async (params: { ids: string[] }) => { - return mainApi.delete(`/metrics/delete`, { + return mainApi.delete(`/metrics`, { data: { ids: params.ids } }).then((res) => res.data); };