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

refactoring: Make iso_code3 code visible at HistoricalEmissions downloaded file #1663

Merged
merged 2 commits into from
Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions app/services/api/v1/data/historical_emissions/csv_content.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ module HistoricalEmissions
class CsvContent
def initialize(filter)
@grouped_query = filter.call
@headers = filter.column_aliases
@headers = filter.column_display_names
@aliases = filter.column_aliases
@years = filter.header_years
end

def call
CSV.generate do |output|
output << (@headers.map(&:humanize) + @years)
output << @headers + @years
@grouped_query.each do |record|
ary = @headers.map { |h| record[h] }
ary = @aliases.map { |h| record[h] }
ary += @years.map do |y|
emission = record.emissions.find { |e| e['year'] == y }
(emission && emission['value']) || 'N/A'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def select_columns_map
{
column: 'iso_code3',
alias: 'iso_code3',
visible: false
display: "ISO"
},
{
column: 'region',
Expand Down