mirror of
https://github.com/zaphar/kitchen.git
synced 2025-07-21 19:29:49 -04:00
Utilize the plan_table for listing, deleting, and saving meal plans
This commit is contained in:
parent
08e7f41be1
commit
ba825258bb
@ -172,6 +172,26 @@
|
||||
},
|
||||
"query": "insert into category_mappings\n (user_id, ingredient_name, category_name)\n values (?, ?, ?)\n on conflict (user_id, ingredient_name)\n do update set category_name=excluded.category_name\n"
|
||||
},
|
||||
"27aa0a21f534cdf580841fa111136fc26cf1a0ca4ddb308c12f3f8f5a62d6178": {
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"nullable": [],
|
||||
"parameters": {
|
||||
"Right": 2
|
||||
}
|
||||
},
|
||||
"query": "delete from plan_table where user_id = ? and plan_date = ?"
|
||||
},
|
||||
"288535e7b9e1f02ad1b677e3dddc85f38c0766ce16d26fc1bdd2bf90ab9a7f7c": {
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"nullable": [],
|
||||
"parameters": {
|
||||
"Right": 2
|
||||
}
|
||||
},
|
||||
"query": "insert into plan_table (user_id, plan_date) values (?, ?)\n on conflict (user_id, plan_date) do nothing;"
|
||||
},
|
||||
"2e076acd2405d234daaa866e5a2ac1e10989fc8d2820f90aa722464a7b17db6b": {
|
||||
"describe": {
|
||||
"columns": [
|
||||
|
@ -554,6 +554,9 @@ impl APIStore for SqliteStore {
|
||||
)
|
||||
.execute(&mut transaction)
|
||||
.await?;
|
||||
sqlx::query_file!("src/web/storage/init_meal_plan.sql", user_id, date)
|
||||
.execute(&mut transaction)
|
||||
.await?;
|
||||
for (id, count) in recipe_counts {
|
||||
sqlx::query_file!(
|
||||
"src/web/storage/save_meal_plan.sql",
|
||||
@ -637,6 +640,13 @@ impl APIStore for SqliteStore {
|
||||
debug!("Processing delete request");
|
||||
let user_id = user_id.as_ref();
|
||||
let mut transaction = self.pool.as_ref().begin().await?;
|
||||
sqlx::query!(
|
||||
"delete from plan_table where user_id = ? and plan_date = ?",
|
||||
user_id,
|
||||
date
|
||||
)
|
||||
.execute(&mut transaction)
|
||||
.await?;
|
||||
sqlx::query!(
|
||||
"delete from plan_recipes where user_id = ? and plan_date = ?",
|
||||
user_id,
|
||||
|
@ -504,10 +504,15 @@ impl MessageMapper<Message, AppState> for StateMachine {
|
||||
.fetch_inventory_for_date(&date)
|
||||
.await
|
||||
.expect("Failed to fetch inventory_data for date");
|
||||
original_copy.plan_dates.insert(date.clone());
|
||||
original_copy.modified_amts = modified;
|
||||
original_copy.filtered_ingredients = filtered;
|
||||
original_copy.extras = extras;
|
||||
local_store.set_plan_date(&date);
|
||||
store
|
||||
.store_plan_for_date(vec![], &date)
|
||||
.await
|
||||
.expect("Failed to init meal plan for date");
|
||||
|
||||
original.set(original_copy);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user