diff --git a/foods.db b/foods.db index 5a4e2b6..2b4de6f 100644 Binary files a/foods.db and b/foods.db differ diff --git a/src/create_tables.sql b/src/create_tables.sql index de99c88..f244c7f 100644 --- a/src/create_tables.sql +++ b/src/create_tables.sql @@ -4,5 +4,6 @@ CREATE TABLE IF NOT EXISTS food ( name TEXT NOT NULL, kc_per_serving INTEGER NOT NULL DEFAULT 0, target_servings INTEGER NOT NULL DEFAULT 1, - actual_servings INTEGER NOT NULL DEFAULT 0 + actual_servings INTEGER NOT NULL DEFAULT 0, + color TEXT NOT NULL DEFAULT 'white' ); diff --git a/src/main.rs b/src/main.rs index 420b75a..ca89720 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,6 +31,7 @@ struct Food { kc_per_serving: i32, target_servings: i32, actual_servings: i32, + color: String, } #[tokio::main] @@ -55,7 +56,7 @@ fn get_foods(conn: &Arc>) -> Vec { let conn = conn.lock().unwrap(); let mut stmt = conn .prepare( - "SELECT id, portion, name, kc_per_serving, target_servings, actual_servings FROM food", + "SELECT id, portion, name, kc_per_serving, target_servings, actual_servings, color FROM food", ) .unwrap(); let foods = stmt @@ -67,6 +68,7 @@ fn get_foods(conn: &Arc>) -> Vec { kc_per_serving: row.get(3).unwrap(), target_servings: row.get(4).unwrap(), actual_servings: row.get(5).unwrap(), + color: row.get(6).unwrap(), }) }) .unwrap() @@ -99,7 +101,7 @@ fn do_increase(conn: &Arc>, id: i32) { fn get_food(conn: &Arc>, id: i32) -> Food { let conn = conn.lock().unwrap(); - let mut stmt = conn.prepare("SELECT id, portion, name, kc_per_serving, target_servings, actual_servings FROM food WHERE id = ?1").unwrap(); + let mut stmt = conn.prepare("SELECT id, portion, name, kc_per_serving, target_servings, actual_servings, color FROM food WHERE id = ?1").unwrap(); let food = stmt .query_one((id,), |row| { Ok(Food { @@ -109,6 +111,7 @@ fn get_food(conn: &Arc>, id: i32) -> Food { kc_per_serving: row.get(3).unwrap(), target_servings: row.get(4).unwrap(), actual_servings: row.get(5).unwrap(), + color: row.get(6).unwrap(), }) }) .unwrap(); diff --git a/templates/food.html b/templates/food.html index 2f4ed33..17f5d72 100644 --- a/templates/food.html +++ b/templates/food.html @@ -1,4 +1,4 @@ -
+

{{ food.name }} diff --git a/templates/sum.html b/templates/sum.html index 7f66211..e86b650 100644 --- a/templates/sum.html +++ b/templates/sum.html @@ -1,3 +1,3 @@ -

+
Total: {{ sum }} kc.
\ No newline at end of file