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

Commit

Permalink
Feature/cor 1667 move non suffix keys to archive (#4829)
Browse files Browse the repository at this point in the history
* Move coronamelder schema's to archive

* fix json schemafile references

* Update type definition for coronamelder

* Update key references to archived

* Update schema definitions and type to archive infectious_people

* Update page to use archived key

* Move schema definition files to archive

* Update schema files in index

* Fix typo in schema definition

* Update types based on new schema

* Correct schema defintion

* Update data structures for cms

* Update schema defintion and types for gm_collection

* Update schema and type definition for archived vulnerable in vr_coll.

* Create function for loading archived vr/gm coll data

* Correct schema for vulnerable nursing home

* Sync datatype of vulnerable_nursing_home to existing

* Undo attempt to archive vr_collection data

* Add functionality to use archived vr_collection data

* Update schema to archive vulnerable_nursing_home vrcollection

* Archive vulnerable_nursing_home on page Verpleeghuiszorg

* Make branch compatible with merged vr_collection archive solution

* Align cms constants with updated archive keys

* Fix script elements:add

---------

Co-authored-by: VWSCoronaDashboard29 <[email protected]>
  • Loading branch information
ben-van-eekelen and VWSCoronaDashboard29 authored Aug 8, 2023
1 parent f0fce3c commit 54691ac
Show file tree
Hide file tree
Showing 26 changed files with 269 additions and 284 deletions.
35 changes: 33 additions & 2 deletions packages/app/schema/archived_nl/__index.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,23 @@
"behavior_archived_20230411",
"behavior_annotations_archived_20230412",
"behavior_per_age_group_archived_20230411",
"repeating_shot_administered_20220713",
"corona_melder_app_warning_archived_20220421",
"corona_melder_app_download_archived_20220421",
"doctor_archived_20210903",
"g_number_archived_20220307",
"nursing_home_archived_20230126",
"reproduction_archived_20230711",
"infectious_people_archived_20210709",
"sewer_archived_20230623",
"tested_ggd_archived_20230321",
"tested_overall_archived_20230331",
"tested_per_age_group_archived_20230331",
"vulnerable_hospital_admissions_archived_20230711",
"vulnerable_nursing_home_archived_20230711"
"vulnerable_nursing_home_archived_20230711",
"vaccine_delivery_per_supplier_archived_20211101",
"vaccine_stock_archived_20211024",
"vaccine_vaccinated_or_support_archived_20230411",
"reproduction_archived_20230711"
],
"additionalProperties": false,
"properties": {
Expand Down Expand Up @@ -48,6 +55,15 @@
"behavior_per_age_group_archived_20230411": {
"$ref": "behavior/behavior_per_age_group.json"
},
"repeating_shot_administered_20220713": {
"$ref": "repeating_shot_administered.json"
},
"corona_melder_app_warning_archived_20220421": {
"$ref": "corona_melder_app_warning.json"
},
"corona_melder_app_download_archived_20220421": {
"$ref": "corona_melder_app_download.json"
},
"doctor_archived_20210903": {
"$ref": "doctor.json"
},
Expand All @@ -57,6 +73,9 @@
"nursing_home_archived_20230126": {
"$ref": "nursing_home.json"
},
"infectious_people_archived_20210709": {
"$ref": "infectious_people.json"
},
"tested_ggd_archived_20230321": {
"$ref": "positive_tests/tested_ggd.json"
},
Expand All @@ -77,6 +96,18 @@
},
"reproduction_archived_20230711": {
"$ref": "reproduction.json"
},
"vaccine_coverage_archived_20220518": {
"$ref": "vaccine_coverage.json"
},
"vaccine_delivery_per_supplier_archived_20211101": {
"$ref": "vaccine_delivery_per_supplier.json"
},
"vaccine_stock_archived_20211024": {
"$ref": "vaccine_stock.json"
},
"vaccine_vaccinated_or_support_archived_20230411": {
"$ref": "vaccine_vaccinated_or_support.json"
}
},
"$defs": {
Expand Down
11 changes: 10 additions & 1 deletion packages/app/schema/archived_vr_collection/__index.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"last_generated",
"proto_name",
"name",
"code"
"code",
"vulnerable_nursing_home_archived_20230711"
],
"properties": {
"last_generated": {
Expand All @@ -21,6 +22,14 @@
},
"code": {
"$ref": "#/$defs/archived_vr_collection_id"
},
"vulnerable_nursing_home_archived_20230711": {
"type": "array",
"minItems": 25,
"maxItems": 25,
"items": {
"$ref": "vulnerable_nursing_home.json"
}
}
},
"$defs": {
Expand Down
12 changes: 2 additions & 10 deletions packages/app/schema/gm_collection/__index.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "object",
"title": "gm_collection",
"additionalProperties": false,
"required": ["last_generated", "proto_name", "name", "code", "hospital_nice", "hospital_nice_choropleth", "sewer", "vaccine_coverage_per_age_group"],
"required": ["last_generated", "proto_name", "name", "code", "hospital_nice_choropleth", "sewer", "vaccine_coverage_per_age_group"],
"properties": {
"last_generated": {
"type": "string"
Expand All @@ -17,20 +17,12 @@
"code": {
"$ref": "#/$defs/gm_collection_id"
},
"hospital_nice": {
"type": "array",
"minItems": 342,
"maxItems": 342,
"items": {
"$ref": "hospital_nice.json"
}
},
"hospital_nice_choropleth": {
"type": "array",
"minItems": 342,
"maxItems": 342,
"items": {
"$ref": "hospital_nice.json"
"$ref": "hospital_nice_choropleth.json"
}
},
"sewer": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"title": "gm_collection_hospital_nice",
"title": "gm_collection_hospital_nice_choropleth",
"additionalProperties": false,
"required": [
"date_unix",
Expand Down
31 changes: 0 additions & 31 deletions packages/app/schema/nl/__index.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
"title": "nl",
"required": [
"booster_shot_administered_archived_20220904",
"repeating_shot_administered",
"booster_coverage_archived_20220904",
"code",
"corona_melder_app_download",
"corona_melder_app_warning",
"deceased_cbs",
"deceased_rivm_archived_20221231",
"deceased_rivm_per_age_group_archived_20221231",
Expand All @@ -19,7 +16,6 @@
"hospital_lcps",
"hospital_nice",
"hospital_nice_per_age_group",
"infectious_people",
"intensive_care_lcps",
"intensive_care_nice",
"intensive_care_nice_per_age_group",
Expand All @@ -31,7 +27,6 @@
"vaccine_campaigns",
"vaccine_campaigns_archived_20220908",
"vaccine_planned_archived_20220908",
"vaccine_vaccinated_or_support",
"vaccine_administered",
"vaccine_administered_doctors",
"vaccine_administered_ggd_ghor",
Expand All @@ -40,8 +35,6 @@
"vaccine_administered_total",
"vaccine_administered_planned",
"vaccine_administered_last_timeframe",
"vaccine_stock",
"vaccine_delivery_per_supplier",
"vaccine_coverage_per_age_group",
"vaccine_coverage_per_age_group_archived",
"vaccine_coverage_per_age_group_archived_20220908",
Expand Down Expand Up @@ -72,15 +65,9 @@
"booster_shot_administered_archived_20220904": {
"$ref": "booster_shot_administered_archived_20220904.json"
},
"repeating_shot_administered": {
"$ref": "repeating_shot_administered.json"
},
"booster_coverage_archived_20220904": {
"$ref": "booster_coverage_archived_20220904.json"
},
"infectious_people": {
"$ref": "infectious_people.json"
},
"intensive_care_nice": {
"$ref": "intensive_care_nice.json"
},
Expand Down Expand Up @@ -117,21 +104,6 @@
"elderly_at_home_archived_20230126": {
"$ref": "elderly_at_home_archived_20230126.json"
},
"vaccine_vaccinated_or_support": {
"$ref": "vaccine_vaccinated_or_support.json"
},
"corona_melder_app_download": {
"$ref": "corona_melder_app_download.json"
},
"corona_melder_app_warning": {
"$ref": "corona_melder_app_warning.json"
},
"vaccine_coverage": {
"$ref": "vaccine_coverage.json"
},
"vaccine_delivery_per_supplier": {
"$ref": "vaccine_delivery_per_supplier.json"
},
"vaccine_administered": {
"$ref": "vaccine_administered.json"
},
Expand Down Expand Up @@ -183,9 +155,6 @@
"vaccine_coverage_per_age_group_estimated_archived_20220908": {
"$ref": "vaccine_coverage_per_age_group_estimated_archived_20220908.json"
},
"vaccine_stock": {
"$ref": "vaccine_stock.json"
},
"variants": {
"$ref": "variants.json"
},
Expand Down
10 changes: 1 addition & 9 deletions packages/app/schema/vr_collection/__index.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "object",
"title": "vr_collection",
"additionalProperties": false,
"required": ["last_generated", "proto_name", "name", "code", "disability_care_archived_20230126", "elderly_at_home_archived_20230126", "vulnerable_nursing_home"],
"required": ["last_generated", "proto_name", "name", "code", "disability_care_archived_20230126", "elderly_at_home_archived_20230126"],
"properties": {
"last_generated": {
"type": "string"
Expand Down Expand Up @@ -32,14 +32,6 @@
"items": {
"$ref": "elderly_at_home_archived_20230126.json"
}
},
"vulnerable_nursing_home": {
"type": "array",
"minItems": 25,
"maxItems": 25,
"items": {
"$ref": "vulnerable_nursing_home.json"
}
}
},
"$defs": {
Expand Down
8 changes: 4 additions & 4 deletions packages/app/src/components/choropleth/logic/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {
ArchivedGmCollection,
GmCollection,
GmCollectionHospitalNice,
GmCollectionHospitalNiceChoropleth,
GmCollectionSewer,
GmCollectionTestedOverall,
GmCollectionVaccineCoveragePerAgeGroup,
Expand Down Expand Up @@ -59,16 +59,16 @@ export type InferedDataCollection<T extends ChoroplethDataItem> = T extends GmDa
? ArchivedVrCollection
: never;

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

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

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

export type ArchivedVrDataCollection = [];
export type ArchivedVrDataCollection = VrCollectionVulnerableNursingHome[];
export type ArchivedVrDataItem = ArchivedVrDataCollection[number];

export type ChoroplethDataItem = GmDataItem | ArchivedGmDataItem | VrDataItem | ArchivedVrDataItem;
Expand Down
6 changes: 3 additions & 3 deletions packages/app/src/pages/gemeente/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { colors, GmCollectionHospitalNice, gmData } from '@corona-dashboard/common';
import { colors, GmCollectionHospitalNiceChoropleth, gmData } from '@corona-dashboard/common';
import { useRouter } from 'next/router';
import { useMemo } from 'react';
import { Box } from '~/components/base';
Expand Down Expand Up @@ -33,12 +33,12 @@ const Municipality = (props: StaticProps<typeof getStaticProps>) => {
};

const data = useMemo(() => {
return gmData.map<GmCollectionHospitalNice>(
return gmData.map<GmCollectionHospitalNiceChoropleth>(
(x) =>
({
gmcode: x.gemcode,
admissions_on_date_of_reporting: null,
} as unknown as GmCollectionHospitalNice)
} as unknown as GmCollectionHospitalNiceChoropleth)
);
}, []);

Expand Down
10 changes: 5 additions & 5 deletions packages/app/src/pages/landelijk/besmettelijke-mensen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { useIntl } from '~/intl';
import { Languages, SiteText } from '~/locale';
import { getArticleParts, getDataExplainedParts, getFaqParts, getPagePartsQuery } from '~/queries/get-page-parts-query';
import { createGetStaticProps, StaticProps } from '~/static-props/create-get-static-props';
import { createGetContent, getLastGeneratedDate, getLokalizeTexts, selectNlData } from '~/static-props/get-data';
import { 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 { getPageInformationHeaderContent } from '~/utils/get-page-information-header-content';
Expand All @@ -30,7 +30,7 @@ type LokalizeTexts = ReturnType<typeof selectLokalizeTexts>;
export const getStaticProps = createGetStaticProps(
({ locale }: { locale: keyof Languages }) => getLokalizeTexts(selectLokalizeTexts, locale),
getLastGeneratedDate,
selectNlData('infectious_people'),
selectArchivedNlData('infectious_people_archived_20210709'),
async (context: GetStaticPropsContext) => {
const { content } = await createGetContent<PagePartQueryResult<ArticleParts>>(() => getPagePartsQuery('infectious_people_page'))(context);

Expand All @@ -45,11 +45,11 @@ export const getStaticProps = createGetStaticProps(
);

const InfectiousPeople = (props: StaticProps<typeof getStaticProps>) => {
const { pageText, selectedNlData: data, lastGenerated, content } = props;
const { pageText, selectedArchivedNlData: data, lastGenerated, content } = props;
const { commonTexts } = useIntl();
const { metadataTexts, textNl } = useDynamicLokalizeTexts<LokalizeTexts>(pageText, selectLokalizeTexts);

const lastFullValue = getLastFilledValue(data.infectious_people);
const lastFullValue = getLastFilledValue(data.infectious_people_archived_20210709);

const metadata = {
...metadataTexts,
Expand Down Expand Up @@ -89,7 +89,7 @@ const InfectiousPeople = (props: StaticProps<typeof getStaticProps>) => {
key: 'infectious_people_over_time_chart',
}}
tooltipTitle={textNl.linechart_titel}
values={data.infectious_people.values}
values={data.infectious_people_archived_20210709.values}
seriesConfig={[
{
type: 'line',
Expand Down
10 changes: 5 additions & 5 deletions packages/app/src/pages/landelijk/coronamelder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { NlLayout } from '~/domain/layout/nl-layout';
import { useIntl } from '~/intl';
import { Languages, SiteText } from '~/locale';
import { createGetStaticProps, StaticProps } from '~/static-props/create-get-static-props';
import { getLastGeneratedDate, getLokalizeTexts, selectNlData } from '~/static-props/get-data';
import { getLastGeneratedDate, getLokalizeTexts, selectArchivedNlData } from '~/static-props/get-data';
import { createDateFromUnixTimestamp } from '~/utils/create-date-from-unix-timestamp';
import { useDynamicLokalizeTexts } from '~/utils/cms/use-dynamic-lokalize-texts';
import { WarningTile } from '~/components/warning-tile';
Expand All @@ -25,18 +25,18 @@ type LokalizeTexts = ReturnType<typeof selectLokalizeTexts>;
export const getStaticProps = createGetStaticProps(
({ locale }: { locale: keyof Languages }) => getLokalizeTexts(selectLokalizeTexts, locale),
getLastGeneratedDate,
selectNlData('corona_melder_app_warning', 'corona_melder_app_download')
selectArchivedNlData('corona_melder_app_warning_archived_20220421', 'corona_melder_app_download_archived_20220421')
);

const CoronamelderPage = (props: StaticProps<typeof getStaticProps>) => {
const [coronamelderTimeframe, setCoronamelderTimeframe] = useState<TimeframeOption>(TimeframeOption.ALL);
const { commonTexts } = useIntl();

const { pageText, selectedNlData: data, lastGenerated } = props;
const { pageText, selectedArchivedNlData: data, lastGenerated } = props;
const { corona_melder_app } = commonTexts;
const { metadataTexts, textNl } = useDynamicLokalizeTexts<LokalizeTexts>(pageText, selectLokalizeTexts);

const warningLastValue = data.corona_melder_app_warning.last_value;
const warningLastValue = data.corona_melder_app_warning_archived_20220421.last_value;
const endDate = createDateFromUnixTimestamp(warningLastValue.date_unix);

const metadata = {
Expand Down Expand Up @@ -81,7 +81,7 @@ const CoronamelderPage = (props: StaticProps<typeof getStaticProps>) => {
}}
tooltipTitle={corona_melder_app.waarschuwingen_over_tijd_grafiek.title}
timeframe={coronamelderTimeframe}
values={data.corona_melder_app_warning.values}
values={data.corona_melder_app_warning_archived_20220421.values}
endDate={endDate}
seriesConfig={[
{
Expand Down
Loading

0 comments on commit 54691ac

Please sign in to comment.