diff --git a/app/controllers/export_controller.rb b/app/controllers/export_controller.rb index e18b4c2b7..a87d8b653 100644 --- a/app/controllers/export_controller.rb +++ b/app/controllers/export_controller.rb @@ -1,8 +1,6 @@ class ExportController < ApplicationController include ActionController::MimeResponds - EXPORT_DATE_FORMAT = "%d/%m/%YT%H:%M:%S.%3NUTC%:z" - before_action :authenticate_user_with_basic_auth! def contacts @@ -163,9 +161,9 @@ def organizations billingCountryCode: provider.billing_information.country, twitter: provider.twitter_handle, rorId: provider.ror_id, - created: provider.created, - modified: provider.updated, - deleted: provider.deleted_at.present? ? provider.deleted_at : nil, + created: export_date(provider.created), + modified: export_date(provider.updated), + deleted: provider.deleted_at.present? ? export_date(provider.deleted_at) : nil, }.values csv += CSV.generate_line row @@ -252,9 +250,9 @@ def repositories serviceContactEmail: client.service_contact.email, serviceContactGivenName: client.service_contact.given_name, serviceContactFamilyName: client.service_contact.family_name, - created: client.created, - modified: client.updated, - deleted: client.deleted_at.present? ? client.deleted_at : nil, + created: export_date(client.created), + modified: export_date(client.updated), + deleted: client.deleted_at.present? ? export_date(client.deleted_at) : nil, doisCountCurrentYear: client_totals[client.uid] ? client_totals[client.uid]["this_year"] : nil, doisCountPreviousYear: client_totals[client.uid] ? client_totals[client.uid]["last_year"] : nil, doisCountTotal: client_totals[client.uid] ? client_totals[client.uid]["count"] : nil @@ -272,4 +270,8 @@ def repositories render json: { "errors" => { "title" => message }}.to_json, status: :bad_request end end + + def export_date(date) + DateTime.strptime(date, "%Y-%m-%dT%H:%M:%S").strftime("%d/%m/%YT%H:%M:%S.%3NUTC%:z") + end end diff --git a/spec/requests/exports_spec.rb b/spec/requests/exports_spec.rb index ed19526fc..efaa430c8 100644 --- a/spec/requests/exports_spec.rb +++ b/spec/requests/exports_spec.rb @@ -15,7 +15,7 @@ it 'returns organizations', vcr: false do get "/export/organizations", nil, admin_headers - + puts last_response.body expect(last_response.status).to eq(200) csv = last_response.body.lines expect(csv.length).to eq(3)