Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Commit

Permalink
fix: fixed ilcd parse issue and added more test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ocni-dtu committed Apr 1, 2024
1 parent f28f9c6 commit 25b2f09
Show file tree
Hide file tree
Showing 5 changed files with 3,464 additions and 12 deletions.
17 changes: 7 additions & 10 deletions src/epd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,13 @@ pub enum SubType {
Representative,
}

impl From<&String> for SubType {
fn from(value: &String) -> Self {
if value.to_ascii_lowercase().contains("representative") {
SubType::Representative
} else if value.to_ascii_lowercase().contains("specific") {
SubType::Specific
} else if value.to_ascii_lowercase().contains("industry") {
SubType::Industry
} else {
SubType::Generic
impl From<&Option<String>> for SubType {
fn from(value: &Option<String>) -> Self {
match value {
Some(_value) if _value.to_lowercase().contains("representative") => SubType::Representative,
Some(_value) if _value.to_lowercase().contains("specific") => SubType::Specific,
Some(_value) if _value.to_lowercase().contains("industry") => SubType::Industry,
_ => SubType::Generic,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ilcd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ pub struct Anies {
#[serde(rename_all = "camelCase")]
pub struct Anie {
pub name: String,
pub value: String,
pub value: Option<String>,
}

#[derive(Deserialize)]
Expand Down
2 changes: 1 addition & 1 deletion src/lcabyg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl From<&Vec<Stage>> for EPD {
name: node.external_source.clone(),
url: Some(node.external_url.clone()),
}),
subtype: SubType::from(&node.data_type),
subtype: SubType::from(&Some(node.data_type.clone())),
standard: if node.compliance == "A1" {
Standard::EN15804A1
} else {
Expand Down
Loading

0 comments on commit 25b2f09

Please sign in to comment.