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

Commit

Permalink
Merge branch 'master' into feature/COR-1866-sync-master-to-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
yorickdevries committed Jan 8, 2024
2 parents cc8437d + ec750f1 commit b1d9e6f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface VariantsStackedAreaTileProps {
}

export const VariantsStackedAreaTile = ({ text, values, variantColors, metadata }: VariantsStackedAreaTileProps) => {
const [variantTimeframe, setVariantTimeframe] = useState<TimeframeOption>(TimeframeOption.THREE_MONTHS);
const [variantStackedAreaTimeframe, setVariantStackedAreaTimeframe] = useState<TimeframeOption>(TimeframeOption.ALL);

const { list, toggle, clear } = useList<keyof VariantChartValue>(alwaysEnabled);

Expand Down Expand Up @@ -54,8 +54,8 @@ export const VariantsStackedAreaTile = ({ text, values, variantColors, metadata
description={text.toelichting}
metadata={metadata}
timeframeOptions={TimeframeOptionsList}
timeframeInitialValue={TimeframeOption.THREE_MONTHS}
onSelectTimeframe={setVariantTimeframe}
timeframeInitialValue={variantStackedAreaTimeframe}
onSelectTimeframe={setVariantStackedAreaTimeframe}
>
<InteractiveLegend helpText={text.legend_help_tekst} selectOptions={selectOptions} selection={list} onToggleItem={toggle} onReset={clear} />
<Spacer marginBottom={space[2]} />
Expand All @@ -64,7 +64,7 @@ export const VariantsStackedAreaTile = ({ text, values, variantColors, metadata
key: 'variants_stacked_area_over_time_chart',
}}
values={values}
timeframe={variantTimeframe}
timeframe={variantStackedAreaTimeframe}
seriesConfig={filteredConfig}
disableLegend
dataOptions={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const getStaticProps = createGetStaticProps(

function PositivelyTestedPeople(props: StaticProps<typeof getStaticProps>) {
const { pageText, selectedGmData: data, selectedArchivedGmData: archivedData, archivedChoropleth, municipalityName, content, lastGenerated } = props;
const [positivelyTestedPeopleTimeframe, setpositivelyTestedPeopleTimeframe] = useState<TimeframeOption>(TimeframeOption.SIX_MONTHS);
const [positivelyTestedPeopleTimeframe, setpositivelyTestedPeopleTimeframe] = useState<TimeframeOption>(TimeframeOption.ALL);
const { commonTexts, formatNumber, formatDateFromSeconds } = useIntl();
const reverseRouter = useReverseRouter();
const { textGm, textShared } = useDynamicLokalizeTexts<LokalizeTexts>(pageText, selectLokalizeTexts);
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/pages/landelijk/positieve-testen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const getStaticProps = createGetStaticProps(
function PositivelyTestedPeople(props: StaticProps<typeof getStaticProps>) {
const { pageText, selectedArchivedNlData: data, archivedChoropleth, content, lastGenerated } = props;

const [confirmedCasesInfectedTimeframe, setConfirmedCasesInfectedTimeframe] = useState<TimeframeOption>(TimeframeOption.SIX_MONTHS);
const [confirmedCasesInfectedTimeframe, setConfirmedCasesInfectedTimeframe] = useState<TimeframeOption>(TimeframeOption.ALL);

const [confirmedCasesInfectedPercentageTimeframe, setConfirmedCasesInfectedPercentageTimeframe] = useState<TimeframeOption>(TimeframeOption.ALL);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ import { getLastInsertionDateOfPage } from '../get-last-insertion-date-of-page';

const GetLastDateOfInsertion = suite('getLastInsertionDateOfPage');

GetLastDateOfInsertion('returns zero when data is empty', () => {
const result = getLastInsertionDateOfPage({}, ['key1']);
assert.is(result, 0);
GetLastDateOfInsertion('returns error when data is empty', () => {
assert.throws(() => getLastInsertionDateOfPage({}, ['key1']), /Pagemetrics not found in data/)
});

GetLastDateOfInsertion('returns zero when metrics are empty', () => {
const result = getLastInsertionDateOfPage(
{ key1: { last_value: { date_of_insertion_unix: 123 } } },
[]
);
assert.is(result, 0);
GetLastDateOfInsertion('returns error when metrics are empty', () => {
assert.throws(() => getLastInsertionDateOfPage(
{ key1: { last_value: { date_of_insertion_unix: 123 } } },
[]
), /Pagemetrics not found in data/);
});

GetLastDateOfInsertion('returns the max date_of_insertion_unix', () => {
Expand Down
12 changes: 10 additions & 2 deletions packages/app/src/utils/get-last-insertion-date-of-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,18 @@ export function getLastInsertionDateOfPage(
data: unknown,
pageMetrics: string[]
) {
return pageMetrics.reduce((lastDate, metricProperty) => {
const metricsAvailableInData: string[] = pageMetrics.filter((metricProperty) => {
return typeof get(data, metricProperty) !== 'undefined';
});

if (metricsAvailableInData.length === 0) {
throw new Error(`Pagemetrics not found in data`);
}

return metricsAvailableInData.reduce((lastDate, metricProperty) => {
const metric: any = get(data, metricProperty);
const metricDate = getMetricDate(metric);

return Math.max(metricDate, lastDate);
}, 0);
};

0 comments on commit b1d9e6f

Please sign in to comment.