diff --git a/backend/.sqlx/query-27e4da7727ef50e3600052bb18b55bdc4f326741f8fc171f69e3582e9a4c2cc0.json b/backend/.sqlx/query-27e4da7727ef50e3600052bb18b55bdc4f326741f8fc171f69e3582e9a4c2cc0.json index 8b610434..ea35a20a 100644 --- a/backend/.sqlx/query-27e4da7727ef50e3600052bb18b55bdc4f326741f8fc171f69e3582e9a4c2cc0.json +++ b/backend/.sqlx/query-27e4da7727ef50e3600052bb18b55bdc4f326741f8fc171f69e3582e9a4c2cc0.json @@ -28,8 +28,7 @@ "PORK", "PORK_AW", "FISH", - "UNKNOWN", - "POULTRY" + "UNKNOWN" ] } } diff --git a/backend/.sqlx/query-4213a8e106ce6df54947d3fe8029904886451deace483860146939369cef7b7a.json b/backend/.sqlx/query-4213a8e106ce6df54947d3fe8029904886451deace483860146939369cef7b7a.json index f9d403eb..302d234d 100644 --- a/backend/.sqlx/query-4213a8e106ce6df54947d3fe8029904886451deace483860146939369cef7b7a.json +++ b/backend/.sqlx/query-4213a8e106ce6df54947d3fe8029904886451deace483860146939369cef7b7a.json @@ -24,8 +24,7 @@ "PORK", "PORK_AW", "FISH", - "UNKNOWN", - "POULTRY" + "UNKNOWN" ] } } diff --git a/backend/.sqlx/query-c75751fea2daaa278fb010d6e42b1fdc13239d619fa4b8237f6298103d7b4bd0.json b/backend/.sqlx/query-c75751fea2daaa278fb010d6e42b1fdc13239d619fa4b8237f6298103d7b4bd0.json index ca27dabe..c2c55af0 100644 --- a/backend/.sqlx/query-c75751fea2daaa278fb010d6e42b1fdc13239d619fa4b8237f6298103d7b4bd0.json +++ b/backend/.sqlx/query-c75751fea2daaa278fb010d6e42b1fdc13239d619fa4b8237f6298103d7b4bd0.json @@ -24,8 +24,7 @@ "PORK", "PORK_AW", "FISH", - "UNKNOWN", - "POULTRY" + "UNKNOWN" ] } } diff --git a/backend/.sqlx/query-d3ba2ffec90b5cfc33c94c03b474bd6b02cd0ea603ac890a3f46c204810821d3.json b/backend/.sqlx/query-d3ba2ffec90b5cfc33c94c03b474bd6b02cd0ea603ac890a3f46c204810821d3.json index c5ca3b06..f972f355 100644 --- a/backend/.sqlx/query-d3ba2ffec90b5cfc33c94c03b474bd6b02cd0ea603ac890a3f46c204810821d3.json +++ b/backend/.sqlx/query-d3ba2ffec90b5cfc33c94c03b474bd6b02cd0ea603ac890a3f46c204810821d3.json @@ -28,8 +28,7 @@ "PORK", "PORK_AW", "FISH", - "UNKNOWN", - "POULTRY" + "UNKNOWN" ] } } diff --git a/backend/.sqlx/query-d704fef7fa865bb6144798e4060ef8ec2cc269390c6b5f7d32684f8095b58984.json b/backend/.sqlx/query-d704fef7fa865bb6144798e4060ef8ec2cc269390c6b5f7d32684f8095b58984.json index 7398d344..ae0f4da7 100644 --- a/backend/.sqlx/query-d704fef7fa865bb6144798e4060ef8ec2cc269390c6b5f7d32684f8095b58984.json +++ b/backend/.sqlx/query-d704fef7fa865bb6144798e4060ef8ec2cc269390c6b5f7d32684f8095b58984.json @@ -24,8 +24,7 @@ "PORK", "PORK_AW", "FISH", - "UNKNOWN", - "POULTRY" + "UNKNOWN" ] } } diff --git a/backend/.sqlx/query-e7593d119608a3c761ea8bf2ad83ca4cf6b2e8184e550fc67dc1faa1c729c3ca.json b/backend/.sqlx/query-e7593d119608a3c761ea8bf2ad83ca4cf6b2e8184e550fc67dc1faa1c729c3ca.json index 6471dbd9..2e461ab4 100644 --- a/backend/.sqlx/query-e7593d119608a3c761ea8bf2ad83ca4cf6b2e8184e550fc67dc1faa1c729c3ca.json +++ b/backend/.sqlx/query-e7593d119608a3c761ea8bf2ad83ca4cf6b2e8184e550fc67dc1faa1c729c3ca.json @@ -28,8 +28,7 @@ "PORK", "PORK_AW", "FISH", - "UNKNOWN", - "POULTRY" + "UNKNOWN" ] } } diff --git a/backend/migrations/20240313130248_poultry_checker.down.sql b/backend/migrations/20240313130248_poultry_checker.down.sql deleted file mode 100644 index 82307ae2..00000000 --- a/backend/migrations/20240313130248_poultry_checker.down.sql +++ /dev/null @@ -1,3 +0,0 @@ --- Add down migration script here -UPDATE food SET food_type = 'UNKNOWN' WHERE food_type = 'POULTRY'; - diff --git a/backend/migrations/20240313130248_poultry_checker.up.sql b/backend/migrations/20240313130248_poultry_checker.up.sql deleted file mode 100644 index 0005228e..00000000 --- a/backend/migrations/20240313130248_poultry_checker.up.sql +++ /dev/null @@ -1,5 +0,0 @@ --- Add up migration script here -ALTER TYPE meal_type add value 'POULTRY'; -COMMIT; - -UPDATE food SET food_type = 'POULTRY' WHERE name ~ '(?i)ente|chicken|pute|geflügel|h[üäua]hn'; \ No newline at end of file diff --git a/backend/src/layer/data/swka_parser/html_parser.rs b/backend/src/layer/data/swka_parser/html_parser.rs index e7e2a446..f8cc3d5e 100644 --- a/backend/src/layer/data/swka_parser/html_parser.rs +++ b/backend/src/layer/data/swka_parser/html_parser.rs @@ -133,8 +133,6 @@ lazy_static! { static ref VOLUME_REGEX: Regex = Regex::new(r"([0-9]*),([0-9]{2}) l").expect(REGEX_PARSE_E_MSG); static ref ID_REGEX: Regex = Regex::new(r"[0-9]{18,}").expect(REGEX_PARSE_E_MSG); - - static ref POULTRY_REGEX: Regex = Regex::new(r"(?i)ente|chicken|pute|geflügel|h[üäua]hn").expect(REGEX_PARSE_E_MSG); } const DISH_NODE_CLASS_SELECTOR_PREFIX: &str = "tr.mt-"; @@ -318,13 +316,12 @@ impl HTMLParser { } fn get_dish(dish_node: &ElementRef) -> Option { - let name = Self::get_dish_name(dish_node)?; Some(Dish { - food_type: Self::get_food_type(dish_node, &name).unwrap_or(FoodType::Unknown), - name, + name: Self::get_dish_name(dish_node)?, price: Self::get_dish_price(dish_node), allergens: Self::get_dish_allergens(dish_node).unwrap_or_default(), additives: Self::get_dish_additives(dish_node).unwrap_or_default(), + food_type: Self::get_dish_type(dish_node).unwrap_or(FoodType::Unknown), env_score: Self::get_dish_env_score(dish_node), nutrition_data: Self::get_dish_nutrition_data(dish_node), }) @@ -400,17 +397,7 @@ impl HTMLParser { .collect() } - fn get_food_type(dish_node: &ElementRef, name: &str) -> Option { - let preliminary_dish_type = Self::get_preliminary_food_type(dish_node); - if (preliminary_dish_type.is_none() || Some(FoodType::Unknown) == preliminary_dish_type) - && Self::is_poultry(name) - { - return Some(FoodType::Poultry); - } - preliminary_dish_type - } - - fn get_preliminary_food_type(dish_node: &ElementRef) -> Option { + fn get_dish_type(dish_node: &ElementRef) -> Option { let dish_type_node = dish_node.select(&DISH_TYPE_NODE_CLASS_SELECTOR).next()?; dish_type_node .value() @@ -418,10 +405,6 @@ impl HTMLParser { .map(FoodType::parse) } - fn is_poultry(name: &str) -> bool { - POULTRY_REGEX.captures(name).is_some() - } - fn get_dish_env_score(dish_node: &ElementRef) -> Option { let env_info = ParseEnvironmentInfo { co2_rating: Self::get_co2_rating(dish_node)?, @@ -606,7 +589,7 @@ mod tests { let file_contents = read_from_file(path).unwrap(); let canteen_data = HTMLParser::new().transform(&file_contents, 42_u32).unwrap(); - //let remove_for_producton = write_output_to_file(path, &canteen_data); + //let _ = write_output_to_file(path, &canteen_data); let expected = read_from_file(&path.replace(".html", ".txt")) .unwrap() .replace("\r\n", "\n"); diff --git a/backend/src/layer/data/swka_parser/test_data/test_mensa_moltke.txt b/backend/src/layer/data/swka_parser/test_data/test_mensa_moltke.txt index 1b3ab486..1bec20db 100644 --- a/backend/src/layer/data/swka_parser/test_data/test_mensa_moltke.txt +++ b/backend/src/layer/data/swka_parser/test_data/test_mensa_moltke.txt @@ -297,7 +297,7 @@ We, ], additives: [], - food_type: Poultry, + food_type: Unknown, env_score: Some( ParseEnvironmentInfo { co2_rating: 1, diff --git a/backend/src/layer/data/swka_parser/test_data/test_normal.txt b/backend/src/layer/data/swka_parser/test_data/test_normal.txt index 1b817220..54e83424 100644 --- a/backend/src/layer/data/swka_parser/test_data/test_normal.txt +++ b/backend/src/layer/data/swka_parser/test_data/test_normal.txt @@ -19,7 +19,7 @@ We, ], additives: [], - food_type: Poultry, + food_type: Unknown, env_score: Some( ParseEnvironmentInfo { co2_rating: 1, @@ -783,7 +783,7 @@ We, ], additives: [], - food_type: Poultry, + food_type: Unknown, env_score: None, nutrition_data: None, }, @@ -4829,7 +4829,7 @@ Colorant, AntioxidantAgents, ], - food_type: Poultry, + food_type: Unknown, env_score: None, nutrition_data: None, }, diff --git a/backend/src/layer/logic/mealplan_management/relation_resolver.rs b/backend/src/layer/logic/mealplan_management/relation_resolver.rs index 14d82254..a3989bba 100644 --- a/backend/src/layer/logic/mealplan_management/relation_resolver.rs +++ b/backend/src/layer/logic/mealplan_management/relation_resolver.rs @@ -315,7 +315,7 @@ mod test { assert!(450.0 < average); assert!(460.0 > average); - let dishes = []; + let dishes = vec![]; let average = RelationResolver::::average(dishes.iter()); assert!((average - 0.0).abs() < f64::EPSILON); } diff --git a/backend/src/util.rs b/backend/src/util.rs index aeb25952..23e5230b 100644 --- a/backend/src/util.rs +++ b/backend/src/util.rs @@ -139,8 +139,6 @@ pub enum FoodType { PorkAw, /// This meal contains fish. Fish, - /// This meal contains poultry, such as chicken, turkey, or similar - Poultry, /// It is unknown whether this meal contains any meat or not. Unknown, }