diff --git a/.gitignore b/.gitignore index ab951f8..d37733d 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,8 @@ Cargo.lock # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ + .env + .env.* + !.env.example + !.env.*.example +# Ignore the .env file that contains sensitive information \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 89e15c6..204a869 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,11 @@ { - "cSpell.words": ["Quelle", "Verwendung"] + "cSpell.words": [ + "Herstellung", + "Kochen", + "Quelle", + "Raffination", + "serde", + "Stück", + "Verwendung" + ] } diff --git a/Cargo.toml b/Cargo.toml index 905120c..981271e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT" repository = "ssh://git@gitea.merlinserver.de:2222/Stefan/merlin_env_helper.git" [dependencies] -diesel = "2.2.10" +diesel = { version= "2.2.10", features = ["serde_json", "postgres", "uuid"]} env_logger = "0.11.8" log = "0.4.27" merlin_env_helper = { version = "0.2.0", registry = "merlin" } diff --git a/src/db/mod.rs b/src/db/mod.rs new file mode 100644 index 0000000..7609346 --- /dev/null +++ b/src/db/mod.rs @@ -0,0 +1,2 @@ +pub mod models; +pub use models::*; diff --git a/src/db/models.rs b/src/db/models.rs index a2323f4..34145ff 100644 --- a/src/db/models.rs +++ b/src/db/models.rs @@ -2,11 +2,13 @@ #![allow(unused)] #![allow(clippy::all)] +use diesel::{ + prelude::Queryable, + sql_types::{Json, Uuid}, +}; - -use uuid::Uuid; #[derive(Queryable, Debug)] -pub struct Icon { +pub struct RowIcon { pub id: Uuid, pub name: String, pub content_type: Option, @@ -17,7 +19,7 @@ pub struct Icon { } #[derive(Queryable, Debug)] -pub struct Ingredient { +pub struct RowIngredient { pub id: Uuid, pub resource: Uuid, pub quantity: i32, @@ -26,7 +28,7 @@ pub struct Ingredient { } #[derive(Queryable, Debug)] -pub struct Recipe { +pub struct RowRecipe { pub id: Uuid, pub resource: Uuid, pub recipe_type: String, @@ -35,7 +37,7 @@ pub struct Recipe { } #[derive(Queryable, Debug)] -pub struct Resource { +pub struct RowResource { pub id: Uuid, pub name: String, pub title: String, @@ -43,4 +45,3 @@ pub struct Resource { pub icon: Option, pub state: Option, } - diff --git a/src/main.rs b/src/main.rs index eb7c0e4..09539a7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ +mod db; mod parse; mod types; - use std::{fs::File, io::Read}; use parse::parse; diff --git a/src/parse/mod.rs b/src/parse/mod.rs index ffd4946..5eae1e8 100644 --- a/src/parse/mod.rs +++ b/src/parse/mod.rs @@ -1,13 +1,11 @@ -use std::collections::HashMap; - +use crate::types::{Duration, Icon, Ingredient, Recipe, RecipeType, Resource, ResourceState}; use regex::Regex; use select::{ document::Document, node::Node, predicate::{Attr, Name, Or}, }; - -use crate::types::{Duration, Icon, Ingredient, Recipe, RecipeType, Resource, ResourceState}; +use std::collections::HashMap; #[derive(Debug, PartialEq, Eq)] enum ParseType {