osulp / Scholars-Archive

ScholarsArchive@OSU, institutional repository for Oregon State University
https://ir.library.oregonstate.edu/
15 stars 3 forks source link

NoMethodError: undefined method `include?' for nil:NilClass in edtf_date_compare_service #1297

Closed luisgreg99 closed 6 years ago

luisgreg99 commented 6 years ago

We can reproduce the error with:

bundle exec rails c
irb(main):005:0> ScholarsArchive::EdtfDateCompareService.includes_last_five_years?("invalid option here")
NoMethodError: undefined method `include?' for nil:NilClass
        from /Users/username/Scholars-Archive/app/services/scholars_archive/edtf_date_compare_service.rb:38:in `block in date_in_past_five_years?'
        ...
luisgreg99 commented 6 years ago

Debugging notes:

Screenshot from @simholt image

I looked more into this error, and it turns out that the degree field "Risk and Uncertainty Quantification in Marine Science" http://opaquenamespace.org/ns/osuDegreeFields/5TrS7vqq was throwing the broken page because it is missing a date in the degree field metadata.

For non-admin users, SA only lists degree fields with dates within the last five years to reduce the number of options under the "Degree field" dropdown.

Is the option "Risk and Uncertainty Quantification in Marine Science" expected to be listed under "Degree Field" for current submissions? @simholt @wickr

simholt commented 6 years ago

Yes, it is new and should be current. (@wickr Am I supposed to add dates?)

wickr commented 6 years ago

@luisgreg99 @simholt yes, it should have a date and be current like Sarah said.

Though hopefully with this fix in now, if we miss a date again it won't cause errors.

luisgreg99 commented 6 years ago

@wickr @simholt Ok, with the current fix in place, when a date is not available in the term (degree field) metadata, the edit or new forms should now skip it or exclude it from the dropdown list under Degree Fields (for non-admin users) instead of throwing an error.

EdtfDateCompareService requires a date in the term in order to filter out degrees older than 5 years.

I noticed that most of the terms in the Degree Fields vocabulary http://opaquenamespace.org/ns/osuDegreeFields have a year YYYY or a year range in the form {YYYY..YYYY}, so I think we just need to update the term http://opaquenamespace.org/ns/osuDegreeFields/5TrS7vqq and set the current year or a known range under Date in the Controlled Vocabulary Manager (CVM) to make it available for current submissions. Do we know a date range appropriate for this term?