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

Fix Discrepancy for publicationYear #303

Merged
merged 6 commits into from
Jan 29, 2024

Conversation

sorochak
Copy link
Contributor

@sorochak sorochak commented Jan 12, 2024

This PR fixes the discrepancy outlined in #295

Updated recordToDataCite mapping function to set publicationYear to dateRevised if it exists, otherwise use datePublished.

Updated generateCitation function to check for dateRevised before datePublished.

@sorochak sorochak added this to the Code Sprint 2023 - Metadata milestone Jan 12, 2024
@sorochak sorochak requested review from fostermh and n-a-t-e January 12, 2024 19:32
@sorochak sorochak self-assigned this Jan 12, 2024
@sorochak sorochak linked an issue Jan 12, 2024 that may be closed by this pull request
Copy link

github-actions bot commented Jan 12, 2024

Visit the preview URL for this PR (updated for commit c0407e9):

https://cioos-metadata-form--pr303-295-discrepancy-for-4eghpnip.web.app

(expires Sat, 17 Feb 2024 01:09:31 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 57eda2a7622dc877ccadb675a0532261c52b09fd

@sorochak
Copy link
Contributor Author

I guess this will only fix new records moving forward. Not already submitted data sets.

@sorochak sorochak requested a review from timvdstap January 12, 2024 20:03
@sorochak sorochak marked this pull request as draft January 12, 2024 22:10
@sorochak sorochak marked this pull request as ready for review January 12, 2024 23:04
Copy link
Member

@fostermh fostermh left a comment

Choose a reason for hiding this comment

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

this appears to resolve the problem mentioned in the issues but it would be good if tim or nate could also review.

@timvdstap
Copy link
Collaborator

I'm getting an error "Error occurred with DOI API" when I select Update DOI. Also, within the Metadata Entry Tool, the publication year doesn't show up in the recommended citation anymore.

@sorochak
Copy link
Contributor Author

@timvdstap I'm unable to reproduce your errors. Let's chat again when you're able to.

@timvdstap
Copy link
Collaborator

timvdstap commented Jan 17, 2024

We were able to reproduce the error, the revised date showed up correctly in DataCite when initially generating a draft DOI, only produced an error when trying to update an existing draft DOI.

@sorochak
Copy link
Contributor Author

sorochak commented Jan 18, 2024

Thanks for catching this error, @timvdstap !

The error occurred because the Date picker returns a Date object when the user selects a new date.

Firebase stores the date as a string. When clicking the save button, the Date object is updated to a date string.

In recordToDataCite.js (our metadata record to Datacite object mapping function), we expect date to be a string, and use .slice() to get the year. The .slice method can only be used on a string. If a user changes the date, and then attempts to update the DOI before saving the record, the .slice method then gets called on a Date object instead of a string and throws an error.

Updated DateInput to format the date as an ISO string instead of a Date object.
Updated DateInput.test to expect ISO string.

@timvdstap
Copy link
Collaborator

publicationYear seems to get updated now properly in DataCite, as well as in the recommended citation in the metadata form. I guess this only applies to newly created metadata records, so I'm not sure yet whether a 'Findable' record in DataCite will also get updated properly in DataCite.

@sorochak
Copy link
Contributor Author

should we merge this now then? Or do we need to figure out the Findable piece still ?

@timvdstap
Copy link
Collaborator

@sorochak You say that this will only impact new records moving forward, could you tell me why that is? The revision to the publicationYear will also be necessary for time series records that are currently published and are getting a new version. Or do you mean that existing versioned records do not automatically get their publicationYear updated?

I'm hesitant to try the Findable component through the emulator because a lot of published records in there (such as e.g. the JSP Time Series record) are incomplete compared to their current versions in the Hakai Catalogue. Seems like the only way to test whether publicationYear also gets updated properly for Findable records would be to either a) create a new Findable DOI through the emulator (which we'll have to then set to Registered so it doesn't get indexed), or b) merge this PR and address any bugs that arise.

@sorochak
Copy link
Contributor Author

My comment regarding that this change will only impact new records moving forward meant that existing versioned records do not automatically get their publicationYear updated. Those existing records would need to be updated manually for the publicationYear to change to the revision date.

@sorochak sorochak merged commit 625e639 into main Jan 29, 2024
3 checks passed
@sorochak sorochak deleted the 295-discrepancy-for-publicationyear branch January 29, 2024 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Discrepancy for publicationYear between Metadata Form and CKAN
3 participants