Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Removed obsolete code for international pages (#4268)
Browse files Browse the repository at this point in the history
* Removed obsolete code for international pages

* Removed type parameter
  • Loading branch information
jeroen-drenth authored May 25, 2022
1 parent 10d9706 commit 4eeff20
Showing 1 changed file with 1 addition and 30 deletions.
31 changes: 1 addition & 30 deletions packages/app/src/static-props/get-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import {
Gm,
GmCollection,
gmData,
In,
InCollection,
Nl,
sortTimeSeriesInDataInPlace,
Vr,
Expand All @@ -18,7 +16,6 @@ import { GetStaticPropsContext } from 'next';
import { isDefined } from 'ts-is-present';
import type { F, O, S, U } from 'ts-toolbelt';
import { AsyncWalkBuilder } from 'walkjs';
import { CountryCode } from '~/domain/international/multi-select-countries';
import { getClient, localize } from '~/lib/sanity';
import { Languages, SiteText } from '~/locale';
import {
Expand Down Expand Up @@ -73,10 +70,6 @@ const json = {
loadJsonFromDataFile<GmCollection>('GM_COLLECTION.json'),
'gm_collection'
),
inCollection: initializeFeatureFlaggedData<InCollection>(
loadJsonFromDataFile<InCollection>('IN_COLLECTION.json', undefined, true),
'in_collection'
),
};

export function getLastGeneratedDate() {
Expand Down Expand Up @@ -308,45 +301,23 @@ function getGmData(context: GetStaticPropsContext) {

const NOOP = () => null;

export function createGetChoroplethData<T1, T2, T3>(settings?: {
export function createGetChoroplethData<T1, T2>(settings?: {
vr?: (collection: VrCollection, context: GetStaticPropsContext) => T1;
gm?: (collection: GmCollection, context: GetStaticPropsContext) => T2;
in?: (collection: InCollection, context: GetStaticPropsContext) => T3;
}) {
return (context: GetStaticPropsContext) => {
const filterVr = settings?.vr ?? NOOP;
const filterGm = settings?.gm ?? NOOP;
const filterIn = settings?.in ?? NOOP;

return {
choropleth: {
vr: filterVr(json.vrCollection, context) as T1,
gm: filterGm(json.gmCollection, context) as T2,
in: filterIn(json.inCollection, context) as T3,
},
};
};
}

export function getInData(countryCodes: CountryCode[]) {
return function () {
const internationalData: Record<string, In> = {};
countryCodes.forEach((countryCode) => {
const data = initializeFeatureFlaggedData<In>(
loadJsonFromDataFile<In>(`IN_${countryCode.toUpperCase()}.json`),
'in'
);

sortTimeSeriesInDataInPlace(data);

internationalData[countryCode] = data;
});
return { internationalData } as {
internationalData: Record<CountryCode, In>;
};
};
}

/**
* This function makes sure that for metrics with inaccurate data for the last x
* items, the last_value is replaced with the last accurate value. For now only
Expand Down

0 comments on commit 4eeff20

Please sign in to comment.