makes models and schema modules privates, adds re-exports
This commit is contained in:
Binary file not shown.
@@ -2,10 +2,12 @@ extern crate cookbook;
|
|||||||
extern crate diesel;
|
extern crate diesel;
|
||||||
|
|
||||||
use self::cookbook::*;
|
use self::cookbook::*;
|
||||||
use self::models::*;
|
|
||||||
|
|
||||||
use diesel::sqlite::SqliteConnection;
|
use diesel::sqlite::SqliteConnection;
|
||||||
use cookbook::models::fields::IngredientList;
|
use cookbook::{
|
||||||
|
ingredients::IngredientList,
|
||||||
|
recipes::Recipe,
|
||||||
|
};
|
||||||
|
|
||||||
struct IngredientListManager<'a>(&'a SqliteConnection, IngredientList);
|
struct IngredientListManager<'a>(&'a SqliteConnection, IngredientList);
|
||||||
|
|
||||||
@@ -28,6 +30,6 @@ fn main() {
|
|||||||
for rec in result {
|
for rec in result {
|
||||||
println!("*************\n{}\n({:?})", rec.title, rec.category);
|
println!("*************\n{}\n({:?})", rec.title, rec.category);
|
||||||
println!("-------------\n");
|
println!("-------------\n");
|
||||||
println!("{}", rec.ingredients.as_string());
|
println!("{}", IngredientListManager(&conn, rec.ingredients).display_lines());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ extern crate diesel;
|
|||||||
|
|
||||||
use std::io::{stdin};
|
use std::io::{stdin};
|
||||||
use diesel::SqliteConnection;
|
use diesel::SqliteConnection;
|
||||||
use self::cookbook::*;
|
use cookbook::*;
|
||||||
use self::models::{NewRecipe, fields::RecipeCategory, fields::IngredientList};
|
use cookbook::recipes::{NewRecipe, RecipeCategory};
|
||||||
|
use cookbook::ingredients::{IngredientList};
|
||||||
|
|
||||||
struct CreateRecipe<'a> {
|
struct CreateRecipe<'a> {
|
||||||
connection: &'a SqliteConnection,
|
connection: &'a SqliteConnection,
|
||||||
@@ -33,7 +34,7 @@ impl<'a> CreateRecipe<'a> {
|
|||||||
|
|
||||||
fn add_ingredient(&mut self, name: String) {
|
fn add_ingredient(&mut self, name: String) {
|
||||||
use crate::ingredients::*;
|
use crate::ingredients::*;
|
||||||
|
let name = name.trim();
|
||||||
// Check it exists or create
|
// Check it exists or create
|
||||||
match get_id_or_create(self.connection, &name) {
|
match get_id_or_create(self.connection, &name) {
|
||||||
Ok(id) => {
|
Ok(id) => {
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
extern crate diesel;
|
extern crate diesel;
|
||||||
extern crate dotenv;
|
extern crate dotenv;
|
||||||
|
|
||||||
pub mod schema;
|
mod schema;
|
||||||
pub mod models;
|
mod models;
|
||||||
|
|
||||||
mod importer;
|
mod importer;
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ pub fn establish_connection() -> SqliteConnection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub mod recipes {
|
pub mod recipes {
|
||||||
use crate::models::{Recipe};
|
pub use crate::models::{Recipe, NewRecipe, fields::RecipeCategory};
|
||||||
use super::{SqliteConnection, schema};
|
use super::{SqliteConnection, schema};
|
||||||
use super::diesel::prelude::*;
|
use super::diesel::prelude::*;
|
||||||
|
|
||||||
@@ -41,7 +41,11 @@ pub mod recipes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub mod ingredients {
|
pub mod ingredients {
|
||||||
use crate::models::{Ingredient, NewIngredient, fields::IngredientId};
|
pub use crate::models::{
|
||||||
|
Ingredient,
|
||||||
|
NewIngredient,
|
||||||
|
fields::{IngredientId, IngredientList},
|
||||||
|
};
|
||||||
use super::{SqliteConnection, schema};
|
use super::{SqliteConnection, schema};
|
||||||
use super::diesel::prelude::*;
|
use super::diesel::prelude::*;
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ extern crate cookbook;
|
|||||||
extern crate planner;
|
extern crate planner;
|
||||||
|
|
||||||
use self::cookbook::*;
|
use self::cookbook::*;
|
||||||
use self::cookbook::models::Recipe;
|
use self::cookbook::recipes::Recipe;
|
||||||
use self::planner::solver::{Variables, Domain, Problem};
|
use self::planner::solver::{Variables, Domain, Problem};
|
||||||
|
|
||||||
/// We want a mapping of the week meals (matin, midi, soir)
|
/// We want a mapping of the week meals (matin, midi, soir)
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ mod api {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Recipe {
|
impl Recipe {
|
||||||
fn from(rec: models::Recipe) -> Recipe {
|
fn from(rec: recipes::Recipe) -> Recipe {
|
||||||
Recipe {
|
Recipe {
|
||||||
id: rec.id,
|
id: rec.id,
|
||||||
title: rec.title,
|
title: rec.title,
|
||||||
|
|||||||
Reference in New Issue
Block a user