From 1e5b63a3d03ea327c866b80377f760d672c6de79 Mon Sep 17 00:00:00 2001 From: dal Date: Thu, 20 Mar 2025 13:40:49 -0600 Subject: [PATCH] a few small tweaks for reqs --- api/libs/handlers/src/collections/types.rs | 1 - .../handlers/src/collections/update_collection_handler.rs | 6 ++++-- api/src/routes/rest/routes/collections/update_collection.rs | 4 +++- web/src/api/buster_rest/collections/requests.ts | 4 +++- web/src/api/buster_rest/metrics/requests.ts | 4 +++- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/api/libs/handlers/src/collections/types.rs b/api/libs/handlers/src/collections/types.rs index bf713997e..5ecbc0cbf 100644 --- a/api/libs/handlers/src/collections/types.rs +++ b/api/libs/handlers/src/collections/types.rs @@ -109,7 +109,6 @@ pub struct UpdateCollectionAssetsRequest { #[derive(Debug, Clone, Deserialize, Serialize)] pub struct UpdateCollectionRequest { - pub id: Uuid, pub collection: Option, pub assets: Option>, } diff --git a/api/libs/handlers/src/collections/update_collection_handler.rs b/api/libs/handlers/src/collections/update_collection_handler.rs index 3c8075b91..3377498d2 100644 --- a/api/libs/handlers/src/collections/update_collection_handler.rs +++ b/api/libs/handlers/src/collections/update_collection_handler.rs @@ -21,16 +21,18 @@ use crate::collections::types::{ /// /// # Arguments /// * `user_id` - The ID of the user updating the collection +/// * `collection_id` - The ID of the collection to update /// * `req` - The request containing the collection updates /// /// # Returns /// * `Result` - The updated collection state pub async fn update_collection_handler( user_id: &Uuid, + collection_id: Uuid, req: UpdateCollectionRequest, ) -> Result { let user_id = Arc::new(*user_id); - let collection_id = Arc::new(req.id); + let collection_id = Arc::new(collection_id); // Update collection record if provided let update_collection_record_handle = if let Some(collection) = req.collection { @@ -89,7 +91,7 @@ pub async fn update_collection_handler( } // Get the updated collection - let collection = match fetch_collection(&req.id).await? { + let collection = match fetch_collection(&collection_id).await? { Some(collection) => collection, None => return Err(anyhow!("Collection not found")), }; diff --git a/api/src/routes/rest/routes/collections/update_collection.rs b/api/src/routes/rest/routes/collections/update_collection.rs index 169d92841..8b2308e64 100644 --- a/api/src/routes/rest/routes/collections/update_collection.rs +++ b/api/src/routes/rest/routes/collections/update_collection.rs @@ -1,4 +1,5 @@ use axum::{ + extract::Path, http::StatusCode, Extension, Json, }; @@ -10,11 +11,12 @@ use uuid::Uuid; /// /// This endpoint updates a collection with the provided details. pub async fn update_collection( + Path(collection_id): Path, Extension(user): Extension, Json(req): Json, ) -> Result, (StatusCode, String)> { // Call the handler - match update_collection_handler(&user.id, req).await { + match update_collection_handler(&user.id, collection_id, req).await { Ok(collection) => Ok(Json(collection)), Err(e) => { tracing::error!("Error updating collection: {}", e); diff --git a/web/src/api/buster_rest/collections/requests.ts b/web/src/api/buster_rest/collections/requests.ts index 2f959643d..916a62323 100644 --- a/web/src/api/buster_rest/collections/requests.ts +++ b/web/src/api/buster_rest/collections/requests.ts @@ -68,7 +68,9 @@ export const collectionsDeleteCollection = async (params: { /** Array of collection IDs to be deleted */ ids: string[]; }) => { - return await mainApi.delete('/collections', { params }).then((res) => res.data); + return await mainApi.delete('/collections', { + data: { ids: params.ids } + }).then((res) => res.data); }; // share collections diff --git a/web/src/api/buster_rest/metrics/requests.ts b/web/src/api/buster_rest/metrics/requests.ts index 656c3716f..5bc0769bd 100644 --- a/web/src/api/buster_rest/metrics/requests.ts +++ b/web/src/api/buster_rest/metrics/requests.ts @@ -52,7 +52,9 @@ export const updateMetric = async (params: UpdateMetricParams) => { }; export const deleteMetrics = async (params: { ids: string[] }) => { - return mainApi.delete(`/metrics/delete`, { params }).then((res) => res.data); + return mainApi.delete(`/metrics/delete`, { + data: { ids: params.ids } + }).then((res) => res.data); }; export const duplicateMetric = async (params: {