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

[Jupiter] Display graduation date in "Fall 2017" format #1003

Closed
pbinkley opened this issue Jan 28, 2019 · 2 comments
Closed

[Jupiter] Display graduation date in "Fall 2017" format #1003

pbinkley opened this issue Jan 28, 2019 · 2 comments
Assignees

Comments

@pbinkley
Copy link
Member

With agreement from FGSR and Leah, we'd like to display the graduation date field for theses in the "Fall 2016" format rather than the current "2016-11" format. The underlying data will still use "2016-11", so it won't be changed. The edit form for theses also does not need to change (since it is only used by admin users). The change applies only to search results and full item displays. OAI is out of scope.

The graduation_date field is normalized to YYYY-MM, with MM = 06 or 11. This should map to "Spring YYYY" when the MM is 06, and "Fall YYYY" when the MM is 11. Fall back to just YYYY for any other value of MM or when MM is absent.

Related to #798. Weiwei has reviewed email discussion of that issue at the time to clarify some of the history.

@weiweishi
Copy link
Contributor

The original requirements on the deposit form will remain unchanged - consider this as a new requirement, for public interface.

@weiweishi weiweishi changed the title Display graduation date in "Fall 2017" format [Jupiter] Display graduation date in "Fall 2017" format Feb 8, 2019
@pgwillia
Copy link
Member

pgwillia commented Feb 8, 2019

<dd><%= humanize_date(@item.graduation_date) %></dd>

# We have a lot of messy "date-ish" data. Created dates coming through the Draft interface are actual date types
# saved into Fedora/Solr as strings at the moment. Much of the legacy data is generally a freeform string containing
# anything from "2017/09/12" to '2013' to "2012-09-26T11:18:38Z" (on Theses) to "Fall 1978" to "Unknown"
# to "Late Roman antiquity" (ok, I'm making that one up, but it wouldn't surprise me).
#
# This complicates displaying the field because if we display the raw data we end up displaying decidedly unfriendly
# things like "1986-11-17 14:51:45 -0700" in cases where higher quality dates were recorded.
#
# Thus, we try to parse the date and display a simple iso8601 formated date if it succeeds, and fall back to
# displaying raw data otherwise.
def humanize_date(dateish)
return I18n.t('date_unknown') if dateish.blank?
Date.parse(dateish).iso8601
rescue ArgumentError
dateish
end

Here's how the deposit side is mapped to 'Spring' 'Fall'

# Metadata team prefers we store and use a number (e.g. '06' or '11')
# to represent the graduation term (e.g. Spring or Fall)
# This TERMS constant is used by the graduation term dropdown on the deposit form,
# mapping the string label to the number value that we wish to use.
TERMS = [
[I18n.t('admin.theses.graduation_terms.spring'), '06'],
[I18n.t('admin.theses.graduation_terms.fall'), '11']
].freeze

graduation_term: parse_graduation_term_from_fedora(thesis.graduation_date),
graduation_year: thesis.sort_year,

def parse_graduation_term_from_fedora(graduation_date)
result = graduation_date&.match(/-(06|11)/)
result = result[0]&.gsub!('-', '') if result.present?
result
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants