Skip to content

Commit

Permalink
4050 - Bulk download: FRA Years: Desk study
Browse files Browse the repository at this point in the history
  • Loading branch information
sorja committed Oct 22, 2024
1 parent 06a65aa commit 992fc28
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ export const getFraYearsData = async (props: Props) => {

const years = Years.fraYears(cycle)

return countries.flatMap(({ countryIso, regionCodes }) =>
return countries.flatMap(({ countryIso, regionCodes, props: { deskStudy } }) =>
years.flatMap<Record<string, string>>((year: string) => {
const base: Record<string, string> = {
regions: regionCodes.join(';'),
iso3: countryIso,
deskStudy: deskStudy ? 'assessment.deskStudy' : '',
name: countryIso,
year,
boreal: getClimaticValue('boreal', countryIso, climaticData),
Expand Down
4 changes: 3 additions & 1 deletion src/server/controller/cycleData/getBulkDownload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const _convertToCSV = (arr: Array<Record<string, string>>): string => {
const fixedHeaders = [
'regions',
'iso3',
'deskStudy',
'name',
'year',
'forest area 2020',
Expand All @@ -54,7 +55,7 @@ const _getFileName = (name: string): string => {
return `${name}_${timestamp}.csv`
}

const handleResult = ({ regions, iso3, name, year, ...row }: Record<string, string>, i18n: i18nType) => {
const handleResult = ({ regions, iso3, deskStudy, name, year, ...row }: Record<string, string>, i18n: i18nType) => {
const _translate = (key: string) => i18n.t<string>(Areas.getTranslationKey(key as RegionCode | CountryIso))

const _handleRegions = (regions: string): string => {
Expand All @@ -64,6 +65,7 @@ const handleResult = ({ regions, iso3, name, year, ...row }: Record<string, stri
const fixed: Record<string, string> = {
regions: _handleRegions(regions),
iso3: `"${iso3}"`,
deskStudy: `"${i18n.t(deskStudy)}"`,
name: `"${_translate(name)}"`,
...row,
}
Expand Down

0 comments on commit 992fc28

Please sign in to comment.