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

Commit

Permalink
task: update code on leftover comments on the PR for COR-1666
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorrik-Klijnsma-Work committed Aug 9, 2023
1 parent 2055b33 commit 4d82a1b
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 39 deletions.
2 changes: 1 addition & 1 deletion packages/app/schema/archived_gm/__difference.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "archived_gm_difference",
"title": "gm_difference",
"type": "object",
"required": [
"tested_overall__infected_moving_average_archived_20230331",
Expand Down
2 changes: 1 addition & 1 deletion packages/app/schema/archived_nl/__difference.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "archived_nl_difference",
"title": "nl_difference",
"type": "object",
"properties": {
"deceased_rivm__covid_daily_archived_20221231": {
Expand Down
22 changes: 20 additions & 2 deletions packages/app/schema/archived_vr_collection/__index.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"proto_name",
"name",
"code",
"vulnerable_nursing_home_archived_20230711"
"vulnerable_nursing_home_archived_20230711",
"elderly_at_home_archived_20230126",
"disability_care_archived_20230126"
],
"properties": {
"last_generated": {
Expand All @@ -30,6 +32,22 @@
"items": {
"$ref": "vulnerable_nursing_home.json"
}
},
"disability_care_archived_20230126": {
"type": "array",
"minItems": 25,
"maxItems": 25,
"items": {
"$ref": "disability_care.json"
}
},
"elderly_at_home_archived_20230126": {
"type": "array",
"minItems": 25,
"maxItems": 25,
"items": {
"$ref": "elderly_at_home.json"
}
}
},
"$defs": {
Expand All @@ -38,4 +56,4 @@
"enum": ["VR_COLLECTION"]
}
}
}
}
18 changes: 6 additions & 12 deletions packages/app/src/components/choropleth/logic/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ import type {
GmCollectionSewer,
GmCollectionTestedOverall,
GmCollectionVaccineCoveragePerAgeGroup,
VrCollection,
ArchivedVrCollection,
VrCollectionDisabilityCareArchived_20230126,
VrCollectionElderlyAtHomeArchived_20230126,
VrCollectionVulnerableNursingHome,
VrCollectionElderlyAtHome,
VrCollectionDisabilityCare,
} from '@corona-dashboard/common';
import type { ParsedFeature } from '@visx/geo/lib/projections/Projection';
import type { Feature, FeatureCollection, MultiPolygon, Polygon } from 'geojson';
Expand Down Expand Up @@ -45,33 +44,28 @@ export const mapToCodeType: Record<MapType, CodeProp> = {
vr: 'vrcode',
};

export type ChoroplethCollection = GmCollection | ArchivedGmCollection | VrCollection;
export type ChoroplethCollection = GmCollection | ArchivedGmCollection | ArchivedVrCollection;

export type InferedMapType<T extends ChoroplethDataItem> = T extends GmDataItem | ArchivedGmDataItem ? 'gm' : T extends VrDataItem | ArchivedVrDataItem ? 'vr' : never;
export type InferedMapType<T extends ChoroplethDataItem> = T extends GmDataItem | ArchivedGmDataItem ? 'gm' : T extends ArchivedVrDataItem ? 'vr' : never;

export type InferedDataCollection<T extends ChoroplethDataItem> = T extends GmDataItem
? GmCollection
: T extends ArchivedGmDataItem
? ArchivedGmCollection
: T extends VrDataItem
? VrCollection
: T extends ArchivedVrDataItem
? ArchivedVrCollection
: never;

export type VrDataCollection = VrCollectionDisabilityCareArchived_20230126[] | VrCollectionElderlyAtHomeArchived_20230126[];
export type VrDataItem = VrDataCollection[number];

export type GmDataCollection = GmCollectionHospitalNiceChoropleth[] | GmCollectionSewer[] | GmCollectionVaccineCoveragePerAgeGroup[];
export type GmDataItem = GmDataCollection[number];

export type ArchivedGmDataCollection = GmCollectionTestedOverall[];
export type ArchivedGmDataItem = ArchivedGmDataCollection[number];

export type ArchivedVrDataCollection = VrCollectionVulnerableNursingHome[];
export type ArchivedVrDataCollection = VrCollectionVulnerableNursingHome[] | VrCollectionElderlyAtHome[] | VrCollectionDisabilityCare[];
export type ArchivedVrDataItem = ArchivedVrDataCollection[number];

export type ChoroplethDataItem = GmDataItem | ArchivedGmDataItem | VrDataItem | ArchivedVrDataItem;
export type ChoroplethDataItem = GmDataItem | ArchivedGmDataItem | ArchivedVrDataItem;

export type CodedGeoProperties = {
code: string;
Expand Down
19 changes: 4 additions & 15 deletions packages/app/src/components/choropleth/logic/utils.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import type { ParsedFeature } from '@visx/geo/lib/projections/Projection';
import type { Feature, MultiPolygon, Polygon } from 'geojson';
import { isPresent } from 'ts-is-present';
import type {
CodedGeoProperties,
CodeProp,
GmDataItem,
ParsedFeatureWithPath,
VrDataItem,
} from './types';
import type { CodedGeoProperties, CodeProp, GmDataItem, ParsedFeatureWithPath, ArchivedVrDataItem } from './types';

export function isCodedValueType(codeType: CodeProp) {
switch (codeType) {
Expand All @@ -22,13 +16,11 @@ export function isGmData(item: any): item is GmDataItem {
return 'gmcode' in item;
}

export function isVrData(item: any): item is VrDataItem {
export function isVrData(item: any): item is ArchivedVrDataItem {
return 'vrcode' in item;
}

export function featureHasPath(
value: ParsedFeature<Feature<MultiPolygon | Polygon, CodedGeoProperties>>
): value is ParsedFeatureWithPath {
export function featureHasPath(value: ParsedFeature<Feature<MultiPolygon | Polygon, CodedGeoProperties>>): value is ParsedFeatureWithPath {
return isPresent(value.path);
}

Expand All @@ -40,9 +32,6 @@ export function featureHasPath(
export function truncatePathCoordinates(feature: ParsedFeatureWithPath) {
return {
...feature,
path: feature.path.replace(
/\d+\.\d+/g,
(x) => Math.round(parseFloat(x)) + ''
),
path: feature.path.replace(/\d+\.\d+/g, (x) => Math.round(parseFloat(x)) + ''),
};
}
8 changes: 4 additions & 4 deletions packages/app/src/pages/landelijk/thuiswonende-70-plussers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { Languages, SiteText } from '~/locale';
import { ElementsQueryResult, getElementsQuery, getTimelineEvents } from '~/queries/get-elements-query';
import { getArticleParts, getDataExplainedParts, getFaqParts, getPagePartsQuery } from '~/queries/get-page-parts-query';
import { createGetStaticProps, StaticProps } from '~/static-props/create-get-static-props';
import { createGetChoroplethData, createGetContent, getLastGeneratedDate, getLokalizeTexts, selectArchivedNlData } from '~/static-props/get-data';
import { createGetArchivedChoroplethData, createGetContent, getLastGeneratedDate, getLokalizeTexts, selectArchivedNlData } from '~/static-props/get-data';
import { ArticleParts, PagePartQueryResult } from '~/types/cms';
import { useDynamicLokalizeTexts } from '~/utils/cms/use-dynamic-lokalize-texts';
import { getBoundaryDateStartUnix } from '~/utils/get-boundary-date-start-unix';
Expand All @@ -41,7 +41,7 @@ export const getStaticProps = createGetStaticProps(
({ locale }: { locale: keyof Languages }) => getLokalizeTexts(selectLokalizeTexts, locale),
getLastGeneratedDate,
selectArchivedNlData('elderly_at_home_archived_20230126'),
createGetChoroplethData({
createGetArchivedChoroplethData({
vr: ({ elderly_at_home_archived_20230126 }) => ({ elderly_at_home_archived_20230126 }),
}),
async (context: GetStaticPropsContext) => {
Expand All @@ -68,7 +68,7 @@ export const getStaticProps = createGetStaticProps(
);

function ElderlyAtHomeNationalPage(props: StaticProps<typeof getStaticProps>) {
const { pageText, selectedArchivedNlData: data, choropleth, lastGenerated, content } = props;
const { pageText, selectedArchivedNlData: data, archivedChoropleth, lastGenerated, content } = props;
const [elderlyAtHomeConfirmedCasesTimeframe, setElderlyAtHomeConfirmedCasesTimeframe] = useState<TimeframeOption>(TimeframeOption.ALL);

const [elderlyAtHomeConfirmedCasesOverTimeTimeframe, setElderlyAtHomeConfirmedCasesOverTimeTimeframe] = useState<TimeframeOption>(TimeframeOption.ALL);
Expand Down Expand Up @@ -175,7 +175,7 @@ function ElderlyAtHomeNationalPage(props: StaticProps<typeof getStaticProps>) {
accessibility={{
key: 'elderly_at_home_infected_people_choropleth',
}}
data={choropleth.vr.elderly_at_home_archived_20230126}
data={archivedChoropleth.vr.elderly_at_home_archived_20230126}
dataConfig={{
metricName: 'elderly_at_home_archived_20230126',
metricProperty: 'positive_tested_daily_per_100k',
Expand Down
28 changes: 24 additions & 4 deletions packages/common/src/types/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
export type ArchivedGmCode = string;

export interface ArchivedGm {
difference: ArchivedGmDifference;
difference: GmDifference;
deceased_rivm_archived_20221231: GmDeceasedRivm;
last_generated: string;
proto_name: ArchivedGmCode;
Expand All @@ -19,7 +19,7 @@ export interface ArchivedGm {
sewer_archived_20230623: GmSewer;
tested_overall_archived_20230331: GmTestedOverall;
}
export interface ArchivedGmDifference {
export interface GmDifference {
tested_overall__infected_moving_average_archived_20230331: DifferenceDecimal;
tested_overall__infected_per_100k_moving_average_archived_20230331: DifferenceDecimal;
deceased_rivm__covid_daily_archived_20221231: DifferenceInteger;
Expand Down Expand Up @@ -147,7 +147,7 @@ export interface ArchivedNl {
proto_name: ArchivedNlId;
name: ArchivedNlId;
code: ArchivedNlId;
difference: ArchivedNlDifference;
difference: NlDifference;
behavior_archived_20230411: NlBehavior;
behavior_annotations_archived_20230412: NlBehaviorAnnotations;
behavior_per_age_group_archived_20230411: NlBehaviorPerAgeGroup;
Expand Down Expand Up @@ -181,7 +181,7 @@ export interface ArchivedNl {
corona_melder_app_download_archived_20220421: NlCoronaMelderAppDownload;
infectious_people_archived_20210709: NlInfectiousPeople;
}
export interface ArchivedNlDifference {
export interface NlDifference {
deceased_rivm__covid_daily_archived_20221231: DifferenceInteger;
nursing_home__deceased_daily_archived_20230126: DifferenceInteger;
nursing_home__newly_infected_people_archived_20230126: DifferenceInteger;
Expand Down Expand Up @@ -698,6 +698,8 @@ export interface ArchivedVrCollection {
name: ArchivedVrCollectionId;
code: ArchivedVrCollectionId;
vulnerable_nursing_home_archived_20230711: VrCollectionVulnerableNursingHome[];
disability_care_archived_20230126: VrCollectionDisabilityCare[];
elderly_at_home_archived_20230126: VrCollectionElderlyAtHome[];
}
export interface VrCollectionVulnerableNursingHome {
newly_infected_locations: number;
Expand All @@ -707,6 +709,24 @@ export interface VrCollectionVulnerableNursingHome {
date_unix: number;
vrcode: string;
}
export interface VrCollectionDisabilityCare {
newly_infected_people: number;
newly_infected_locations: number;
infected_locations_total: number;
infected_locations_percentage: number;
deceased_daily: number;
date_unix: number;
date_of_insertion_unix: number;
vrcode: string;
}
export interface VrCollectionElderlyAtHome {
positive_tested_daily: number;
positive_tested_daily_per_100k: number;
deceased_daily: number;
date_unix: number;
date_of_insertion_unix: number;
vrcode: string;
}

export type GmCode = string;

Expand Down

0 comments on commit 4d82a1b

Please sign in to comment.