Skip to content

Commit

Permalink
Add related work contribution full_name to client query, and use in c…
Browse files Browse the repository at this point in the history
…onstructing 505 field/add to existing tests
  • Loading branch information
rhigman committed Nov 20, 2023
1 parent 30a2e8a commit 17be2ec
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
1 change: 1 addition & 0 deletions thoth-client/assets/queries.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ fragment Work on Work {
contributionType
firstName
lastName
fullName
contributionOrdinal
contributor {
orcid
Expand Down
16 changes: 4 additions & 12 deletions thoth-export-server/src/marc21/marc21record_thoth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,16 +575,7 @@ fn toc_field(relations: &[WorkRelations]) -> ThothResult<FieldRepr> {
.related_work
.contributions
.iter()
// Ideally we'd use full_name rather than first_name + last_name
// TODO Switch this out (will require updates to existing tests)
// .map(|c| c.full_name)
.map(|c| {
format!(
"{} {}",
c.first_name.clone().unwrap_or_default(),
c.last_name
)
})
.map(|c| c.full_name.clone())
.collect::<Vec<_>>()
.join(", ");
toc_field = toc_field.add_subfield(b"g", format!("{}.", chapter_number))?;
Expand Down Expand Up @@ -1067,6 +1058,7 @@ pub(crate) mod tests {
contribution_type: thoth_client::ContributionType::AUTHOR,
first_name: Some("Chapter-One".to_string()),
last_name: "Author".to_string(),
full_name: "Chapter-One Author".to_string(),
contribution_ordinal: 1,
contributor: WorkRelationsRelatedWorkContributionsContributor { orcid: None },
affiliations: vec![],
Expand Down Expand Up @@ -1553,7 +1545,7 @@ pub(crate) mod tests {
.related_work
.contributions
.append(&mut vec![relation.related_work.contributions[0].clone()]);
relation.related_work.contributions[1].last_name = "Second-Author".to_string();
relation.related_work.contributions[1].full_name = "Chapter-One Second-Author".to_string();
// Not strictly required, but let's keep things tidy
relation.related_work.contributions[1].contribution_ordinal = 2;
let relations = vec![relation];
Expand All @@ -1575,7 +1567,7 @@ pub(crate) mod tests {
let mut second_relation = test_relation();
second_relation.relation_ordinal = 2;
second_relation.related_work.full_title = "Chapter Two".to_string();
second_relation.related_work.contributions[0].first_name = Some("Chapter-Two".to_string());
second_relation.related_work.contributions[0].full_name = "Chapter-Two Author".to_string();
// Place in reverse order and test correct re-ordering
let relations = vec![second_relation, test_relation()];
let expected = Ok(FieldRepr::from((b"505", "00"))
Expand Down
1 change: 1 addition & 0 deletions thoth-export-server/src/xml/doideposit_crossref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,7 @@ mod tests {
contribution_type: ContributionType::AUTHOR,
first_name: Some("Chapter One".to_string()),
last_name: "Author".to_string(),
full_name: "Chapter One Author".to_string(),
contribution_ordinal: 1,
contributor: WorkRelationsRelatedWorkContributionsContributor {
orcid: Some(
Expand Down

0 comments on commit 17be2ec

Please sign in to comment.