UCSCLibrary / dams_project_mgmt

DAMS purpose is to provide access to digitized and born-digital UCSC Special Collections content. This repository is used for project planning. It holds the task tickets and roadmap for the different projects under DAMS.
2 stars 0 forks source link

[8] Properly handle all date fields when importing #517

Closed bkiahstroud closed 2 years ago

bkiahstroud commented 2 years ago

Ref #498

Summary

Similar to dateCreated (#498), dateDigitized and datePublished will also throw errors on the edit form if they aren’t full dates (YYYY-MM-DD). This behavior appears to be coming from how Hyrax displays fields that use date picker inputs

Related thread in Slack: link

Proposed Solutions

Archived 1. “Sanitize” the values for `dateDigitized` and `datePublished` like we do for `dateCreated` (convert YYYY values into full dates) a. Con: exported data may not match imported data 2. Change the inputs on the Hyrax form from [date pickers](https://share.getcloudapp.com/bLuKdvJg) to raw text inputs

Acceptance Criteria

rschwab commented 2 years ago

datePublished and dateDigitized should be changed to plain text fields so that YYYY values can be imported and exported without being converted. We don't have a need for these to be sortable beyond string sorting, so they can be stored in the repo as strings not datetimes. The edit form should also be a text input rather than a date picker.

dateOfSituation is currently a plain text field but should be converted to a datetime field to work along the same lines as dateCreated. Formats are: dateOfSituationIngest: YYYY or YYYY-MM-DD dateOfSituationDisplay: ex: approximately YYYY, or YYYY-YYYY dateOfSituation: YYYY-MM-DD (ex: 1950-12-31)

Values for dates are imported using dateOfSituationIngest and dateOfSituationDisplay. Bulkrax converts the value in dateOfSituationIngest to a YYYY-MM-DD format to store in dateOfSituation. It converts partial dates so that when sorted they go at the end of the list (YYYY-12-31 or equivalent). dateOfSituationIngest and dateOfSituationDisplay are exportable, and are never overwritten by the value in dateOfSituation field.

rschwab commented 2 years ago

On this importer I created two works with dateOfSituationIngest values of YYYY and YYYY-MM-DD and dateOfSituationDisplay values with strings. The works created are giving this error: F, [2022-05-25T17:21:19.886461 #10964] FATAL -- : [f0a4a5d8-aeac-4fdb-b795-96989cfef2bc]
F, [2022-05-25T17:21:19.886493 #10964] FATAL -- : [f0a4a5d8-aeac-4fdb-b795-96989cfef2bc] ActionView::Template::Error (invalid date): F, [2022-05-25T17:21:19.886577 #10964] FATAL -- : [f0a4a5d8-aeac-4fdb-b795-96989cfef2bc] 4: <% next if (field.name == "dateOfSituation") && !presenter.attribute_to_html(:dateOfSituationDisplay).blank? %> [f0a4a5d8-aeac-4fdb-b795-96989cfef2bc] 5: <% next if %w[dateCreatedIngest dateOfSituationIngest].include?(field.name) %> [f0a4a5d8-aeac-4fdb-b795-96989cfef2bc] 6: [f0a4a5d8-aeac-4fdb-b795-96989cfef2bc] 7: <% if (html = presenter.attribute_to_html(field.name.to_sym, field.display_options)).present? %> [f0a4a5d8-aeac-4fdb-b795-96989cfef2bc] 8: <%= html %> [f0a4a5d8-aeac-4fdb-b795-96989cfef2bc] 9: <% elsif presenter.inherits? %> [f0a4a5d8-aeac-4fdb-b795-96989cfef2bc] 10: <% inheritable_fields = (ScoobySnacks::METADATA_SCHEMA.secondary_display_fields & ScoobySnacks::METADATA_SCHEMA.inheritable_fields) %> F, [2022-05-25T17:21:19.886593 #10964] FATAL -- : [f0a4a5d8-aeac-4fdb-b795-96989cfef2bc]
F, [2022-05-25T17:21:19.886637 #10964] FATAL -- : [f0a4a5d8-aeac-4fdb-b795-96989cfef2bc] app/views/hyrax/base/_secondary_attribute_rows.html.erb:7:in block in _app_views_hyrax_base__secondary_attribute_rows_html_erb___3545996982412736577_522060' [f0a4a5d8-aeac-4fdb-b795-96989cfef2bc] app/views/hyrax/base/_secondary_attribute_rows.html.erb:2:ineach' [f0a4a5d8-aeac-4fdb-b795-96989cfef2bc] app/views/hyrax/base/_secondary_attribute_rows.html.erb:2:in _app_views_hyrax_base__secondary_attribute_rows_html_erb___3545996982412736577_522060' [f0a4a5d8-aeac-4fdb-b795-96989cfef2bc] app/views/hyrax/base/_metadata.html.erb:22:in_app_views_hyrax_base__metadata_html_erb_4004868817038060129_521860' [f0a4a5d8-aeac-4fdb-b795-96989cfef2bc] app/views/hyrax/base/show.html.erb:19:in `_app_views_hyrax_base_show_html_erb1226286763378728241_521800'

rschwab commented 2 years ago

Hmm this same error came up after removing the dateofSituationDisplay and dateofSituationIngest fields on a new importer with new works.

bkiahstroud commented 2 years ago

@rschwab I've tracked this down to the metadata schema. I'll be pushing up a fix soon

rschwab commented 2 years ago

This works now, great work Kiah!