From 5e738501ddb185e35f2b9423f771023379a320ee Mon Sep 17 00:00:00 2001 From: Tobias Reisinger Date: Wed, 29 Nov 2023 15:59:44 +0100 Subject: [PATCH] Fix bugs to align with tests --- emgauwa-core/src/handlers/v1/schedules.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/emgauwa-core/src/handlers/v1/schedules.rs b/emgauwa-core/src/handlers/v1/schedules.rs index bd521aa..cb58d92 100644 --- a/emgauwa-core/src/handlers/v1/schedules.rs +++ b/emgauwa-core/src/handlers/v1/schedules.rs @@ -13,6 +13,7 @@ use crate::handlers::errors::ApiError; pub struct RequestSchedule { name: String, periods: DbPeriods, + #[serde(default)] // empty tags are allowed tags: Vec, } @@ -60,7 +61,7 @@ pub async fn show( .await? .ok_or(DatabaseError::NotFound)?; - let return_schedule = Schedule::from_db_model(&mut pool_conn, schedule); + let return_schedule = Schedule::from_db_model(&mut pool_conn, schedule)?; Ok(HttpResponse::Ok().json(return_schedule)) } @@ -77,7 +78,7 @@ pub async fn add( .set_tags(&mut pool_conn, data.tags.as_slice()) .await?; - let return_schedule = Schedule::from_db_model(&mut pool_conn, new_schedule); + let return_schedule = Schedule::from_db_model(&mut pool_conn, new_schedule)?; Ok(HttpResponse::Created().json(return_schedule)) } @@ -135,7 +136,7 @@ pub async fn update( .set_tags(&mut pool_conn, data.tags.as_slice()) .await?; - let return_schedule = Schedule::from_db_model(&mut pool_conn, schedule); + let return_schedule = Schedule::from_db_model(&mut pool_conn, schedule)?; Ok(HttpResponse::Ok().json(return_schedule)) }