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

Timx 270 date bug fix #160

Merged
merged 2 commits into from
Apr 4, 2024
Merged

Timx 270 date bug fix #160

merged 2 commits into from
Apr 4, 2024

Conversation

ehanson8
Copy link
Contributor

@ehanson8 ehanson8 commented Apr 4, 2024

Purpose and background context

Bug fix based on this Sentry error

How can a reviewer manually see the effects of these changes?

Run the following command on the main branch and observe the invalid dates values from the publishers field in alma-transformed-records.json:

pipenv run transform -i tests/fixtures/marc/marc_record_all_fields.xml -o output/alma-transformed-records.json -s alma

Then run it on the TIMX-270-date-bug-fix to observe that the invalid values no longer appear.

Includes new or updated dependencies?

YES

Changes expectations for external applications?

NO

What are the relevant tickets?

Developer

  • All new ENV is documented in README
  • All new ENV has been added to staging and production environments
  • All related Jira tickets are linked in commit message(s)
  • Stakeholder approval has been confirmed (or is not needed)

Code Reviewer(s)

  • The commit message is clear and follows our guidelines (not just this PR message)
  • There are appropriate tests covering any new functionality
  • The provided documentation is sufficient for understanding any new functionality introduced
  • Any manual tests have been performed and verified
  • New dependencies are appropriate or there were no changes

Why these changes are being introduced:
* Fixing date error reported by Sentry

How this addresses that need:
* Add date validation to create_dates_and_locations_from_publishers method
* Add unit test and update Marc unit tests to drop invalid date values

Side effects of this change:
* None

Relevant ticket(s):
* https://mitlibraries.atlassian.net/browse/TIMX-270
Copy link
Contributor

@ghukill ghukill left a comment

Choose a reason for hiding this comment

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

Looks good to me! Seems pretty straightfoward: applying the validate_date() helper before inserting into dates.

Comment on lines +41 to +48
assert Transformer.create_dates_and_locations_from_publishers(fields) == {
"timdex_record_id": "abc123",
"publishers": [
timdex.Publisher(name="Publisher", date="2018", location="Location")
],
"dates": [timdex.Date(kind="Publication date", value="2018")],
"locations": [timdex.Location(value="Location", kind="Place of Publication")],
}
Copy link
Contributor

Choose a reason for hiding this comment

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

With this broken out into a method, nice and easy to test, I dig it.

@ehanson8 ehanson8 merged commit 008e20c into main Apr 4, 2024
3 checks passed
@ehanson8 ehanson8 deleted the TIMX-270-date-bug-fix branch April 4, 2024 17:27
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.

2 participants