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

Commit

Permalink
Merge pull request #4269 from minvws/release/2.48.3
Browse files Browse the repository at this point in the history
Release/2.48.3
  • Loading branch information
Jorrik-Klijnsma-Work authored May 30, 2022
2 parents 54bdb33 + 86a2f3a commit 8ecb650
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/app/src/utils/get-last-insertion-date-of-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@ export function getLastInsertionDateOfPage(
return pageMetrics.reduce((lastDate, metricProperty) => {
const metricOrUnixDate = get(data, metricProperty);

const metricDate =
typeof metricOrUnixDate === 'number'
? metricOrUnixDate
: metricOrUnixDate?.last_value?.date_of_insertion_unix || 0;
let metricDate: number;

if (typeof metricOrUnixDate === 'number') {
metricDate = metricOrUnixDate;
} else if (typeof metricOrUnixDate?.last_value?.date_of_insertion_unix !== 'undefined') {
metricDate = metricOrUnixDate?.last_value?.date_of_insertion_unix;
} else if (typeof metricOrUnixDate?.values !== 'undefined') {
metricDate = metricOrUnixDate?.values.reduce((max: number, value: any) => value.date_of_insertion_unix > max ? value.date_of_insertion_unix : max, 0);
} else {
metricDate = 0;
}

return metricDate > lastDate ? metricDate : lastDate;
}, 0);
Expand Down

0 comments on commit 8ecb650

Please sign in to comment.