diff --git a/thoth-api/src/graphql/model.rs b/thoth-api/src/graphql/model.rs index 394fa6e3..dcb722c0 100644 --- a/thoth-api/src/graphql/model.rs +++ b/thoth-api/src/graphql/model.rs @@ -3313,11 +3313,11 @@ impl Series { } pub fn issn_print(&self) -> Option<&String> { - self.issn_print.as_ref() + self.issn_print.as_ref() } pub fn issn_digital(&self) -> Option<&String> { - self.issn_digital.as_ref() + self.issn_digital.as_ref() } #[graphql(description = "URL of the series' landing page")] diff --git a/thoth-export-server/src/marc21/marc21record_thoth.rs b/thoth-export-server/src/marc21/marc21record_thoth.rs index 3f22f917..3dc8c350 100644 --- a/thoth-export-server/src/marc21/marc21record_thoth.rs +++ b/thoth-export-server/src/marc21/marc21record_thoth.rs @@ -635,10 +635,29 @@ impl Marc21Field for WorkIssues { f.add_subfield(b"v", format!("vol. {}.", self.issue_ordinal).as_bytes()) }) .and_then(|f| f.add_subfield(b"x", self.series.issn_digital.as_deref().unwrap_or_default().as_bytes())) - .and_then(|f| f.add_subfield(b"x", self.series.issn_print.as_deref().unwrap_or_default().as_bytes())) + .and_then(|f| { + f.add_subfield( + b"x", + self.series + .issn_digital + .as_deref() + .unwrap_or_default() + .as_bytes(), + ) + }) + .and_then(|f| { + f.add_subfield( + b"x", + self.series + .issn_print + .as_deref() + .unwrap_or_default() + .as_bytes(), + ) + }) .and_then(|f| builder.add_field(f))?; - } - Ok(()) + } + Ok(()) } } diff --git a/thoth-export-server/src/xml/onix3_thoth.rs b/thoth-export-server/src/xml/onix3_thoth.rs index aa68f0b2..8d3890a9 100644 --- a/thoth-export-server/src/xml/onix3_thoth.rs +++ b/thoth-export-server/src/xml/onix3_thoth.rs @@ -1150,7 +1150,7 @@ impl XmlElementBlock for WorkIssues { })?; write_element_block("IDValue", w, |w| { w.write(XmlEvent::Characters( - &self.series.issn_digital.replace('-', ""), + &self.series.issn_digital.as_deref().unwrap_or_default().replace('-', ""), )) .map_err(|e| e.into()) }) @@ -1641,8 +1641,8 @@ mod tests { series: WorkIssuesSeries { series_type: thoth_client::SeriesType::JOURNAL, series_name: "Name of series".to_string(), - issn_print: "1234-5678".to_string(), - issn_digital: "8765-4321".to_string(), + issn_print: Some("1234-5678".to_string()), + issn_digital: Some("8765-4321".to_string()), series_url: Some("https://series.url".to_string()), series_description: None, series_cfp_url: Some("https://series.cfp.url".to_string()), @@ -1700,7 +1700,7 @@ mod tests { // Change all possible values to test that output is updated test_issue.issue_ordinal = 2; test_issue.series.series_name = "Different series".to_string(); - test_issue.series.issn_digital = "1111-2222".to_string(); + test_issue.series.issn_digital = Some("1111-2222".to_string()); test_issue.series.series_url = None; test_issue.series.series_cfp_url = None; let output = generate_test_output(true, &test_issue);