Skip to content

Commit

Permalink
Add parent identifiers in csv output for orgs
Browse files Browse the repository at this point in the history
  • Loading branch information
richardhallett committed Sep 20, 2019
1 parent aa8019b commit a06b7ea
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
28 changes: 15 additions & 13 deletions app/controllers/organizations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ def index
response = Provider.find_by_id(params[:ids], page: page, sort: sort)
else
response = Provider.query(params[:query],
year: params[:year],
region: params[:region],
consortium_id: params[:provider_id],
organization_type: params[:organization_type],
year: params[:year],
region: params[:region],
consortium_id: params[:provider_id],
organization_type: params[:organization_type],
focus_area: params[:focus_area],
page: page,
page: page,
sort: sort)
end

Expand Down Expand Up @@ -84,15 +84,18 @@ def index
header = %w(
accountName
fabricaAccountId
year
is_active
parentFabricaAccountId
salesForceId
parentSalesForceId
memberType
isActive
accountDescription
accountWebsite
region
country
logo_url
logoUrl
focusArea
organisation_type
organisationType
accountType
generalContactEmail
groupEmail
Expand Down Expand Up @@ -125,12 +128,11 @@ def index
secondaryBillingContactGivenName
secondaryBillingContactFamilyName
twitter
ror_id
member_type
joined
rorId
created
updated
deleted_at)
deletedAt)
puts response.records.to_a[0].to_json
format.csv { render request.format.to_sym => response.records.to_a, header: header }
end
rescue Elasticsearch::Transport::Transport::Errors::BadRequest => exception
Expand Down
9 changes: 5 additions & 4 deletions app/models/provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,11 @@ def csv
provider = {
name: name,
provider_id: symbol,
year: year,
is_active: is_active,
consortium_id: consortium.present? ? consortium.symbol : '',
salesforce_id: salesforce_id,
consortium_salesforce_id: consortium.present? ? consortium.salesforce_id : '',
role_name: role_name,
is_active: is_active == "\x01",
description: description,
website: website,
region: region_human_name,
Expand Down Expand Up @@ -289,8 +292,6 @@ def csv
secondary_billing_contact_family_name: secondary_billing_contact_family_name,
twitter_handle: twitter_handle,
ror_id: ror_id,
role_name: role_name,
joined: joined,
created: created,
updated: updated,
deleted_at: deleted_at,
Expand Down

0 comments on commit a06b7ea

Please sign in to comment.