This commit is contained in:
Stefan Menner
2025-06-16 16:52:00 +02:00
parent ed64cd886b
commit 41b1930c70
7 changed files with 28 additions and 14 deletions

5
.gitignore vendored
View File

@@ -20,3 +20,8 @@ Cargo.lock
# and can be added to the global gitignore or merged into this file. For a more nuclear # 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. # option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/ #.idea/
.env
.env.*
!.env.example
!.env.*.example
# Ignore the .env file that contains sensitive information

10
.vscode/settings.json vendored
View File

@@ -1,3 +1,11 @@
{ {
"cSpell.words": ["Quelle", "Verwendung"] "cSpell.words": [
"Herstellung",
"Kochen",
"Quelle",
"Raffination",
"serde",
"Stück",
"Verwendung"
]
} }

View File

@@ -8,7 +8,7 @@ license = "MIT"
repository = "ssh://git@gitea.merlinserver.de:2222/Stefan/merlin_env_helper.git" repository = "ssh://git@gitea.merlinserver.de:2222/Stefan/merlin_env_helper.git"
[dependencies] [dependencies]
diesel = "2.2.10" diesel = { version= "2.2.10", features = ["serde_json", "postgres", "uuid"]}
env_logger = "0.11.8" env_logger = "0.11.8"
log = "0.4.27" log = "0.4.27"
merlin_env_helper = { version = "0.2.0", registry = "merlin" } merlin_env_helper = { version = "0.2.0", registry = "merlin" }

2
src/db/mod.rs Normal file
View File

@@ -0,0 +1,2 @@
pub mod models;
pub use models::*;

View File

@@ -2,11 +2,13 @@
#![allow(unused)] #![allow(unused)]
#![allow(clippy::all)] #![allow(clippy::all)]
use diesel::{
prelude::Queryable,
sql_types::{Json, Uuid},
};
use uuid::Uuid;
#[derive(Queryable, Debug)] #[derive(Queryable, Debug)]
pub struct Icon { pub struct RowIcon {
pub id: Uuid, pub id: Uuid,
pub name: String, pub name: String,
pub content_type: Option<String>, pub content_type: Option<String>,
@@ -17,7 +19,7 @@ pub struct Icon {
} }
#[derive(Queryable, Debug)] #[derive(Queryable, Debug)]
pub struct Ingredient { pub struct RowIngredient {
pub id: Uuid, pub id: Uuid,
pub resource: Uuid, pub resource: Uuid,
pub quantity: i32, pub quantity: i32,
@@ -26,7 +28,7 @@ pub struct Ingredient {
} }
#[derive(Queryable, Debug)] #[derive(Queryable, Debug)]
pub struct Recipe { pub struct RowRecipe {
pub id: Uuid, pub id: Uuid,
pub resource: Uuid, pub resource: Uuid,
pub recipe_type: String, pub recipe_type: String,
@@ -35,7 +37,7 @@ pub struct Recipe {
} }
#[derive(Queryable, Debug)] #[derive(Queryable, Debug)]
pub struct Resource { pub struct RowResource {
pub id: Uuid, pub id: Uuid,
pub name: String, pub name: String,
pub title: String, pub title: String,
@@ -43,4 +45,3 @@ pub struct Resource {
pub icon: Option<Uuid>, pub icon: Option<Uuid>,
pub state: Option<Json>, pub state: Option<Json>,
} }

View File

@@ -1,6 +1,6 @@
mod db;
mod parse; mod parse;
mod types; mod types;
use std::{fs::File, io::Read}; use std::{fs::File, io::Read};
use parse::parse; use parse::parse;

View File

@@ -1,13 +1,11 @@
use std::collections::HashMap; use crate::types::{Duration, Icon, Ingredient, Recipe, RecipeType, Resource, ResourceState};
use regex::Regex; use regex::Regex;
use select::{ use select::{
document::Document, document::Document,
node::Node, node::Node,
predicate::{Attr, Name, Or}, predicate::{Attr, Name, Or},
}; };
use std::collections::HashMap;
use crate::types::{Duration, Icon, Ingredient, Recipe, RecipeType, Resource, ResourceState};
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
enum ParseType { enum ParseType {