Replace endpoint /calendar/schedule_recipe by /calendar/sheduled_recipe
This commit is contained in:
parent
4f739593b8
commit
9b89117a66
4 changed files with 8 additions and 7 deletions
|
|
@ -10,16 +10,17 @@ impl Connection {
|
||||||
async fn get<T>(&self, name: &str) -> Result<T>
|
async fn get<T>(&self, name: &str) -> Result<T>
|
||||||
where
|
where
|
||||||
T: FromStr,
|
T: FromStr,
|
||||||
|
T::Err: std::fmt::Display,
|
||||||
{
|
{
|
||||||
let v: String = sqlx::query_scalar("SELECT [value] FROM [Settings] WHERE [name] = $1")
|
let v: String = sqlx::query_scalar("SELECT [value] FROM [Settings] WHERE [name] = $1")
|
||||||
.bind(name)
|
.bind(name)
|
||||||
.fetch_one(&self.pool)
|
.fetch_one(&self.pool)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
T::from_str(&v).map_err(|_| {
|
T::from_str(&v).map_err(|error| {
|
||||||
DBError::Other(format!(
|
DBError::Other(format!(
|
||||||
"Can't convert string value \"{}\" when reading setting {}",
|
"Can't convert string value \"{}\" when reading setting {}. Original error: {}",
|
||||||
v, name
|
v, name, error
|
||||||
))
|
))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -225,8 +225,8 @@ async fn main() {
|
||||||
get(services::ron::calendar::get_scheduled_recipes),
|
get(services::ron::calendar::get_scheduled_recipes),
|
||||||
)
|
)
|
||||||
.route(
|
.route(
|
||||||
"/calendar/schedule_recipe",
|
"/calendar/scheduled_recipe",
|
||||||
post(services::ron::calendar::schedule_recipe)
|
post(services::ron::calendar::add_scheduled_recipe)
|
||||||
.delete(services::ron::calendar::rm_scheduled_recipe),
|
.delete(services::ron::calendar::rm_scheduled_recipe),
|
||||||
)
|
)
|
||||||
.route("/shopping_list", get(services::ron::shopping_list::get))
|
.route("/shopping_list", get(services::ron::shopping_list::get))
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ impl From<data::db::recipe::AddScheduledRecipeResult> for common::ron_api::Sched
|
||||||
}
|
}
|
||||||
|
|
||||||
#[debug_handler]
|
#[debug_handler]
|
||||||
pub async fn schedule_recipe(
|
pub async fn add_scheduled_recipe(
|
||||||
State(connection): State<db::Connection>,
|
State(connection): State<db::Connection>,
|
||||||
Extension(context): Extension<Context>,
|
Extension(context): Extension<Context>,
|
||||||
ExtractRon(ron): ExtractRon<common::ron_api::ScheduleRecipe>,
|
ExtractRon(ron): ExtractRon<common::ron_api::ScheduleRecipe>,
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ impl RecipeScheduler {
|
||||||
Ok(ScheduleRecipeResult::Ok)
|
Ok(ScheduleRecipeResult::Ok)
|
||||||
} else {
|
} else {
|
||||||
request::post::<ron_api::ScheduleRecipeResult, _>(
|
request::post::<ron_api::ScheduleRecipeResult, _>(
|
||||||
"calendar/schedule_recipe",
|
"calendar/scheduled_recipe",
|
||||||
ron_api::ScheduleRecipe {
|
ron_api::ScheduleRecipe {
|
||||||
recipe_id,
|
recipe_id,
|
||||||
date,
|
date,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue