From f0fce3c76b65fd93f6e3a97d1aab287cf31573ba Mon Sep 17 00:00:00 2001 From: M <120020483+VWSCoronaDashboard30@users.noreply.github.com> Date: Tue, 8 Aug 2023 17:00:17 +0200 Subject: [PATCH] feat(COR-1690): Archived positive tests metrics (#4827) * feat(COR-1690): Archived positive tests metrics * feat(COR-1690): Implemented GM and Choropleth changes * feat(COR-1690): Removed console.log() from get-schema-metrics.ts * feat(COR-1690): PR comment resolution * feat(COR-1690): PR CMS V2 compile issue resolution --- .../app/schema/archived_gm/__difference.json | 56 +++++ packages/app/schema/archived_gm/__index.json | 14 +- .../positive_tests}/tested_overall.json | 0 .../archived_gm_collection/__index.json | 16 +- .../positive_tests}/tested_overall.json | 0 .../app/schema/archived_nl/__difference.json | 30 ++- packages/app/schema/archived_nl/__index.json | 20 +- .../positive_tests}/g_number.json | 0 .../positive_tests}/tested_ggd.json | 0 .../positive_tests}/tested_overall.json | 0 .../positive_tests}/tested_per_age_group.json | 0 packages/app/schema/gm/__difference.json | 13 +- packages/app/schema/gm/__index.json | 4 - .../app/schema/gm_collection/__index.json | 10 +- packages/app/schema/nl/__difference.json | 16 -- packages/app/schema/nl/__index.json | 16 -- .../src/components/choropleth/logic/types.ts | 14 +- .../pages/gemeente/[code]/positief-testen.tsx | 51 +++-- .../src/pages/landelijk/positieve-testen.tsx | 71 +++---- .../utils/load-json-from-data-file.ts | 6 +- .../src/elements/schemas/shared/index.ts | 4 +- packages/cms/src/studio/constants.ts | 10 +- .../cms/src/studio/data/data-structure.ts | 60 +++--- packages/cms/src/studio/scripts/add-chart.ts | 19 +- packages/common/src/types/data-utils.ts | 7 +- packages/common/src/types/data.ts | 193 +++++++++--------- packages/common/src/types/feature-flags.ts | 2 +- 27 files changed, 340 insertions(+), 292 deletions(-) create mode 100644 packages/app/schema/archived_gm/__difference.json rename packages/app/schema/{gm => archived_gm/positive_tests}/tested_overall.json (100%) rename packages/app/schema/{gm_collection => archived_gm_collection/positive_tests}/tested_overall.json (100%) rename packages/app/schema/{nl => archived_nl/positive_tests}/g_number.json (100%) rename packages/app/schema/{nl => archived_nl/positive_tests}/tested_ggd.json (100%) rename packages/app/schema/{nl => archived_nl/positive_tests}/tested_overall.json (100%) rename packages/app/schema/{nl => archived_nl/positive_tests}/tested_per_age_group.json (100%) diff --git a/packages/app/schema/archived_gm/__difference.json b/packages/app/schema/archived_gm/__difference.json new file mode 100644 index 0000000000..04bd313985 --- /dev/null +++ b/packages/app/schema/archived_gm/__difference.json @@ -0,0 +1,56 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "archived_gm_difference", + "type": "object", + "properties": { + "tested_overall__infected_moving_average_archived_20230331": { + "$ref": "#/definitions/diff_decimal" + }, + "tested_overall__infected_per_100k_moving_average_archived_20230331": { + "$ref": "#/definitions/diff_decimal" + } + }, + "additionalProperties": false, + "definitions": { + "diff_integer": { + "title": "difference_integer", + "type": "object", + "properties": { + "old_value": { + "type": "integer" + }, + "difference": { + "type": "integer" + }, + "old_date_unix": { + "type": "integer" + }, + "new_date_unix": { + "type": "integer" + } + }, + "required": ["old_value", "difference", "old_date_unix", "new_date_unix"], + "additionalProperties": false + }, + "diff_decimal": { + "title": "difference_decimal", + "type": "object", + "properties": { + "old_value": { + "type": "number" + }, + "difference": { + "type": "number" + }, + "old_date_unix": { + "type": "integer" + }, + "new_date_unix": { + "type": "integer" + } + }, + "required": ["old_value", "difference", "old_date_unix", "new_date_unix"], + "additionalProperties": false + } + } +} diff --git a/packages/app/schema/archived_gm/__index.json b/packages/app/schema/archived_gm/__index.json index f543072397..bcd8d4538e 100644 --- a/packages/app/schema/archived_gm/__index.json +++ b/packages/app/schema/archived_gm/__index.json @@ -3,13 +3,7 @@ "type": "object", "title": "archived_gm", "additionalProperties": false, - "required": [ - "last_generated", - "proto_name", - "name", - "code", - "sewer_archived_20230623" - ], + "required": ["last_generated", "proto_name", "name", "code", "difference", "sewer_archived_20230623", "tested_overall_archived_20230331"], "properties": { "last_generated": { "type": "string" @@ -23,8 +17,14 @@ "code": { "$ref": "#/$defs/archived_gm_code" }, + "difference": { + "$ref": "__difference.json" + }, "sewer_archived_20230623": { "$ref": "sewer.json" + }, + "tested_overall_archived_20230331": { + "$ref": "positive_tests/tested_overall.json" } }, "$defs": { diff --git a/packages/app/schema/gm/tested_overall.json b/packages/app/schema/archived_gm/positive_tests/tested_overall.json similarity index 100% rename from packages/app/schema/gm/tested_overall.json rename to packages/app/schema/archived_gm/positive_tests/tested_overall.json diff --git a/packages/app/schema/archived_gm_collection/__index.json b/packages/app/schema/archived_gm_collection/__index.json index c19a86d3be..f1bc4f9aa0 100644 --- a/packages/app/schema/archived_gm_collection/__index.json +++ b/packages/app/schema/archived_gm_collection/__index.json @@ -3,13 +3,7 @@ "type": "object", "title": "archived_gm_collection", "additionalProperties": false, - "required": [ - "last_generated", - "proto_name", - "name", - "code", - "sewer_archived_20230623" - ], + "required": ["last_generated", "proto_name", "name", "code", "sewer_archived_20230623", "tested_overall_archived_20230331"], "properties": { "last_generated": { "type": "string" @@ -30,6 +24,14 @@ "items": { "$ref": "sewer.json" } + }, + "tested_overall_archived_20230331": { + "type": "array", + "minItems": 342, + "maxItems": 342, + "items": { + "$ref": "positive_tests/tested_overall.json" + } } }, "$defs": { diff --git a/packages/app/schema/gm_collection/tested_overall.json b/packages/app/schema/archived_gm_collection/positive_tests/tested_overall.json similarity index 100% rename from packages/app/schema/gm_collection/tested_overall.json rename to packages/app/schema/archived_gm_collection/positive_tests/tested_overall.json diff --git a/packages/app/schema/archived_nl/__difference.json b/packages/app/schema/archived_nl/__difference.json index 185c9bb6b5..ee61b7bf63 100644 --- a/packages/app/schema/archived_nl/__difference.json +++ b/packages/app/schema/archived_nl/__difference.json @@ -6,25 +6,41 @@ "nursing_home__deceased_daily_archived_20230126": { "$ref": "#/definitions/diff_integer" }, - "vulnerable_nursing_home__infected_locations_total_archived_20230711": { + "nursing_home__newly_infected_people_archived_20230126": { "$ref": "#/definitions/diff_integer" }, - "nursing_home__newly_infected_people_archived_20230126": { + "reproduction__index_average_archived_20230711": { + "$ref": "#/definitions/diff_decimal" + }, + "tested_ggd__infected_percentage_moving_average_archived_20230321": { + "$ref": "#/definitions/diff_decimal" + }, + "tested_ggd__tested_total_moving_average_archived_20230321": { + "$ref": "#/definitions/diff_decimal" + }, + "tested_overall__infected_moving_average_archived_20230331": { + "$ref": "#/definitions/diff_decimal" + }, + "tested_overall__infected_per_100k_moving_average_archived_20230331": { + "$ref": "#/definitions/diff_decimal" + }, + "vulnerable_nursing_home__infected_locations_total_archived_20230711": { "$ref": "#/definitions/diff_integer" }, "vulnerable_hospital_admissions_archived_20230711": { "$ref": "#/definitions/diff_integer" - }, - "reproduction__index_average_archived_20230711": { - "$ref": "#/definitions/diff_decimal" } }, "required": [ "nursing_home__deceased_daily_archived_20230126", - "vulnerable_nursing_home__infected_locations_total_archived_20230711", "nursing_home__newly_infected_people_archived_20230126", + "reproduction__index_average_archived_20230711", + "tested_ggd__infected_percentage_moving_average_archived_20230321", + "tested_ggd__tested_total_moving_average_archived_20230321", + "tested_overall__infected_moving_average_archived_20230331", + "tested_overall__infected_per_100k_moving_average_archived_20230331", "vulnerable_hospital_admissions_archived_20230711", - "reproduction__index_average_archived_20230711" + "vulnerable_nursing_home__infected_locations_total_archived_20230711" ], "additionalProperties": false, "definitions": { diff --git a/packages/app/schema/archived_nl/__index.json b/packages/app/schema/archived_nl/__index.json index 64adc6fd48..91f6e750e9 100644 --- a/packages/app/schema/archived_nl/__index.json +++ b/packages/app/schema/archived_nl/__index.json @@ -12,11 +12,15 @@ "behavior_annotations_archived_20230412", "behavior_per_age_group_archived_20230411", "doctor_archived_20210903", + "g_number_archived_20220307", "nursing_home_archived_20230126", + "reproduction_archived_20230711", "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", - "reproduction_archived_20230711" + "vulnerable_nursing_home_archived_20230711" ], "additionalProperties": false, "properties": { @@ -47,9 +51,21 @@ "doctor_archived_20210903": { "$ref": "doctor.json" }, + "g_number_archived_20220307": { + "$ref": "positive_tests/g_number.json" + }, "nursing_home_archived_20230126": { "$ref": "nursing_home.json" }, + "tested_ggd_archived_20230321": { + "$ref": "positive_tests/tested_ggd.json" + }, + "tested_overall_archived_20230331": { + "$ref": "positive_tests/tested_overall.json" + }, + "tested_per_age_group_archived_20230331": { + "$ref": "positive_tests/tested_per_age_group.json" + }, "sewer_archived_20230623": { "$ref": "sewer.json" }, diff --git a/packages/app/schema/nl/g_number.json b/packages/app/schema/archived_nl/positive_tests/g_number.json similarity index 100% rename from packages/app/schema/nl/g_number.json rename to packages/app/schema/archived_nl/positive_tests/g_number.json diff --git a/packages/app/schema/nl/tested_ggd.json b/packages/app/schema/archived_nl/positive_tests/tested_ggd.json similarity index 100% rename from packages/app/schema/nl/tested_ggd.json rename to packages/app/schema/archived_nl/positive_tests/tested_ggd.json diff --git a/packages/app/schema/nl/tested_overall.json b/packages/app/schema/archived_nl/positive_tests/tested_overall.json similarity index 100% rename from packages/app/schema/nl/tested_overall.json rename to packages/app/schema/archived_nl/positive_tests/tested_overall.json diff --git a/packages/app/schema/nl/tested_per_age_group.json b/packages/app/schema/archived_nl/positive_tests/tested_per_age_group.json similarity index 100% rename from packages/app/schema/nl/tested_per_age_group.json rename to packages/app/schema/archived_nl/positive_tests/tested_per_age_group.json diff --git a/packages/app/schema/gm/__difference.json b/packages/app/schema/gm/__difference.json index c92cd8292a..f75212fa23 100644 --- a/packages/app/schema/gm/__difference.json +++ b/packages/app/schema/gm/__difference.json @@ -3,12 +3,6 @@ "title": "gm_difference", "type": "object", "properties": { - "tested_overall__infected_per_100k_moving_average": { - "$ref": "#/definitions/diff_decimal" - }, - "tested_overall__infected_moving_average": { - "$ref": "#/definitions/diff_decimal" - }, "hospital_nice__admissions_on_date_of_reporting_moving_average": { "$ref": "#/definitions/diff_decimal" }, @@ -19,12 +13,7 @@ "$ref": "#/definitions/diff_integer" } }, - "required": [ - "tested_overall__infected_per_100k_moving_average", - "tested_overall__infected_moving_average", - "hospital_nice__admissions_on_date_of_reporting_moving_average", - "deceased_rivm__covid_daily_archived_20221231" - ], + "required": ["hospital_nice__admissions_on_date_of_reporting_moving_average", "deceased_rivm__covid_daily_archived_20221231"], "additionalProperties": false, "definitions": { "diff_integer": { diff --git a/packages/app/schema/gm/__index.json b/packages/app/schema/gm/__index.json index 47ad240a02..0fbd9cd656 100644 --- a/packages/app/schema/gm/__index.json +++ b/packages/app/schema/gm/__index.json @@ -15,7 +15,6 @@ "sewer_installation_measurement", "sewer_per_installation", "sewer", - "tested_overall", "vaccine_coverage_per_age_group", "vaccine_coverage_per_age_group_archived", "vaccine_coverage_per_age_group_archived_20220908", @@ -46,9 +45,6 @@ "hospital_nice": { "$ref": "hospital_nice.json" }, - "tested_overall": { - "$ref": "tested_overall.json" - }, "sewer": { "$ref": "sewer.json" }, diff --git a/packages/app/schema/gm_collection/__index.json b/packages/app/schema/gm_collection/__index.json index c94b90c8ab..50df843a28 100644 --- a/packages/app/schema/gm_collection/__index.json +++ b/packages/app/schema/gm_collection/__index.json @@ -3,7 +3,7 @@ "type": "object", "title": "gm_collection", "additionalProperties": false, - "required": ["last_generated", "proto_name", "name", "code", "hospital_nice", "hospital_nice_choropleth", "tested_overall", "sewer", "vaccine_coverage_per_age_group"], + "required": ["last_generated", "proto_name", "name", "code", "hospital_nice", "hospital_nice_choropleth", "sewer", "vaccine_coverage_per_age_group"], "properties": { "last_generated": { "type": "string" @@ -33,14 +33,6 @@ "$ref": "hospital_nice.json" } }, - "tested_overall": { - "type": "array", - "minItems": 342, - "maxItems": 342, - "items": { - "$ref": "tested_overall.json" - } - }, "sewer": { "type": "array", "minItems": 342, diff --git a/packages/app/schema/nl/__difference.json b/packages/app/schema/nl/__difference.json index 9887fde012..f5d938b424 100644 --- a/packages/app/schema/nl/__difference.json +++ b/packages/app/schema/nl/__difference.json @@ -3,18 +3,6 @@ "title": "nl_difference", "type": "object", "properties": { - "tested_overall__infected_per_100k_moving_average": { - "$ref": "#/definitions/diff_decimal" - }, - "tested_overall__infected_moving_average": { - "$ref": "#/definitions/diff_decimal" - }, - "tested_ggd__tested_total_moving_average": { - "$ref": "#/definitions/diff_decimal" - }, - "tested_ggd__infected_percentage_moving_average": { - "$ref": "#/definitions/diff_decimal" - }, "infectious_people__estimate": { "$ref": "#/definitions/diff_integer" }, @@ -44,12 +32,8 @@ } }, "required": [ - "tested_overall__infected_per_100k_moving_average", - "tested_overall__infected_moving_average", "hospital_nice__admissions_on_date_of_reporting_moving_average", "hospital_lcps__beds_occupied_covid", - "tested_ggd__tested_total_moving_average", - "tested_ggd__infected_percentage_moving_average", "infectious_people__estimate", "intensive_care_nice__admissions_on_date_of_reporting_moving_average", "intensive_care_lcps__beds_occupied_covid", diff --git a/packages/app/schema/nl/__index.json b/packages/app/schema/nl/__index.json index 5c46945f03..f2b0101212 100644 --- a/packages/app/schema/nl/__index.json +++ b/packages/app/schema/nl/__index.json @@ -16,7 +16,6 @@ "named_difference", "disability_care_archived_20230126", "elderly_at_home_archived_20230126", - "g_number", "hospital_lcps", "hospital_nice", "hospital_nice_per_age_group", @@ -29,9 +28,6 @@ "proto_name", "self_test_overall", "sewer", - "tested_ggd", - "tested_overall", - "tested_per_age_group", "vaccine_campaigns", "vaccine_campaigns_archived_20220908", "vaccine_planned_archived_20220908", @@ -82,9 +78,6 @@ "booster_coverage_archived_20220904": { "$ref": "booster_coverage_archived_20220904.json" }, - "g_number": { - "$ref": "g_number.json" - }, "infectious_people": { "$ref": "infectious_people.json" }, @@ -94,12 +87,6 @@ "intensive_care_nice_per_age_group": { "$ref": "intensive_care_nice_per_age_group.json" }, - "tested_overall": { - "$ref": "tested_overall.json" - }, - "tested_per_age_group": { - "$ref": "tested_per_age_group.json" - }, "sewer": { "$ref": "sewer.json" }, @@ -115,9 +102,6 @@ "intensive_care_lcps": { "$ref": "intensive_care_lcps.json" }, - "tested_ggd": { - "$ref": "tested_ggd.json" - }, "disability_care_archived_20230126": { "$ref": "disability_care_archived_20230126.json" }, diff --git a/packages/app/src/components/choropleth/logic/types.ts b/packages/app/src/components/choropleth/logic/types.ts index 352b7bc5a2..0e994de2ba 100644 --- a/packages/app/src/components/choropleth/logic/types.ts +++ b/packages/app/src/components/choropleth/logic/types.ts @@ -1,4 +1,5 @@ import type { + ArchivedGmCollection, GmCollection, GmCollectionHospitalNice, GmCollectionSewer, @@ -44,12 +45,14 @@ export const mapToCodeType: Record = { vr: 'vrcode', }; -export type ChoroplethCollection = GmCollection | VrCollection; +export type ChoroplethCollection = GmCollection | ArchivedGmCollection | VrCollection; -export type InferedMapType = T extends GmDataItem ? 'gm' : T extends VrDataItem | ArchivedVrDataItem ? 'vr' : never; +export type InferedMapType = T extends GmDataItem | ArchivedGmDataItem ? 'gm' : T extends VrDataItem | ArchivedVrDataItem ? 'vr' : never; export type InferedDataCollection = T extends GmDataItem ? GmCollection + : T extends ArchivedGmDataItem + ? ArchivedGmCollection : T extends VrDataItem ? VrCollection : T extends ArchivedVrDataItem @@ -59,13 +62,16 @@ export type InferedDataCollection = T extends GmDa export type VrDataCollection = VrCollectionDisabilityCareArchived_20230126[] | VrCollectionElderlyAtHomeArchived_20230126[] | VrCollectionVulnerableNursingHome[]; export type VrDataItem = VrDataCollection[number]; -export type GmDataCollection = GmCollectionHospitalNice[] | GmCollectionTestedOverall[] | GmCollectionSewer[] | GmCollectionVaccineCoveragePerAgeGroup[]; +export type GmDataCollection = GmCollectionHospitalNice[] | GmCollectionSewer[] | GmCollectionVaccineCoveragePerAgeGroup[]; export type GmDataItem = GmDataCollection[number]; +export type ArchivedGmDataCollection = GmCollectionTestedOverall[]; +export type ArchivedGmDataItem = ArchivedGmDataCollection[number]; + export type ArchivedVrDataCollection = []; export type ArchivedVrDataItem = ArchivedVrDataCollection[number]; -export type ChoroplethDataItem = GmDataItem | VrDataItem | ArchivedVrDataItem; +export type ChoroplethDataItem = GmDataItem | ArchivedGmDataItem | VrDataItem | ArchivedVrDataItem; export type CodedGeoProperties = { code: string; diff --git a/packages/app/src/pages/gemeente/[code]/positief-testen.tsx b/packages/app/src/pages/gemeente/[code]/positief-testen.tsx index 78ff6aad5e..26f9cddb7e 100644 --- a/packages/app/src/pages/gemeente/[code]/positief-testen.tsx +++ b/packages/app/src/pages/gemeente/[code]/positief-testen.tsx @@ -26,7 +26,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, selectGmData } from '~/static-props/get-data'; +import { createGetArchivedChoroplethData, createGetContent, getLastGeneratedDate, getLokalizeTexts, selectGmData, selectArchivedGmData } from '~/static-props/get-data'; import { filterByRegionMunicipalities } from '~/static-props/utils/filter-by-region-municipalities'; import { ArticleParts, PagePartQueryResult } from '~/types/cms'; import { replaceComponentsInText, replaceVariablesInText, useReverseRouter } from '~/utils'; @@ -48,16 +48,11 @@ const pageMetrics = ['tested_overall']; export const getStaticProps = createGetStaticProps( ({ locale }: { locale: keyof Languages }) => getLokalizeTexts(selectLokalizeTexts, locale), getLastGeneratedDate, - selectGmData( - 'code', - 'difference.tested_overall__infected_moving_average', - 'difference.tested_overall__infected_per_100k_moving_average', - 'static_values.population_count', - 'tested_overall' - ), - createGetChoroplethData({ - gm: ({ tested_overall }, context) => ({ - tested_overall: filterByRegionMunicipalities(tested_overall, context), + selectGmData('code', 'static_values.population_count'), + selectArchivedGmData('tested_overall_archived_20230331'), + createGetArchivedChoroplethData({ + gm: ({ tested_overall_archived_20230331 }, context) => ({ + tested_overall_archived_20230331: filterByRegionMunicipalities(tested_overall_archived_20230331, context), }), }), async (context: GetStaticPropsContext) => { @@ -68,7 +63,7 @@ export const getStaticProps = createGetStaticProps( const { locale } = context; return `{ "parts": ${getPagePartsQuery('positive_tests_page')}, - "elements": ${getElementsQuery('gm', ['tested_overall'], locale)} + "elements": ${getElementsQuery('archived_gm', ['tested_overall_archived_20230331'], locale)} }`; })(context); return { @@ -83,13 +78,13 @@ export const getStaticProps = createGetStaticProps( ); function PositivelyTestedPeople(props: StaticProps) { - const { pageText, selectedGmData: data, choropleth, municipalityName, content, lastGenerated } = props; + const { pageText, selectedGmData: data, selectedArchivedGmData: archived_data, archivedChoropleth, municipalityName, content, lastGenerated } = props; const [positivelyTestedPeopleTimeframe, setpositivelyTestedPeopleTimeframe] = useState(TimeframeOption.SIX_MONTHS); const { commonTexts, formatNumber, formatDateFromSeconds } = useIntl(); const reverseRouter = useReverseRouter(); const { textGm, textShared } = useDynamicLokalizeTexts(pageText, selectLokalizeTexts); - const lastValue = data.tested_overall.last_value; + const archivedLastValue = archived_data.tested_overall_archived_20230331.last_value; const populationCount = data.static_values.population_count; const metadata = { ...commonTexts.gemeente_index.metadata, @@ -116,7 +111,7 @@ function PositivelyTestedPeople(props: StaticProps) { description={textGm.pagina_toelichting} metadata={{ datumsText: textGm.datums, - dateOrRange: lastValue.date_unix, + dateOrRange: archivedLastValue.date_unix, dateOfInsertionUnix: lastInsertionDateOfPage, dataSources: [textGm.bronnen.rivm], }} @@ -134,11 +129,11 @@ function PositivelyTestedPeople(props: StaticProps) { - + {replaceComponentsInText(commonTexts.gemeente_index.population_count, { municipalityName, @@ -150,8 +145,8 @@ function PositivelyTestedPeople(props: StaticProps) { {textGm.infected_kpi.link_cta && } @@ -161,18 +156,18 @@ function PositivelyTestedPeople(props: StaticProps) { - + {textGm.barscale_toelichting} {replaceComponentsInText(textGm.population_count_explanation, { municipalityName: {municipalityName}, - value: {formatNumber(lastValue.infected_per_100k_moving_average)}, + value: {formatNumber(archivedLastValue.infected_per_100k_moving_average)}, })} @@ -193,7 +188,7 @@ function PositivelyTestedPeople(props: StaticProps) { accessibility={{ key: 'confirmed_cases_infected_over_time_chart', }} - values={data.tested_overall.values} + values={archived_data.tested_overall_archived_20230331.values} timeframe={positivelyTestedPeopleTimeframe} seriesConfig={[ { @@ -211,7 +206,7 @@ function PositivelyTestedPeople(props: StaticProps) { }, ]} dataOptions={{ - timelineEvents: getTimelineEvents(content.elements.timeSeries, 'tested_overall'), + timelineEvents: getTimelineEvents(content.elements.timeSeries, 'tested_overall_archived_20230331'), }} /> @@ -226,7 +221,7 @@ function PositivelyTestedPeople(props: StaticProps) { @@ -237,7 +232,7 @@ function PositivelyTestedPeople(props: StaticProps) { title: textShared.chloropleth_legenda_titel, }} metadata={{ - date: lastValue.date_unix, + date: archivedLastValue.date_unix, source: textGm.bronnen.rivm, }} > @@ -246,9 +241,9 @@ function PositivelyTestedPeople(props: StaticProps) { accessibility={{ key: 'confirmed_cases_choropleth', }} - data={choropleth.gm.tested_overall} + data={archivedChoropleth.gm.tested_overall_archived_20230331} dataConfig={{ - metricName: 'tested_overall', + metricName: 'tested_overall_archived_20230331', metricProperty: 'infected_per_100k', dataFormatters: { infected: formatNumber, diff --git a/packages/app/src/pages/landelijk/positieve-testen.tsx b/packages/app/src/pages/landelijk/positieve-testen.tsx index d1064aa0a2..11078068e2 100644 --- a/packages/app/src/pages/landelijk/positieve-testen.tsx +++ b/packages/app/src/pages/landelijk/positieve-testen.tsx @@ -26,7 +26,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, selectNlData } from '~/static-props/get-data'; +import { createGetArchivedChoroplethData, createGetContent, getLastGeneratedDate, getLokalizeTexts, selectArchivedNlData } from '~/static-props/get-data'; import { space } from '~/style/theme'; import { ArticleParts, PagePartQueryResult } from '~/types/cms'; import { useDynamicLokalizeTexts } from '~/utils/cms/use-dynamic-lokalize-texts'; @@ -36,7 +36,7 @@ import { replaceComponentsInText } from '~/utils/replace-components-in-text'; import { replaceVariablesInText } from '~/utils/replace-variables-in-text'; import { useReverseRouter } from '~/utils/use-reverse-router'; -const pageMetrics = ['g_number', 'tested_ggd', 'tested_overall', 'tested_per_age_group']; +const pageMetrics = ['g_number_archived_20220307', 'tested_ggd_archived_20230321', 'tested_overall_archived_20230331', 'tested_per_age_group_archived_20230331']; const selectLokalizeTexts = (siteText: SiteText) => ({ metadataTexts: siteText.pages.topical_page.nl.nationaal_metadata, @@ -49,18 +49,9 @@ type LokalizeTexts = ReturnType; export const getStaticProps = createGetStaticProps( ({ locale }: { locale: keyof Languages }) => getLokalizeTexts(selectLokalizeTexts, locale), getLastGeneratedDate, - selectNlData( - 'difference.tested_ggd__infected_percentage_moving_average', - 'difference.tested_ggd__tested_total_moving_average', - 'difference.tested_overall__infected_moving_average', - 'difference.tested_overall__infected_per_100k_moving_average', - 'g_number', - 'tested_ggd', - 'tested_overall', - 'tested_per_age_group' - ), - createGetChoroplethData({ - gm: ({ tested_overall }) => ({ tested_overall }), + selectArchivedNlData('g_number_archived_20220307', 'tested_ggd_archived_20230321', 'tested_overall_archived_20230331', 'tested_per_age_group_archived_20230331'), + createGetArchivedChoroplethData({ + gm: ({ tested_overall_archived_20230331 }) => ({ tested_overall_archived_20230331 }), }), async (context: GetStaticPropsContext) => { const { content } = await createGetContent<{ @@ -70,7 +61,7 @@ export const getStaticProps = createGetStaticProps( const { locale } = context; return `{ "parts": ${getPagePartsQuery('positive_tests_page')}, - "elements": ${getElementsQuery('nl', ['tested_overall', 'tested_ggd', 'tested_per_age_group'], locale)} + "elements": ${getElementsQuery('archived_nl', ['tested_overall_archived_20230331', 'tested_ggd_archived_20230321', 'tested_per_age_group_archived_20230331'], locale)} }`; })(context); return { @@ -85,7 +76,7 @@ export const getStaticProps = createGetStaticProps( ); function PositivelyTestedPeople(props: StaticProps) { - const { pageText, selectedNlData: data, choropleth, content, lastGenerated } = props; + const { pageText, selectedArchivedNlData: data, archivedChoropleth, content, lastGenerated } = props; const [confirmedCasesInfectedTimeframe, setConfirmedCasesInfectedTimeframe] = useState(TimeframeOption.SIX_MONTHS); @@ -113,8 +104,8 @@ function PositivelyTestedPeople(props: StaticProps) { }, ]; - const dataOverallLastValue = data.tested_overall.last_value; - const dataGgdLastValue = data.tested_ggd.last_value; + const archivedDataOverallLastValue = data.tested_overall_archived_20230331.last_value; + const archivedDataGgdLastValue = data.tested_ggd_archived_20230321.last_value; const metadata = { ...metadataTexts, @@ -136,7 +127,7 @@ function PositivelyTestedPeople(props: StaticProps) { description={textNl.pagina_toelichting} metadata={{ datumsText: textNl.datums, - dateOrRange: dataOverallLastValue.date_unix, + dateOrRange: archivedDataOverallLastValue.date_unix, dateOfInsertionUnix: lastInsertionDateOfPage, dataSources: [textNl.bronnen.rivm], }} @@ -151,9 +142,9 @@ function PositivelyTestedPeople(props: StaticProps) { ) { accessibility={{ key: 'confirmed_cases_infected_over_time_chart', }} - values={data.tested_overall.values} + values={data.tested_overall_archived_20230331.values} timeframe={confirmedCasesInfectedTimeframe} seriesConfig={[ { @@ -189,7 +180,7 @@ function PositivelyTestedPeople(props: StaticProps) { tooltipLabel: textNl.tooltip_labels.annotations, checkIsOutofBounds: (x: NlTestedOverallValue, max: number) => x.infected > max, }, - timelineEvents: getTimelineEvents(content.elements.timeSeries, 'tested_overall'), + timelineEvents: getTimelineEvents(content.elements.timeSeries, 'tested_overall_archived_20230331'), }} /> @@ -200,9 +191,9 @@ function PositivelyTestedPeople(props: StaticProps) { timeframeOptions={TimeframeOptionsList} title={textNl.ggd.linechart_percentage_titel} description={replaceVariablesInText(textNl.ggd.linechart_percentage_toelichting, { - date: formatDateFromSeconds(dataGgdLastValue.date_unix, 'weekday-long'), - tested_total: formatNumber(dataGgdLastValue.tested_total), - infected_total: formatNumber(dataGgdLastValue.infected), + date: formatDateFromSeconds(archivedDataGgdLastValue.date_unix, 'weekday-long'), + tested_total: formatNumber(archivedDataGgdLastValue.tested_total), + infected_total: formatNumber(archivedDataGgdLastValue.infected), })} metadata={{ date: getLastInsertionDateOfPage(data, ['tested_ggd']), @@ -220,7 +211,7 @@ function PositivelyTestedPeople(props: StaticProps) { key: 'confirmed_cases_infected_percentage_over_time_chart', }} timeframe={confirmedCasesInfectedPercentageTimeframe} - values={data.tested_ggd.values} + values={data.tested_ggd_archived_20230321.values} forceLegend seriesConfig={[ { @@ -239,9 +230,9 @@ function PositivelyTestedPeople(props: StaticProps) { timeframeOptions={TimeframeOptionsList} title={textNl.ggd.linechart_totaltests_titel} description={replaceVariablesInText(textNl.ggd.linechart_totaltests_toelichting, { - date: formatDateFromSeconds(dataGgdLastValue.date_unix, 'weekday-long'), - tested_total: formatNumber(dataGgdLastValue.tested_total), - infected_total: formatNumber(dataGgdLastValue.infected), + date: formatDateFromSeconds(archivedDataGgdLastValue.date_unix, 'weekday-long'), + tested_total: formatNumber(archivedDataGgdLastValue.tested_total), + infected_total: formatNumber(archivedDataGgdLastValue.infected), })} metadata={{ source: textNl.ggd.bronnen.rivm, @@ -259,7 +250,7 @@ function PositivelyTestedPeople(props: StaticProps) { key: 'confirmed_cases_tested_over_time_chart', }} timeframe={confirmedCasesTestedOverTimeTimeframe} - values={data.tested_ggd.values} + values={data.tested_ggd_archived_20230321.values} seriesConfig={[ { type: 'line', @@ -295,9 +286,9 @@ function PositivelyTestedPeople(props: StaticProps) { accessibility={{ key: 'confirmed_cases_infected_per_age_group_over_time_chart', }} - values={data.tested_per_age_group.values} + values={data.tested_per_age_group_archived_20230331.values} timeframe={confirmedCasesInfectedPerAgeTimeframe} - timelineEvents={getTimelineEvents(content.elements.timeSeries, 'tested_per_age_group')} + timelineEvents={getTimelineEvents(content.elements.timeSeries, 'tested_per_age_group_archived_20230331')} text={textNl} /> @@ -307,7 +298,7 @@ function PositivelyTestedPeople(props: StaticProps) { ) { {replaceComponentsInText(textNl.map_last_value_text, { - infected_per_100k: {`${formatNumber(dataOverallLastValue.infected_per_100k)}`}, - dateTo: formatDateFromSeconds(dataOverallLastValue.date_unix, 'weekday-long'), + infected_per_100k: {`${formatNumber(archivedDataOverallLastValue.infected_per_100k)}`}, + dateTo: formatDateFromSeconds(archivedDataOverallLastValue.date_unix, 'weekday-long'), })} @@ -331,9 +322,9 @@ function PositivelyTestedPeople(props: StaticProps) { accessibility={{ key: 'confirmed_cases_municipal_choropleth', }} - data={choropleth.gm.tested_overall} + data={archivedChoropleth.gm.tested_overall_archived_20230331} dataConfig={{ - metricName: 'tested_overall', + metricName: 'tested_overall_archived_20230331', metricProperty: 'infected_per_100k', dataFormatters: { infected: formatNumber, @@ -348,7 +339,7 @@ function PositivelyTestedPeople(props: StaticProps) { - + {content.faqs && content.faqs.questions?.length > 0 && } diff --git a/packages/app/src/static-props/utils/load-json-from-data-file.ts b/packages/app/src/static-props/utils/load-json-from-data-file.ts index 5b64b0a45f..151da41b75 100644 --- a/packages/app/src/static-props/utils/load-json-from-data-file.ts +++ b/packages/app/src/static-props/utils/load-json-from-data-file.ts @@ -1,11 +1,7 @@ import fs from 'fs'; import path from 'path'; -export function loadJsonFromDataFile( - filename: string, - jsonFolder = 'json', - dontFailOnNotFound = false -): T { +export function loadJsonFromDataFile(filename: string, jsonFolder = 'json', dontFailOnNotFound = false): T { const filePath = path.join(process.cwd(), 'public', jsonFolder, filename); try { const fileContents = fs.readFileSync(filePath, 'utf8'); diff --git a/packages/cms-v2/src/elements/schemas/shared/index.ts b/packages/cms-v2/src/elements/schemas/shared/index.ts index ecf5a62481..41b7579e29 100644 --- a/packages/cms-v2/src/elements/schemas/shared/index.ts +++ b/packages/cms-v2/src/elements/schemas/shared/index.ts @@ -52,7 +52,7 @@ export const commonPreview = { * choropleth and maybe even introducing a specific icon for each element type. */ const titleByMetricName: Partial> = { - tested_overall: 'Positief geteste mensen', + tested_overall_archived_20230331: 'Positief geteste mensen', sewer: 'Rioolwater metingen', hospital_nice: 'Ziekenhuisopnames', intensive_care_nice: 'IC-opnames', @@ -68,7 +68,7 @@ const titleByMetricName: Partial> = { deceased_rivm_archived_20221231: 'Sterfte (RIVM)', intensive_care_nice_per_age_group: 'IC-opnames (per leeftijd)', hospital_nice_per_age_group: 'Ziekenhuisopnames (per leeftijd)', - tested_per_age_group: 'Positief getest (per leeftijd)', + tested_per_age_group_archived_20230331: 'Positief getest (per leeftijd)', elderly_at_home_archived_20230126: '70-plussers', self_test_overall: 'Zelfgerapporteerde positieve coronatestuitslagen', }; diff --git a/packages/cms/src/studio/constants.ts b/packages/cms/src/studio/constants.ts index 9396c4ec30..a563986a8a 100644 --- a/packages/cms/src/studio/constants.ts +++ b/packages/cms/src/studio/constants.ts @@ -17,7 +17,7 @@ export const titleByMetricName: Partial> = { disability_care_archived_20230126: 'Gehandicaptenzorg', doctor_archived_20210903: 'Huisartsen', elderly_at_home_archived_20230126: '70-plussers', - g_number: 'Ontwikkeling aantal positieve testen', + g_number_archived_20220307: 'Ontwikkeling aantal positieve testen', hospital_lcps: 'Ziekenhuisopnames (LCPS)', hospital_nice_per_age_group: 'Ziekenhuisopnames (per leeftijd) (NICE)', hospital_nice: 'Ziekenhuisopnames (NICE)', @@ -33,9 +33,9 @@ export const titleByMetricName: Partial> = { sewer_per_installation: 'Virusdeeltjes in rioolwater', sewer: 'Rioolwater metingen', static_values: 'Statische waarden', - tested_ggd: "Positief geteste mensen (GGD'en)", - tested_overall: 'Positief geteste mensen', - tested_per_age_group: 'Positief getest (per leeftijd)', + tested_ggd_archived_20230321: "Positief geteste mensen (GGD'en)", + tested_overall_archived_20230331: 'Positief geteste mensen', + tested_per_age_group_archived_20230331: 'Positief getest (per leeftijd)', vaccine_administered_doctors: 'Gezette prikken (huisartsen)', vaccine_administered_ggd_ghor: "Gezette prikken (GGD'en)", vaccine_administered_ggd: "Gezette prikken (GGD'en)", @@ -102,4 +102,4 @@ export const DAYS_OF_THE_WEEK_LIST = [ }, ]; -export const RELATIVE_SCHEMA_PATH = '../../../app/schema'; +export const RELATIVE_SCHEMA_PATH = '../../../../app/schema'; diff --git a/packages/cms/src/studio/data/data-structure.ts b/packages/cms/src/studio/data/data-structure.ts index 19dc29d866..9d7b2ee2eb 100644 --- a/packages/cms/src/studio/data/data-structure.ts +++ b/packages/cms/src/studio/data/data-structure.ts @@ -3,8 +3,14 @@ * This file is generated based on the JSON schema's by yarn generate-data-structures in the cli package. */ export const dataStructure = { - archived_gm: { sewer_archived_20230623: ['average', 'total_number_of_samples', 'sampled_installation_count', 'total_installation_count', 'data_is_outdated'] }, - archived_gm_collection: { sewer_archived_20230623: ['average', 'total_installation_count', 'data_is_outdated'] }, + archived_gm: { + sewer_archived_20230623: ['average', 'total_number_of_samples', 'sampled_installation_count', 'total_installation_count', 'data_is_outdated'], + tested_overall_archived_20230331: ['infected', 'infected_moving_average', 'infected_moving_average_rounded', 'infected_per_100k', 'infected_per_100k_moving_average'], + }, + archived_gm_collection: { + sewer_archived_20230623: ['average', 'total_installation_count', 'data_is_outdated'], + tested_overall_archived_20230331: ['infected_per_100k', 'infected'], + }, archived_nl: { behavior_archived_20230411: [ 'number_of_participants', @@ -67,6 +73,7 @@ export const dataStructure = { ], behavior_annotations_archived_20230412: ['behavior_indicator', 'message_title_nl', 'message_title_en', 'message_desc_nl', 'message_desc_en'], doctor_archived_20210903: ['covid_symptoms_per_100k', 'covid_symptoms'], + g_number_archived_20220307: ['g_number'], nursing_home_archived_20230126: [ 'newly_infected_people', 'newly_infected_people_moving_average', @@ -76,6 +83,29 @@ export const dataStructure = { 'infected_locations_total', 'infected_locations_percentage', ], + tested_ggd_archived_20230321: [ + 'infected', + 'infected_moving_average', + 'infected_percentage', + 'infected_percentage_moving_average', + 'tested_total', + 'tested_total_moving_average', + 'tested_total_moving_average_rounded', + ], + tested_overall_archived_20230331: ['infected', 'infected_moving_average', 'infected_moving_average_rounded', 'infected_per_100k', 'infected_per_100k_moving_average'], + tested_per_age_group_archived_20230331: [ + 'infected_age_0_9_per_100k', + 'infected_age_10_19_per_100k', + 'infected_age_20_29_per_100k', + 'infected_age_30_39_per_100k', + 'infected_age_40_49_per_100k', + 'infected_age_50_59_per_100k', + 'infected_age_60_69_per_100k', + 'infected_age_70_79_per_100k', + 'infected_age_80_89_per_100k', + 'infected_age_90_plus_per_100k', + 'infected_overall_per_100k', + ], sewer_archived_20230623: ['average'], vulnerable_nursing_home_archived_20230711: ['newly_infected_locations', 'infected_locations_total', 'infected_locations_percentage'], reproduction_archived_20230711: ['index_low', 'index_average', 'index_high'], @@ -88,7 +118,6 @@ export const dataStructure = { 'admissions_on_date_of_admission_moving_average_rounded', 'admissions_on_date_of_reporting', ], - tested_overall: ['infected', 'infected_moving_average', 'infected_moving_average_rounded', 'infected_per_100k', 'infected_per_100k_moving_average'], sewer: ['average', 'data_is_outdated'], vaccine_coverage_per_age_group: [ 'vaccination_type', @@ -125,7 +154,6 @@ export const dataStructure = { gm_collection: { hospital_nice: ['admissions_on_date_of_admission', 'admissions_on_date_of_admission_per_100000', 'admissions_on_date_of_reporting'], hospital_nice_choropleth: ['admissions_on_date_of_admission', 'admissions_on_date_of_admission_per_100000', 'admissions_on_date_of_reporting'], - tested_overall: ['infected_per_100k', 'infected'], sewer: ['average', 'data_is_outdated'], vaccine_coverage_per_age_group: [ 'vaccination_type', @@ -144,7 +172,6 @@ export const dataStructure = { booster_shot_administered_archived_20220904: ['administered_total', 'ggd_administered_total', 'others_administered_total'], repeating_shot_administered: ['ggd_administered_total'], booster_coverage_archived_20220904: ['age_group', 'percentage'], - g_number: ['g_number'], infectious_people: ['margin_low', 'estimate', 'margin_high'], intensive_care_nice: [ 'admissions_on_date_of_admission', @@ -164,20 +191,6 @@ export const dataStructure = { 'admissions_age_90_plus_per_million', 'admissions_overall_per_million', ], - tested_overall: ['infected', 'infected_moving_average', 'infected_moving_average_rounded', 'infected_per_100k', 'infected_per_100k_moving_average'], - tested_per_age_group: [ - 'infected_age_0_9_per_100k', - 'infected_age_10_19_per_100k', - 'infected_age_20_29_per_100k', - 'infected_age_30_39_per_100k', - 'infected_age_40_49_per_100k', - 'infected_age_50_59_per_100k', - 'infected_age_60_69_per_100k', - 'infected_age_70_79_per_100k', - 'infected_age_80_89_per_100k', - 'infected_age_90_plus_per_100k', - 'infected_overall_per_100k', - ], sewer: ['average'], hospital_nice: [ 'admissions_on_date_of_admission', @@ -199,15 +212,6 @@ export const dataStructure = { ], hospital_lcps: ['beds_occupied_covid', 'influx_covid_patients', 'influx_covid_patients_moving_average'], intensive_care_lcps: ['beds_occupied_covid', 'beds_occupied_covid_percentage', 'influx_covid_patients', 'influx_covid_patients_moving_average'], - tested_ggd: [ - 'infected', - 'infected_moving_average', - 'infected_percentage', - 'infected_percentage_moving_average', - 'tested_total', - 'tested_total_moving_average', - 'tested_total_moving_average_rounded', - ], disability_care_archived_20230126: [ 'newly_infected_people', 'newly_infected_people_moving_average', diff --git a/packages/cms/src/studio/scripts/add-chart.ts b/packages/cms/src/studio/scripts/add-chart.ts index aa678a93af..2ca648cb86 100644 --- a/packages/cms/src/studio/scripts/add-chart.ts +++ b/packages/cms/src/studio/scripts/add-chart.ts @@ -6,6 +6,7 @@ import { client } from '../client'; import { onState } from '../utils/abort-process'; import { getSchemaMetricProperties } from '../utils/get-schema-metric-properties'; import { getSchemaMetrics } from '../utils/get-schema-metrics'; +import { initialiseEnvironmentVariables } from '../../lokalize/utils/initialise-environment-variables'; type Element = { scope: DataScopeKey; @@ -15,9 +16,6 @@ type Element = { _id: string; }; -const developmentClient = client.withConfig({ dataset: 'development' }); -const productionClient = client.withConfig({ dataset: 'production' }); - const promptForElement = async (): Promise => { const element: Element = { scope: 'nl', @@ -31,6 +29,7 @@ const promptForElement = async (): Promise => { { title: 'National', value: 'nl' }, { title: 'National (archived)', value: 'archived_nl' }, { title: 'Municipal', value: 'gm' }, + { title: 'Municipal (archived)', value: 'archived_gm' }, ]; const scopeResponse = (await prompts({ @@ -126,6 +125,9 @@ const isNewElement = async (element: Element) => { *[_type == '${_type}' && _id == '${_id}'][0] `; + const developmentClient = client.withConfig({ dataset: 'development' }); + const productionClient = client.withConfig({ dataset: 'production' }); + const developmentDocument = await developmentClient.fetch(query); const productionDocument = await productionClient.fetch(query); @@ -135,13 +137,20 @@ const isNewElement = async (element: Element) => { const elementToId = (element: Element) => `${element.scope}__${element.metricName}__${snakeCase(element._type)}${isDefined(element.metricProperty) ? `__${element.metricProperty}` : ''}`; -const saveElement = async (element: Element) => Promise.all([developmentClient.create(element), productionClient.create(element)]); +const saveElement = async (element: Element, developmentClient: any, productionClient: any) => { + return Promise.all([developmentClient.create(element), productionClient.create(element)]); +}; (async () => { + await initialiseEnvironmentVariables(); + + const developmentClient = client.withConfig({ dataset: 'development', token: process.env.SANITY_API_TOKEN }); + const productionClient = client.withConfig({ dataset: 'production', token: process.env.SANITY_API_TOKEN }); + const element = await promptForElement(); if (isDefined(element)) { - await saveElement(element); + await saveElement(element, developmentClient, productionClient); } console.log('Have a swell day, friend. Goodluck and godspeed in all your endevours!'); diff --git a/packages/common/src/types/data-utils.ts b/packages/common/src/types/data-utils.ts index bbae70dae9..2509fcd77e 100644 --- a/packages/common/src/types/data-utils.ts +++ b/packages/common/src/types/data-utils.ts @@ -1,4 +1,4 @@ -import { ArchivedGm, ArchivedNl, Gm, Nl } from '.'; +import { ArchivedGm, ArchivedGmCollection, ArchivedNl, Gm, GmCollection, Nl, VrCollection } from '.'; /** * All possible datascopes. Can be used to access the types of a scope based on @@ -7,8 +7,11 @@ import { ArchivedGm, ArchivedNl, Gm, Nl } from '.'; export type ScopedData = { gm: Gm; nl: Nl; - archived_gm: ArchivedGm; + gm_collection: GmCollection; + vr_collection: VrCollection; archived_nl: ArchivedNl; + archived_gm: ArchivedGm; + archived_gm_collection: ArchivedGmCollection; }; export type ScopedRouterData = Omit; diff --git a/packages/common/src/types/data.ts b/packages/common/src/types/data.ts index 4f822b55ec..779a0b2648 100644 --- a/packages/common/src/types/data.ts +++ b/packages/common/src/types/data.ts @@ -11,7 +11,19 @@ export interface ArchivedGm { proto_name: ArchivedGmCode; name: ArchivedGmCode; code: ArchivedGmCode; + difference: ArchivedGmDifference; sewer_archived_20230623: GmSewer; + tested_overall_archived_20230331: GmTestedOverall; +} +export interface ArchivedGmDifference { + tested_overall__infected_moving_average_archived_20230331?: DifferenceDecimal; + tested_overall__infected_per_100k_moving_average_archived_20230331?: DifferenceDecimal; +} +export interface DifferenceDecimal { + old_value: number; + difference: number; + old_date_unix: number; + new_date_unix: number; } export interface GmSewer { values: GmSewerValue[]; @@ -27,6 +39,19 @@ export interface GmSewerValue { date_of_insertion_unix: number; data_is_outdated: boolean; } +export interface GmTestedOverall { + values: GmTestedOverallValue[]; + last_value: GmTestedOverallValue; +} +export interface GmTestedOverallValue { + date_unix: number; + infected: number; + infected_moving_average: number | null; + infected_moving_average_rounded: number | null; + infected_per_100k: number; + infected_per_100k_moving_average: number | null; + date_of_insertion_unix: number; +} export type ArchivedGmCollectionId = 'GM_COLLECTION'; @@ -36,6 +61,7 @@ export interface ArchivedGmCollection { name: ArchivedGmCollectionId; code: ArchivedGmCollectionId; sewer_archived_20230623: GmCollectionSewer[]; + tested_overall_archived_20230331: GmCollectionTestedOverall[]; } export interface GmCollectionSewer { date_start_unix: number; @@ -46,6 +72,13 @@ export interface GmCollectionSewer { date_of_insertion_unix: number; data_is_outdated: boolean; } +export interface GmCollectionTestedOverall { + date_unix: number; + gmcode: string; + infected_per_100k: number; + infected: number; + date_of_insertion_unix: number; +} export type ArchivedNlId = 'NL'; @@ -59,7 +92,11 @@ export interface ArchivedNl { behavior_annotations_archived_20230412: NlBehaviorAnnotations; behavior_per_age_group_archived_20230411: NlBehaviorPerAgeGroup; doctor_archived_20210903: NlDoctor; + g_number_archived_20220307: NlGNumber; nursing_home_archived_20230126: NlNursingHome; + tested_ggd_archived_20230321: NlTestedGgd; + tested_overall_archived_20230331: NlTestedOverall; + tested_per_age_group_archived_20230331: NlTestedPerAgeGroup; sewer_archived_20230623: NlSewer; vulnerable_nursing_home_archived_20230711: NlVulnerableNursingHome; vulnerable_hospital_admissions_archived_20230711: NlVulnerableHospitalAdmissions; @@ -67,10 +104,14 @@ export interface ArchivedNl { } export interface ArchivedNlDifference { nursing_home__deceased_daily_archived_20230126: DifferenceInteger; - vulnerable_nursing_home__infected_locations_total_archived_20230711: DifferenceInteger; nursing_home__newly_infected_people_archived_20230126: DifferenceInteger; - vulnerable_hospital_admissions_archived_20230711: DifferenceInteger; reproduction__index_average_archived_20230711: DifferenceDecimal; + tested_ggd__infected_percentage_moving_average_archived_20230321: DifferenceDecimal; + tested_ggd__tested_total_moving_average_archived_20230321: DifferenceDecimal; + tested_overall__infected_moving_average_archived_20230331: DifferenceDecimal; + tested_overall__infected_per_100k_moving_average_archived_20230331: DifferenceDecimal; + vulnerable_nursing_home__infected_locations_total_archived_20230711: DifferenceInteger; + vulnerable_hospital_admissions_archived_20230711: DifferenceInteger; } export interface DifferenceInteger { old_value: number; @@ -214,6 +255,15 @@ export interface NlDoctorValue { covid_symptoms: number; date_of_insertion_unix: number; } +export interface NlGNumber { + values: NlGNumberValue[]; + last_value: NlGNumberValue; +} +export interface NlGNumberValue { + g_number: number; + date_unix: number; + date_of_insertion_unix: number; +} export interface NlNursingHome { values: NlNursingHomeArchived_20230126Value[]; last_value: NlNursingHomeArchived_20230126Value; @@ -229,6 +279,53 @@ export interface NlNursingHomeArchived_20230126Value { date_unix: number; date_of_insertion_unix: number; } +export interface NlTestedGgd { + values: NlTestedGgdValue[]; + last_value: NlTestedGgdValue; +} +export interface NlTestedGgdValue { + infected: number; + infected_moving_average: number | null; + infected_percentage: number; + infected_percentage_moving_average: number | null; + tested_total: number; + tested_total_moving_average: number | null; + tested_total_moving_average_rounded: number | null; + date_unix: number; + date_of_insertion_unix: number; +} +export interface NlTestedOverall { + values: NlTestedOverallValue[]; + last_value: NlTestedOverallValue; +} +export interface NlTestedOverallValue { + infected: number; + infected_moving_average: number | null; + infected_moving_average_rounded: number | null; + infected_per_100k: number; + infected_per_100k_moving_average: number | null; + date_unix: number; + date_of_insertion_unix: number; +} +export interface NlTestedPerAgeGroup { + values: NlTestedPerAgeGroupValue[]; + last_value: NlTestedPerAgeGroupValue; +} +export interface NlTestedPerAgeGroupValue { + infected_age_0_9_per_100k: number; + infected_age_10_19_per_100k: number; + infected_age_20_29_per_100k: number; + infected_age_30_39_per_100k: number; + infected_age_40_49_per_100k: number; + infected_age_50_59_per_100k: number; + infected_age_60_69_per_100k: number; + infected_age_70_79_per_100k: number; + infected_age_80_89_per_100k: number; + infected_age_90_plus_per_100k: number; + infected_overall_per_100k: number; + date_unix: number; + date_of_insertion_unix: number; +} export interface NlSewer { values: NlSewerValue[]; last_value: NlSewerValue; @@ -287,7 +384,6 @@ export interface Gm { deceased_rivm_archived_20221231: GmDeceasedRivmArchived_20221231; difference: GmDifference; hospital_nice: GmHospitalNice; - tested_overall: GmTestedOverall; sewer: GmSewer; sewer_per_installation: GmSewerPerInstallation; sewer_installation_measurement: GmSewerInstallationMeasurement; @@ -312,8 +408,6 @@ export interface GmDeceasedRivmArchived_20221231Value { date_of_insertion_unix: number; } export interface GmDifference { - tested_overall__infected_per_100k_moving_average: DifferenceDecimal; - tested_overall__infected_moving_average: DifferenceDecimal; hospital_nice__admissions_on_date_of_reporting_moving_average: DifferenceDecimal; sewer__average?: DifferenceInteger; deceased_rivm__covid_daily_archived_20221231: DifferenceInteger; @@ -342,19 +436,6 @@ export interface GmHospitalNiceValue { admissions_on_date_of_reporting: number; date_of_insertion_unix: number; } -export interface GmTestedOverall { - values: GmTestedOverallValue[]; - last_value: GmTestedOverallValue; -} -export interface GmTestedOverallValue { - date_unix: number; - infected: number; - infected_moving_average: number | null; - infected_moving_average_rounded: number | null; - infected_per_100k: number; - infected_per_100k_moving_average: number | null; - date_of_insertion_unix: number; -} export interface GmSewer { values: GmSewerValue[]; last_value: GmSewerValue; @@ -452,7 +533,6 @@ export interface GmCollection { code: GmCollectionId; hospital_nice: GmCollectionHospitalNice[]; hospital_nice_choropleth: GmCollectionHospitalNice[]; - tested_overall: GmCollectionTestedOverall[]; sewer: GmCollectionSewer[]; vaccine_coverage_per_age_group: GmCollectionVaccineCoveragePerAgeGroup[]; } @@ -464,13 +544,6 @@ export interface GmCollectionHospitalNice { admissions_on_date_of_reporting: number; date_of_insertion_unix: number; } -export interface GmCollectionTestedOverall { - date_unix: number; - gmcode: string; - infected_per_100k: number; - infected: number; - date_of_insertion_unix: number; -} export interface GmCollectionSewer { date_start_unix: number; date_end_unix: number; @@ -507,18 +580,14 @@ export interface Nl { booster_shot_administered_archived_20220904: NlBoosterShotAdministeredArchived_20220904; repeating_shot_administered: NlRepeatingShotAdministered; booster_coverage_archived_20220904: NlBoosterCoverageArchived_20220904; - g_number: NlGNumber; infectious_people: NlInfectiousPeople; intensive_care_nice: NlIntensiveCareNice; intensive_care_nice_per_age_group: NlIntensiveCareNicePerAgeGroup; - tested_overall: NlTestedOverall; - tested_per_age_group: NlTestedPerAgeGroup; sewer: NlSewer; hospital_nice: NlHospitalNice; hospital_nice_per_age_group: NlHospitalNicePerAgeGroup; hospital_lcps: NlHospitalLcps; intensive_care_lcps: NlIntensiveCareLcps; - tested_ggd: NlTestedGgd; disability_care_archived_20230126: NlDisabilityCareArchived_20230126; deceased_rivm_archived_20221231: NlDeceasedRivmArchived_20221231; deceased_rivm_per_age_group_archived_20221231: NlDeceasedRivmPerAgeGroupArchived_20221231; @@ -551,10 +620,6 @@ export interface Nl { self_test_overall: NlSelfTestOverall; } export interface NlDifference { - tested_overall__infected_per_100k_moving_average: DifferenceDecimal; - tested_overall__infected_moving_average: DifferenceDecimal; - tested_ggd__tested_total_moving_average: DifferenceDecimal; - tested_ggd__infected_percentage_moving_average: DifferenceDecimal; infectious_people__estimate: DifferenceInteger; hospital_nice__admissions_on_date_of_reporting_moving_average: DifferenceDecimal; hospital_lcps__beds_occupied_covid: DifferenceInteger; @@ -565,13 +630,13 @@ export interface NlDifference { vulnerable_hospital_admissions?: DifferenceInteger; deceased_rivm__covid_daily_archived_20221231: DifferenceInteger; } -export interface DifferenceDecimal { +export interface DifferenceInteger { old_value: number; difference: number; old_date_unix: number; new_date_unix: number; } -export interface DifferenceInteger { +export interface DifferenceDecimal { old_value: number; difference: number; old_date_unix: number; @@ -616,15 +681,6 @@ export interface NlBoosterCoverageArchived_20220904Value { date_unix: number; date_of_insertion_unix: number; } -export interface NlGNumber { - values: NlGNumberValue[]; - last_value: NlGNumberValue; -} -export interface NlGNumberValue { - g_number: number; - date_unix: number; - date_of_insertion_unix: number; -} export interface NlInfectiousPeople { values: NlInfectiousPeopleValue[]; last_value: NlInfectiousPeopleValue; @@ -667,38 +723,6 @@ export interface NlIntensiveCareNicePerAgeGroupValue { date_end_unix: number; date_of_insertion_unix: number; } -export interface NlTestedOverall { - values: NlTestedOverallValue[]; - last_value: NlTestedOverallValue; -} -export interface NlTestedOverallValue { - infected: number; - infected_moving_average: number | null; - infected_moving_average_rounded: number | null; - infected_per_100k: number; - infected_per_100k_moving_average: number | null; - date_unix: number; - date_of_insertion_unix: number; -} -export interface NlTestedPerAgeGroup { - values: NlTestedPerAgeGroupValue[]; - last_value: NlTestedPerAgeGroupValue; -} -export interface NlTestedPerAgeGroupValue { - infected_age_0_9_per_100k: number; - infected_age_10_19_per_100k: number; - infected_age_20_29_per_100k: number; - infected_age_30_39_per_100k: number; - infected_age_40_49_per_100k: number; - infected_age_50_59_per_100k: number; - infected_age_60_69_per_100k: number; - infected_age_70_79_per_100k: number; - infected_age_80_89_per_100k: number; - infected_age_90_plus_per_100k: number; - infected_overall_per_100k: number; - date_unix: number; - date_of_insertion_unix: number; -} export interface NlSewer { values: NlSewerValue[]; last_value: NlSewerValue; @@ -762,21 +786,6 @@ export interface NlIntensiveCareLcpsValue { date_unix: number; date_of_insertion_unix: number; } -export interface NlTestedGgd { - values: NlTestedGgdValue[]; - last_value: NlTestedGgdValue; -} -export interface NlTestedGgdValue { - infected: number; - infected_moving_average: number | null; - infected_percentage: number; - infected_percentage_moving_average: number | null; - tested_total: number; - tested_total_moving_average: number | null; - tested_total_moving_average_rounded: number | null; - date_unix: number; - date_of_insertion_unix: number; -} export interface NlDisabilityCareArchived_20230126 { values: NlDisabilityCareArchived_20230126Value[]; last_value: NlDisabilityCareArchived_20230126Value; diff --git a/packages/common/src/types/feature-flags.ts b/packages/common/src/types/feature-flags.ts index 56610da58b..dfa6efb928 100644 --- a/packages/common/src/types/feature-flags.ts +++ b/packages/common/src/types/feature-flags.ts @@ -39,4 +39,4 @@ export type VerboseFeature = { metricProperties?: string[]; } & SimpleFeature; -export type JsonDataScope = DataScopeKey | 'vr_collection' | 'gm_collection' | 'archived_gm_collection'; +export type JsonDataScope = DataScopeKey;