different colors for different foods!

This commit is contained in:
Khaïs COLIN 2025-10-19 14:33:32 +02:00
parent 5cf4a12eae
commit e47b9810d2
Signed by: logistic-bot
SSH key fingerprint: SHA256:RlpiqKeXpcPFZZ4y9Ou4xi2M8OhRJovIwDlbCaMsuAo
5 changed files with 9 additions and 5 deletions

View file

@ -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<Mutex<Connection>>) -> Vec<Food> {
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<Mutex<Connection>>) -> Vec<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()
@ -99,7 +101,7 @@ fn do_increase(conn: &Arc<Mutex<Connection>>, id: i32) {
fn get_food(conn: &Arc<Mutex<Connection>>, 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<Mutex<Connection>>, 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();