Skip to content

Commit

Permalink
fabricaId for contacts
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Mar 7, 2020
1 parent 862b923 commit d40775c
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions app/controllers/export_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def contacts
format.csv do
headers = %W(
fabricaAccountId
fabricaId
email
firstName
lastName
Expand All @@ -44,11 +45,11 @@ def contacts
contacts = Hash.new

add_contact = Proc.new { |contacts, email, id, firstname, lastname, type|
email.downcase
if email
unless contacts.has_key?(email)
contacts[email] = {
'fabricaAccountId' => id,
'fabricaId' => id + "-" + email,
'firstName' => firstname,
'lastName' => lastname,
}
Expand All @@ -75,6 +76,7 @@ def contacts
contacts.each do |email, contact|
csv += CSV.generate_line [
contact['fabricaAccountId'],
contact['fabricaId'],
email,
contact['firstName'],
contact['lastName'],
Expand Down Expand Up @@ -141,6 +143,7 @@ def organizations
"twitter",
"ROR",
"Fabrica Creation Date",
"Fabrica Modification Date",
"Fabrica Deletion Date"
]

Expand Down Expand Up @@ -169,7 +172,8 @@ def organizations
billingCountry: provider.billing_country,
twitter: provider.twitter_handle,
rorId: provider.ror_id,
created: provider.created.present? ? provider.created.strftime(EXPORT_DATE_FORMAT) : nil,
created: provider.created.strftime(EXPORT_DATE_FORMAT),
modified: provider.updated.strftime(EXPORT_DATE_FORMAT),
deleted: provider.deleted_at.present? ? provider.deleted_at.strftime(EXPORT_DATE_FORMAT) : nil,
}.values

Expand Down Expand Up @@ -236,8 +240,9 @@ def repositories
"serviceContactEmail",
"serviceContactGivenName",
"serviceContactFamilyName",
"Fabrica Creation date",
"Fabrica Deletion date",
"Fabrica Creation Date",
"Fabrica Modification Date",
"Fabrica Deletion Date",
"doisCurrentYear",
"doisPreviousYear",
"doisTotal"
Expand All @@ -264,7 +269,8 @@ def repositories
serviceContactEmail: client.service_contact_email,
serviceContactGivenName: client.service_contact_given_name,
serviceContactFamilyName: client.service_contact_family_name,
created: client.created.present? ? client.created.strftime(EXPORT_DATE_FORMAT) : nil,
created: client.created.strftime(EXPORT_DATE_FORMAT),
modified: client.updated.strftime(EXPORT_DATE_FORMAT),
deleted: client.deleted_at.present? ? client.deleted_at.strftime(EXPORT_DATE_FORMAT) : nil,
doisCountCurrentYear: client_totals[client_id] ? client_totals[client_id]["this_year"] : nil,
doisCountPreviousYear: client_totals[client_id] ? client_totals[client_id]["last_year"] : nil,
Expand Down

0 comments on commit d40775c

Please sign in to comment.