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

Commit

Permalink
Fix/cor 610 incosistent dates on topical pages headers (#4213)
Browse files Browse the repository at this point in the history
* create hook for getting the last date of insertion

* Added hook to vaccinaties page

* Added all NL pages

* Added all VR pages

* Added to all GM pages

* Exclude difference data

* Improving the Hook
  • Loading branch information
Jorrik-Klijnsma-Work authored May 2, 2022
1 parent 86480b9 commit 76ef654
Show file tree
Hide file tree
Showing 27 changed files with 257 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ import {
} from '~/utils';
export { getStaticPaths } from '~/static-paths/gm';

import { getLastInsertionDateOfPage } from '~/utils/get-last-insertion-date-of-page';

const pageMetrics = [
'code',
'static_values.population_count',
'tested_overall',
];

export const getStaticProps = createGetStaticProps(
({ locale }: { locale: keyof Languages }) =>
getLokalizeTexts(
Expand Down Expand Up @@ -127,6 +135,8 @@ const PositivelyTestedPeople = (props: StaticProps<typeof getStaticProps>) => {
}),
};

const lastInsertionDateOfPage = getLastInsertionDateOfPage(data, pageMetrics);

return (
<Layout {...metadata} lastGenerated={lastGenerated}>
<GmLayout code={data.code} municipalityName={municipalityName}>
Expand All @@ -141,7 +151,7 @@ const PositivelyTestedPeople = (props: StaticProps<typeof getStaticProps>) => {
metadata={{
datumsText: textGm.datums,
dateOrRange: lastValue.date_unix,
dateOfInsertionUnix: lastValue.date_of_insertion_unix,
dateOfInsertionUnix: lastInsertionDateOfPage,
dataSources: [textGm.bronnen.rivm],
}}
referenceLink={textGm.reference.href}
Expand Down
14 changes: 12 additions & 2 deletions packages/app/src/pages/gemeente/[code]/rioolwater.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ import { ArticleParts, PagePartQueryResult } from '~/types/cms';
import { replaceComponentsInText } from '~/utils/replace-components-in-text';
import { replaceVariablesInText } from '~/utils/replace-variables-in-text';

import { getLastInsertionDateOfPage } from '~/utils/get-last-insertion-date-of-page';

const pageMetrics = [
'sewer_per_installation',
'static_values.population_count',
'sewer',
'code',
];

export { getStaticPaths } from '~/static-paths/gm';

export const getStaticProps = createGetStaticProps(
Expand Down Expand Up @@ -100,6 +109,8 @@ const SewerWater = (props: StaticProps<typeof getStaticProps>) => {
}),
};

const lastInsertionDateOfPage = getLastInsertionDateOfPage(data, pageMetrics);

return (
<Layout {...metadata} lastGenerated={lastGenerated}>
<GmLayout code={data.code} municipalityName={municipalityName}>
Expand All @@ -117,8 +128,7 @@ const SewerWater = (props: StaticProps<typeof getStaticProps>) => {
start: sewerAverages.last_value.date_start_unix,
end: sewerAverages.last_value.date_end_unix,
},
dateOfInsertionUnix:
sewerAverages.last_value.date_of_insertion_unix,
dateOfInsertionUnix: lastInsertionDateOfPage,
dataSources: [textGm.bronnen.rivm],
}}
referenceLink={textGm.reference.href}
Expand Down
9 changes: 7 additions & 2 deletions packages/app/src/pages/gemeente/[code]/sterfte.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ import {
import { ArticleParts, PagePartQueryResult } from '~/types/cms';
import { replaceVariablesInText } from '~/utils';

import { getLastInsertionDateOfPage } from '~/utils/get-last-insertion-date-of-page';

const pageMetrics = ['deceased_rivm', 'code'];

export { getStaticPaths } from '~/static-paths/gm';

export const getStaticProps = createGetStaticProps(
Expand Down Expand Up @@ -97,6 +101,8 @@ const DeceasedMunicipalPage = (props: StaticProps<typeof getStaticProps>) => {
}),
};

const lastInsertionDateOfPage = getLastInsertionDateOfPage(data, pageMetrics);

return (
<Layout {...metadata} lastGenerated={lastGenerated}>
<GmLayout code={data.code} municipalityName={municipalityName}>
Expand All @@ -112,8 +118,7 @@ const DeceasedMunicipalPage = (props: StaticProps<typeof getStaticProps>) => {
metadata={{
datumsText: textGm.section_deceased_rivm.datums,
dateOrRange: data.deceased_rivm.last_value.date_unix,
dateOfInsertionUnix:
data.deceased_rivm.last_value.date_of_insertion_unix,
dateOfInsertionUnix: lastInsertionDateOfPage,
dataSources: [textGm.section_deceased_rivm.bronnen.rivm],
}}
articles={content.articles}
Expand Down
13 changes: 11 additions & 2 deletions packages/app/src/pages/gemeente/[code]/vaccinaties.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ import {
useFormatLokalizePercentage,
} from '~/utils';

import { getLastInsertionDateOfPage } from '~/utils/get-last-insertion-date-of-page';

const pageMetrics = [
'code',
'vaccine_coverage_per_age_group',
'booster_coverage',
];

export { getStaticPaths } from '~/static-paths/gm';

export const getStaticProps = createGetStaticProps(
Expand Down Expand Up @@ -161,6 +169,8 @@ export const VaccinationsGmPage = (
`[${VaccinationsGmPage.name}] Could not find data for the vaccine coverage per age group for the age 12+`
);

const lastInsertionDateOfPage = getLastInsertionDateOfPage(data, pageMetrics);

return (
<Layout {...metadata} lastGenerated={lastGenerated}>
<GmLayout code={data.code} municipalityName={municipalityName}>
Expand All @@ -175,8 +185,7 @@ export const VaccinationsGmPage = (
metadata={{
datumsText: textGm.informatie_blok.datums,
dateOrRange: filteredAgeGroup18Plus.date_unix,
dateOfInsertionUnix:
filteredAgeGroup18Plus.date_of_insertion_unix,
dateOfInsertionUnix: lastInsertionDateOfPage,
dataSources: [],
}}
pageLinks={content.links}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ import {
useReverseRouter,
} from '~/utils';

import { getLastInsertionDateOfPage } from '~/utils/get-last-insertion-date-of-page';

const pageMetrics = ['hospital_nice', 'code'];

export { getStaticPaths } from '~/static-paths/gm';

export const getStaticProps = createGetStaticProps(
Expand Down Expand Up @@ -132,6 +136,8 @@ const IntakeHospital = (props: StaticProps<typeof getStaticProps>) => {
}),
};

const lastInsertionDateOfPage = getLastInsertionDateOfPage(data, pageMetrics);

return (
<Layout {...metadata} lastGenerated={lastGenerated}>
<GmLayout code={data.code} municipalityName={municipalityName}>
Expand All @@ -146,7 +152,7 @@ const IntakeHospital = (props: StaticProps<typeof getStaticProps>) => {
metadata={{
datumsText: textGm.datums,
dateOrRange: lastValue.date_unix,
dateOfInsertionUnix: lastValue.date_of_insertion_unix,
dateOfInsertionUnix: lastInsertionDateOfPage,
dataSources: [textGm.bronnen.rivm],
}}
referenceLink={textGm.reference.href}
Expand Down
11 changes: 10 additions & 1 deletion packages/app/src/pages/landelijk/gedrag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ import {
} from '~/static-props/get-data';
import { ArticleParts, PagePartQueryResult } from '~/types/cms';
import { replaceVariablesInText } from '~/utils/replace-variables-in-text';
import { getLastInsertionDateOfPage } from '~/utils/get-last-insertion-date-of-page';

const pageMetrics = [
'behavior',
'behavior_annotations',
'behavior_per_age_group',
];

export const getStaticProps = createGetStaticProps(
({ locale }: { locale: keyof Languages }) =>
Expand Down Expand Up @@ -130,6 +137,8 @@ export default function BehaviorPage(
? { timelineEvents: currentTimelineEvents }
: undefined;

const lastInsertionDateOfPage = getLastInsertionDateOfPage(data, pageMetrics);

return (
<Layout {...metadata} lastGenerated={lastGenerated}>
<NlLayout>
Expand All @@ -145,7 +154,7 @@ export default function BehaviorPage(
start: behaviorLastValue.date_start_unix,
end: behaviorLastValue.date_end_unix,
},
dateOfInsertionUnix: behaviorLastValue.date_of_insertion_unix,
dateOfInsertionUnix: lastInsertionDateOfPage,
dataSources: [text.nl.bronnen.rivm],
}}
referenceLink={text.nl.reference.href}
Expand Down
7 changes: 6 additions & 1 deletion packages/app/src/pages/landelijk/gehandicaptenzorg.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ import {
import { ArticleParts, PagePartQueryResult } from '~/types/cms';
import { getBoundaryDateStartUnix } from '~/utils/get-boundary-date-start-unix';
import { useReverseRouter } from '~/utils/use-reverse-router';
import { getLastInsertionDateOfPage } from '~/utils/get-last-insertion-date-of-page';

const pageMetrics = ['disability_care'];

export const getStaticProps = createGetStaticProps(
({ locale }: { locale: keyof Languages }) =>
Expand Down Expand Up @@ -114,6 +117,8 @@ const DisabilityCare = (props: StaticProps<typeof getStaticProps>) => {
description: textNl.besmette_locaties.metadata.description,
};

const lastInsertionDateOfPage = getLastInsertionDateOfPage(data, pageMetrics);

return (
<Layout {...metadata} lastGenerated={lastGenerated}>
<NlLayout>
Expand All @@ -127,7 +132,7 @@ const DisabilityCare = (props: StaticProps<typeof getStaticProps>) => {
metadata={{
datumsText: textNl.positief_geteste_personen.datums,
dateOrRange: lastValue.date_unix,
dateOfInsertionUnix: lastValue.date_of_insertion_unix,
dateOfInsertionUnix: lastInsertionDateOfPage,
dataSources: [textNl.positief_geteste_personen.bronnen.rivm],
}}
referenceLink={textNl.positief_geteste_personen.reference.href}
Expand Down
13 changes: 12 additions & 1 deletion packages/app/src/pages/landelijk/intensive-care-opnames.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import {
getBoundaryDateStartUnix,
replaceVariablesInText,
} from '~/utils';
import { getLastInsertionDateOfPage } from '~/utils/get-last-insertion-date-of-page';

const AgeDemographic = dynamic<
AgeDemographicProps<NlHospitalVaccineIncidencePerAgeGroupValue>
Expand All @@ -67,6 +68,14 @@ const PieChart = dynamic<PieChartProps<NlIntensiveCareVaccinationStatusValue>>(
() => import('~/components/pie-chart').then((mod) => mod.PieChart)
);

const pageMetrics = [
'intensive_care_lcps',
'intensive_care_nice',
'intensive_care_nice_per_age_group',
'intensive_care_vaccination_status',
'hospital_vaccine_incidence_per_age_group',
];

export const getStaticProps = createGetStaticProps(
({ locale }: { locale: keyof Languages }) =>
getLokalizeTexts(
Expand Down Expand Up @@ -153,6 +162,8 @@ const IntakeIntensiveCare = (props: StaticProps<typeof getStaticProps>) => {
description: textNl.metadata.description,
};

const lastInsertionDateOfPage = getLastInsertionDateOfPage(data, pageMetrics);

return (
<Layout {...metadata} lastGenerated={lastGenerated}>
<NlLayout>
Expand All @@ -168,7 +179,7 @@ const IntakeIntensiveCare = (props: StaticProps<typeof getStaticProps>) => {
metadata={{
datumsText: textNl.datums,
dateOrRange: dataIntake.last_value.date_unix,
dateOfInsertionUnix: dataIntake.last_value.date_of_insertion_unix,
dateOfInsertionUnix: lastInsertionDateOfPage,
dataSources: [textNl.bronnen.nice, textNl.bronnen.lnaz],
}}
referenceLink={textNl.reference.href}
Expand Down
13 changes: 12 additions & 1 deletion packages/app/src/pages/landelijk/positief-geteste-mensen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ import {
} from '~/static-props/get-data';
import { ArticleParts, PagePartQueryResult } from '~/types/cms';
import { replaceComponentsInText, useReverseRouter } from '~/utils';
import { getLastInsertionDateOfPage } from '~/utils/get-last-insertion-date-of-page';

const pageMetrics = [
'g_number',
'tested_ggd',
'tested_ggd_archived',
'tested_overall',
'tested_per_age_group',
];

export const getStaticProps = createGetStaticProps(
({ locale }: { locale: keyof Languages }) =>
Expand Down Expand Up @@ -136,6 +145,8 @@ const PositivelyTestedPeople = (props: StaticProps<typeof getStaticProps>) => {
description: textNl.metadata.description,
};

const lastInsertionDateOfPage = getLastInsertionDateOfPage(data, pageMetrics);

return (
<Layout {...metadata} lastGenerated={lastGenerated}>
<NlLayout>
Expand All @@ -151,7 +162,7 @@ const PositivelyTestedPeople = (props: StaticProps<typeof getStaticProps>) => {
metadata={{
datumsText: textNl.datums,
dateOrRange: dataOverallLastValue.date_unix,
dateOfInsertionUnix: dataOverallLastValue.date_of_insertion_unix,
dateOfInsertionUnix: lastInsertionDateOfPage,
dataSources: [textNl.bronnen.rivm],
}}
referenceLink={textNl.reference.href}
Expand Down
7 changes: 6 additions & 1 deletion packages/app/src/pages/landelijk/reproductiegetal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ import {
selectNlData,
} from '~/static-props/get-data';
import { ArticleParts, PagePartQueryResult } from '~/types/cms';
import { getLastInsertionDateOfPage } from '~/utils/get-last-insertion-date-of-page';

const pageMetrics = ['reproduction'];

export const getStaticProps = createGetStaticProps(
({ locale }: { locale: keyof Languages }) =>
Expand Down Expand Up @@ -82,6 +85,8 @@ const ReproductionIndex = (props: StaticProps<typeof getStaticProps>) => {
description: textNl.metadata.description,
};

const lastInsertionDateOfPage = getLastInsertionDateOfPage(data, pageMetrics);

return (
<Layout {...metadata} lastGenerated={lastGenerated}>
<NlLayout>
Expand All @@ -97,7 +102,7 @@ const ReproductionIndex = (props: StaticProps<typeof getStaticProps>) => {
metadata={{
datumsText: textNl.datums,
dateOrRange: lastFilledValue.date_unix,
dateOfInsertionUnix: lastFilledValue.date_of_insertion_unix,
dateOfInsertionUnix: lastInsertionDateOfPage,
dataSources: [textNl.bronnen.rivm],
}}
referenceLink={textNl.reference.href}
Expand Down
8 changes: 6 additions & 2 deletions packages/app/src/pages/landelijk/rioolwater.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ import {
} from '~/static-props/get-data';
import { ArticleParts, PagePartQueryResult } from '~/types/cms';
import { useReverseRouter } from '~/utils/use-reverse-router';
import { getLastInsertionDateOfPage } from '~/utils/get-last-insertion-date-of-page';

const pageMetrics = ['sewer'];

export const getStaticProps = createGetStaticProps(
({ locale }: { locale: keyof Languages }) =>
Expand Down Expand Up @@ -90,6 +93,8 @@ const SewerWater = (props: StaticProps<typeof getStaticProps>) => {
description: textNl.metadata.description,
};

const lastInsertionDateOfPage = getLastInsertionDateOfPage(data, pageMetrics);

return (
<Layout {...metadata} lastGenerated={lastGenerated}>
<NlLayout>
Expand All @@ -103,8 +108,7 @@ const SewerWater = (props: StaticProps<typeof getStaticProps>) => {
metadata={{
datumsText: textNl.datums,
dateOrRange: sewerAverages.last_value.date_unix,
dateOfInsertionUnix:
sewerAverages.last_value.date_of_insertion_unix,
dateOfInsertionUnix: lastInsertionDateOfPage,
dataSources: [textNl.bronnen.rivm],
}}
referenceLink={textNl.reference.href}
Expand Down
11 changes: 10 additions & 1 deletion packages/app/src/pages/landelijk/sterfte.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ import {
selectNlData,
} from '~/static-props/get-data';
import { ArticleParts, PagePartQueryResult } from '~/types/cms';
import { getLastInsertionDateOfPage } from '~/utils/get-last-insertion-date-of-page';

const pageMetrics = [
'deceased_cbs',
'deceased_rivm_per_age_group',
'deceased_rivm',
];

export const getStaticProps = createGetStaticProps(
({ locale }: { locale: keyof Languages }) =>
Expand Down Expand Up @@ -99,6 +106,8 @@ const DeceasedNationalPage = (props: StaticProps<typeof getStaticProps>) => {
description: textNl.metadata.description,
};

const lastInsertionDateOfPage = getLastInsertionDateOfPage(data, pageMetrics);

return (
<Layout {...metadata} lastGenerated={lastGenerated}>
<NlLayout>
Expand All @@ -112,7 +121,7 @@ const DeceasedNationalPage = (props: StaticProps<typeof getStaticProps>) => {
metadata={{
datumsText: textNl.section_deceased_rivm.datums,
dateOrRange: dataRivm.last_value.date_unix,
dateOfInsertionUnix: dataRivm.last_value.date_of_insertion_unix,
dateOfInsertionUnix: lastInsertionDateOfPage,
dataSources: [textNl.section_deceased_rivm.bronnen.rivm],
}}
articles={content.mainArticles}
Expand Down
Loading

0 comments on commit 76ef654

Please sign in to comment.