Fix bugs to align with tests

This commit is contained in:
Tobias Reisinger 2023-11-29 15:59:44 +01:00
parent fdca5b7277
commit 5e738501dd
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE

View file

@ -13,6 +13,7 @@ use crate::handlers::errors::ApiError;
pub struct RequestSchedule {
name: String,
periods: DbPeriods,
#[serde(default)] // empty tags are allowed
tags: Vec<String>,
}
@ -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))
}