From e0850218b430eb7d9a2629b96a0321c73eb02b50 Mon Sep 17 00:00:00 2001 From: AT <93994194+VWSCoronaDashboard21@users.noreply.github.com> Date: Wed, 12 Jul 2023 15:22:39 +0200 Subject: [PATCH] feature/COR-1684-archive-reproduction-number (#4809) * feat(reproduction number): archive page * feat(Reproduction number): archive page * feat(reproduction number): schema changes * fix(reproduction number): fix cms keys * fix: remove timeline --------- Co-authored-by: VWSCoronaDashboard21 --- .../app/schema/archived_nl/__difference.json | 54 +++++++++++++++++++ packages/app/schema/archived_nl/__index.json | 10 +++- .../{nl => archived_nl}/reproduction.json | 8 +-- packages/app/schema/nl/__difference.json | 4 -- packages/app/schema/nl/__index.json | 4 -- packages/app/src/domain/layout/nl-layout.tsx | 7 ++- .../src/pages/landelijk/reproductiegetal.tsx | 34 +++++++----- .../src/elements/schemas/shared/index.ts | 2 +- packages/cms/src/lokalize/key-mutations.csv | 1 + packages/cms/src/studio/constants.ts | 2 +- packages/common/src/types/data.ts | 35 +++++++----- 11 files changed, 114 insertions(+), 47 deletions(-) create mode 100644 packages/app/schema/archived_nl/__difference.json rename packages/app/schema/{nl => archived_nl}/reproduction.json (87%) diff --git a/packages/app/schema/archived_nl/__difference.json b/packages/app/schema/archived_nl/__difference.json new file mode 100644 index 0000000000..8e8453ba51 --- /dev/null +++ b/packages/app/schema/archived_nl/__difference.json @@ -0,0 +1,54 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "archived_nl_difference", + "type": "object", + "properties": { + "reproduction__index_average_archived_20230711": { + "$ref": "#/definitions/diff_decimal" + } + }, + "required": ["reproduction__index_average_archived_20230711"], + "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_nl/__index.json b/packages/app/schema/archived_nl/__index.json index 0a0b5011bf..ec47154966 100644 --- a/packages/app/schema/archived_nl/__index.json +++ b/packages/app/schema/archived_nl/__index.json @@ -7,11 +7,13 @@ "proto_name", "name", "code", + "difference", "behavior_archived_20230411", "behavior_annotations_archived_20230412", "behavior_per_age_group_archived_20230411", "doctor_archived_20210903", - "sewer_archived_20230623" + "sewer_archived_20230623", + "reproduction_archived_20230711" ], "additionalProperties": false, "properties": { @@ -27,6 +29,9 @@ "code": { "$ref": "#/$defs/archived_nl_id" }, + "difference": { + "$ref": "__difference.json" + }, "behavior_archived_20230411": { "$ref": "behavior/behavior.json" }, @@ -41,6 +46,9 @@ }, "sewer_archived_20230623": { "$ref": "sewer.json" + }, + "reproduction_archived_20230711": { + "$ref": "reproduction.json" } }, "$defs": { diff --git a/packages/app/schema/nl/reproduction.json b/packages/app/schema/archived_nl/reproduction.json similarity index 87% rename from packages/app/schema/nl/reproduction.json rename to packages/app/schema/archived_nl/reproduction.json index ea0dfa07d2..713c129c28 100644 --- a/packages/app/schema/nl/reproduction.json +++ b/packages/app/schema/archived_nl/reproduction.json @@ -4,13 +4,7 @@ "title": "nl_reproduction_value", "type": "object", "additionalProperties": false, - "required": [ - "index_low", - "index_average", - "index_high", - "date_unix", - "date_of_insertion_unix" - ], + "required": ["index_low", "index_average", "index_high", "date_unix", "date_of_insertion_unix"], "properties": { "index_low": { "type": ["number", "null"], diff --git a/packages/app/schema/nl/__difference.json b/packages/app/schema/nl/__difference.json index bb9e115e1c..14379afd24 100644 --- a/packages/app/schema/nl/__difference.json +++ b/packages/app/schema/nl/__difference.json @@ -48,9 +48,6 @@ "vulnerable_hospital_admissions": { "$ref": "#/definitions/diff_integer" }, - "reproduction__index_average": { - "$ref": "#/definitions/diff_decimal" - }, "deceased_rivm__covid_daily_archived_20221231": { "$ref": "#/definitions/diff_integer" } @@ -62,7 +59,6 @@ "hospital_lcps__beds_occupied_covid", "tested_ggd__tested_total_moving_average", "tested_ggd__infected_percentage_moving_average", - "reproduction__index_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 14cc6c2252..6c5287daf3 100644 --- a/packages/app/schema/nl/__index.json +++ b/packages/app/schema/nl/__index.json @@ -31,7 +31,6 @@ "vulnerable_tested_per_age_group", "vulnerable_hospital_admissions", "proto_name", - "reproduction", "self_test_overall", "sewer", "tested_ggd", @@ -107,9 +106,6 @@ "tested_per_age_group": { "$ref": "tested_per_age_group.json" }, - "reproduction": { - "$ref": "reproduction.json" - }, "sewer": { "$ref": "sewer.json" }, diff --git a/packages/app/src/domain/layout/nl-layout.tsx b/packages/app/src/domain/layout/nl-layout.tsx index cc4327e385..5035e0b612 100644 --- a/packages/app/src/domain/layout/nl-layout.tsx +++ b/packages/app/src/domain/layout/nl-layout.tsx @@ -37,10 +37,13 @@ export function NlLayout(props: NlLayoutProps) { const items = useSidebar({ layout: 'nl', map: [ - ['development_of_the_virus', ['sewage_measurement', 'tests', 'reproduction_number', 'variants', 'mortality']], + ['development_of_the_virus', ['sewage_measurement', 'tests', 'variants', 'mortality']], ['consequences_for_healthcare', ['hospitals_and_care', 'patients', 'nursing_home_care']], ['actions_to_take', ['vaccinations']], - ['archived_metrics', ['compliance', 'positive_tests', 'disabled_care', 'elderly_at_home', 'coronamelder_app', 'infectious_people', 'general_practitioner_suspicions']], + [ + 'archived_metrics', + ['reproduction_number', 'compliance', 'positive_tests', 'disabled_care', 'elderly_at_home', 'coronamelder_app', 'infectious_people', 'general_practitioner_suspicions'], + ], ], }); diff --git a/packages/app/src/pages/landelijk/reproductiegetal.tsx b/packages/app/src/pages/landelijk/reproductiegetal.tsx index 1d89c6f1e0..2912e499e2 100644 --- a/packages/app/src/pages/landelijk/reproductiegetal.tsx +++ b/packages/app/src/pages/landelijk/reproductiegetal.tsx @@ -10,21 +10,22 @@ import { PageInformationBlock } from '~/components/page-information-block'; import { PageKpi } from '~/components/page-kpi'; import { TileList } from '~/components/tile-list'; import { TwoKpiSection } from '~/components/two-kpi-section'; +import { WarningTile } from '~/components/warning-tile'; import { Layout } from '~/domain/layout/layout'; import { NlLayout } from '~/domain/layout/nl-layout'; import { ReproductionChartTile } from '~/domain/tested/reproduction-chart-tile'; import { useIntl } from '~/intl'; import { Languages, SiteText } from '~/locale'; -import { ElementsQueryResult, getElementsQuery, getTimelineEvents } from '~/queries/get-elements-query'; +import { ElementsQueryResult, getElementsQuery } from '~/queries/get-elements-query'; import { getArticleParts, getDataExplainedParts, getFaqParts, getPagePartsQuery } from '~/queries/get-page-parts-query'; import { StaticProps, createGetStaticProps } 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 { getLastInsertionDateOfPage } from '~/utils/get-last-insertion-date-of-page'; import { getPageInformationHeaderContent } from '~/utils/get-page-information-header-content'; -const pageMetrics = ['reproduction']; +const pageMetrics = ['reproduction_archived_20230711']; const selectLokalizeTexts = (siteText: SiteText) => ({ metadataTexts: siteText.pages.topical_page.nl.nationaal_metadata, @@ -36,7 +37,7 @@ type LokalizeTexts = ReturnType; export const getStaticProps = createGetStaticProps( ({ locale }: { locale: keyof Languages }) => getLokalizeTexts(selectLokalizeTexts, locale), getLastGeneratedDate, - selectNlData('reproduction', 'difference.reproduction__index_average'), + selectArchivedNlData('reproduction_archived_20230711', 'difference.reproduction__index_average_archived_20230711'), async (context: GetStaticPropsContext) => { const { content } = await createGetContent<{ parts: PagePartQueryResult; @@ -45,7 +46,7 @@ export const getStaticProps = createGetStaticProps( const { locale } = context; return `{ "parts": ${getPagePartsQuery('reproduction_page')}, - "elements": ${getElementsQuery('nl', ['reproduction'], locale)} + "elements": ${getElementsQuery('nl', ['reproduction_archived_20230711'], locale)} }`; })(context); @@ -61,9 +62,10 @@ export const getStaticProps = createGetStaticProps( ); const ReproductionIndex = (props: StaticProps) => { - const { pageText, selectedNlData: data, content, lastGenerated } = props; + const { pageText, selectedArchivedNlData: data, content, lastGenerated } = props; - const lastFilledValue = getLastFilledValue(data.reproduction); + const reproductionLastValue = getLastFilledValue(data.reproduction_archived_20230711); + const reproductionValues = data.reproduction_archived_20230711; const { commonTexts } = useIntl(); const { metadataTexts, textNl } = useDynamicLokalizeTexts(pageText, selectLokalizeTexts); @@ -76,19 +78,21 @@ const ReproductionIndex = (props: StaticProps) => { const lastInsertionDateOfPage = getLastInsertionDateOfPage(data, pageMetrics); + const hasActiveWarningTile = !!textNl.belangrijk_bericht; + return (