Fix bugs to align with tests
This commit is contained in:
parent
fdca5b7277
commit
5e738501dd
1 changed files with 4 additions and 3 deletions
|
@ -13,6 +13,7 @@ use crate::handlers::errors::ApiError;
|
||||||
pub struct RequestSchedule {
|
pub struct RequestSchedule {
|
||||||
name: String,
|
name: String,
|
||||||
periods: DbPeriods,
|
periods: DbPeriods,
|
||||||
|
#[serde(default)] // empty tags are allowed
|
||||||
tags: Vec<String>,
|
tags: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +61,7 @@ pub async fn show(
|
||||||
.await?
|
.await?
|
||||||
.ok_or(DatabaseError::NotFound)?;
|
.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))
|
Ok(HttpResponse::Ok().json(return_schedule))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +78,7 @@ pub async fn add(
|
||||||
.set_tags(&mut pool_conn, data.tags.as_slice())
|
.set_tags(&mut pool_conn, data.tags.as_slice())
|
||||||
.await?;
|
.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))
|
Ok(HttpResponse::Created().json(return_schedule))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +136,7 @@ pub async fn update(
|
||||||
.set_tags(&mut pool_conn, data.tags.as_slice())
|
.set_tags(&mut pool_conn, data.tags.as_slice())
|
||||||
.await?;
|
.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))
|
Ok(HttpResponse::Ok().json(return_schedule))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue