Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#793] Export Metadata Subfields Description And Additional Descriptions #823

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/models/invenio_rdm_record_converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ def invenio_metadata(gf)
"creators": creators(gf.creator),
"title": gf.title.first,
"additional_titles": gf.title.last(gf.title.size-1).map{ |title| {"title": title, "type": "alternative_title", "lang": "eng"} },
"description": gf.description.first,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit frustrated. The last time I looked at this I misunderstood how it was storing descriptions based on what I was reading back to CSV. I took it again today with file ids included to try and help understand the data better and realized it was storing descriptions as an array. I guess it work out in the end /shrug.

"additional_descriptions": gf.description.last(gf.description.size-1).map{ |add_desc| {"description": add_desc, "type": "other", "lang": "eng"} },
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think leaving it as "other" to begin with will be fine. It's seemingly a required field so we need to put something, but really this will need to be looked over by a librarian I think.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an odd one, the way descriptions are stored. Anyway, what if there is only one description stored? Will this break?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll check, but I think that ["entry"].last(0) returns [] which is then [].map{} which again returns []

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, forgot to reply. What I said above is the case.

"subjects": SUBJECT_SCHEMES.map{ |subject_type| subjects_for_scheme(gf.send(subject_type), subject_type) }.flatten,
"formats": gf.mime_type,
"locations": gf.based_near.present? ? gf.based_near.shift.split("', ").map{ |location| {place: location.gsub("'", "")} } : {}
Expand Down
5 changes: 4 additions & 1 deletion spec/models/invenio_rdm_record_converter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
mesh: [mesh_term],
lcsh: [lcsh_term],
mime_type: 'application/pdf',
based_near: ["'Boston, Massachusetts, United States', 'East Peoria, Illinois, United States'"]
based_near: ["'Boston, Massachusetts, United States', 'East Peoria, Illinois, United States'"],
description: ["This is a generic file for specs only", "This is an additional description to help test"]
)
}
let(:json) do
Expand Down Expand Up @@ -58,6 +59,8 @@
"lang": "eng"
}
],
"description": generic_file.description.shift,
"additional_descriptions": [{"description": generic_file.description.last, "type": "other", "lang": "eng"}],
"subjects": [
{
"subject": "keyword subject",
Expand Down