hyrax icon indicating copy to clipboard operation
hyrax copied to clipboard

Admin Analytic's Work Reports renders in error when attempting to call `strftime` on a String.

Open jeremyf opened this issue 3 years ago • 0 comments

In app/views/hyrax/admin/analytics/work_reports/show.html.erb we have cases where @document.date_uploaded is not a Date-like object. When that view attempts to call strftime on the @document.date_uploaded we get the following error: undefined method strftime' for "2022-08-10T23:22:45Z":String.

Throughout the code base the @document.date_uploaded is rendered directly (e.g. no conversion). In the Hyrax::StatsUsagePresenter object we do ensure a date like value. Which indicates that this field cannot predicatably be called a Date.

Proposal: Add a helper method cast_to_formatted_date(value, format: "%Y-%m-%d") this would attempt to parse the value from String to date then render with the given format. Port this to the 3.4.x and 4.0.x branches.

jeremyf avatar Aug 26 '22 18:08 jeremyf