mirror of
https://github.com/zaphar/kitchen.git
synced 2025-07-21 19:29:49 -04:00
Merge into DAO
This commit is contained in:
parent
5a7ea05522
commit
a96f175e9b
@ -21,7 +21,9 @@ pub struct Api {
|
||||
}
|
||||
|
||||
impl Api {
|
||||
// mealplan
|
||||
pub fn new_recipe_from_str(&self, input: &str) {}
|
||||
|
||||
pub fn new_mealplan_from_str(&self, input: &str) {}
|
||||
}
|
||||
|
||||
impl From<SqliteBackend> for Api {
|
||||
|
@ -237,7 +237,7 @@ impl<'conn> TxHandle<'conn> {
|
||||
let id: Uuid = r.get(0)?;
|
||||
let title: String = r.get(1)?;
|
||||
let desc: String = r.get(2)?;
|
||||
Ok(Recipe::new_id(id, title, desc))
|
||||
Ok(Recipe::new_with_id(id, title, desc))
|
||||
}
|
||||
|
||||
fn map_ingredient_row(r: &rusqlite::Row) -> Result<Ingredient, rusqlite::Error> {
|
||||
|
@ -56,7 +56,7 @@ impl Mealplan {
|
||||
/// A Recipe with a title, description, and a series of steps.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct Recipe {
|
||||
pub id: uuid::Uuid, // TODO(jwall): use uuid instead?
|
||||
pub id: uuid::Uuid,
|
||||
pub title: String,
|
||||
pub desc: String,
|
||||
pub steps: Vec<Step>,
|
||||
@ -72,7 +72,7 @@ impl Recipe {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_id<S: Into<String>>(id: uuid::Uuid, title: S, desc: S) -> Self {
|
||||
pub fn new_with_id<S: Into<String>>(id: uuid::Uuid, title: S, desc: S) -> Self {
|
||||
Self {
|
||||
id: id,
|
||||
title: title.into(),
|
||||
@ -120,18 +120,6 @@ impl Recipe {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct StepKey(i64, i64);
|
||||
|
||||
impl StepKey {
|
||||
pub fn recipe_id(&self) -> i64 {
|
||||
self.0
|
||||
}
|
||||
pub fn step_idx(&self) -> i64 {
|
||||
self.1
|
||||
}
|
||||
}
|
||||
|
||||
/// A Recipe step. It has the time for the step if there is one, instructions, and an ingredients
|
||||
/// list.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
@ -150,17 +138,6 @@ impl Step {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_id<S: Into<String>>(
|
||||
prep_time: Option<std::time::Duration>,
|
||||
instructions: S,
|
||||
) -> Self {
|
||||
Self {
|
||||
prep_time: prep_time,
|
||||
instructions: instructions.into(),
|
||||
ingredients: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_ingredients<Iter>(&mut self, ingredients: Iter)
|
||||
where
|
||||
Iter: IntoIterator<Item = Ingredient>,
|
||||
@ -200,7 +177,7 @@ impl Ingredient {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_id<S: Into<String>>(
|
||||
pub fn new_with_id<S: Into<String>>(
|
||||
id: i64,
|
||||
name: S,
|
||||
form: Option<String>,
|
||||
|
@ -233,8 +233,3 @@ fn test_ingredient_display() {
|
||||
assert_eq!(format!("{}", i), expected);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_recipe_display() {
|
||||
todo!()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user