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

4050 - Bulk download: FRA Years: Desk study #4051

Merged
merged 1 commit into from
Oct 22, 2024
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
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
Loading