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

Commit

Permalink
refactor(COR-1865): Force undo changes from commit hook
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-van-eekelen committed Dec 20, 2023
1 parent 47e61a2 commit 22c0e25
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/app/src/utils/get-last-insertion-date-of-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ function hasLastValue(metric: any): boolean {
}

function hasValues(metric: any): boolean {
return Array.isArray(metric?.values) && typeof metric?.values[metric.values.length - 1]?.date_of_insertion_unix !== 'undefined';
return Array.isArray(metric?.values) &&
typeof metric?.values[metric.values.length - 1]?.date_of_insertion_unix !== 'undefined';
}

function hasInsertionDate(metric: any): boolean {
return typeof metric?.date_of_insertion_unix !== 'undefined';
}

function hasNestedLastValue(metric: any): boolean {
return Array.isArray(metric?.values) && typeof metric?.values[0]?.last_value?.date_of_insertion_unix !== 'undefined';
return Array.isArray(metric?.values) &&
typeof metric?.values[0]?.last_value?.date_of_insertion_unix !== 'undefined';
}

// functions for getting values
Expand All @@ -31,7 +33,7 @@ function getDateFromInsertionDate(metric: any): number {
}

function getDateFromNestedLastValue(metric: any): number {
return metric?.values.reduce((lastDate: number, innerValue: any) => {
return metric?.values.reduce((lastDate :number, innerValue: any) => {
const metricDate = getMetricDate(innerValue);
return Math.max(metricDate, lastDate);
}, 0);
Expand All @@ -53,7 +55,10 @@ function getMetricDate(metricOrUnixDate: any): number {
return 0;
}

export function getLastInsertionDateOfPage(data: unknown, pageMetrics: string[]) {
export function getLastInsertionDateOfPage(
data: unknown,
pageMetrics: string[]
) {
const metricsAvailableInData: string[] = pageMetrics.filter((metricProperty) => {
return typeof get(data, metricProperty) === 'number';
});
Expand All @@ -65,7 +70,6 @@ export function getLastInsertionDateOfPage(data: unknown, pageMetrics: string[])
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 22c0e25

Please sign in to comment.