Restore photobooth uploader files after sync
This commit is contained in:
28
resources/js/admin/mobile/lib/analytics.ts
Normal file
28
resources/js/admin/mobile/lib/analytics.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
export function resolveMaxCount(values: number[]): number {
|
||||
if (!Array.isArray(values) || values.length === 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return Math.max(...values, 1);
|
||||
}
|
||||
|
||||
export function resolveTimelineHours(timestamps: string[], fallbackHours = 12): number {
|
||||
if (!Array.isArray(timestamps) || timestamps.length < 2) {
|
||||
return fallbackHours;
|
||||
}
|
||||
|
||||
const times = timestamps
|
||||
.map((value) => new Date(value).getTime())
|
||||
.filter((value) => Number.isFinite(value));
|
||||
|
||||
if (times.length < 2) {
|
||||
return fallbackHours;
|
||||
}
|
||||
|
||||
const min = Math.min(...times);
|
||||
const max = Math.max(...times);
|
||||
const diff = Math.max(0, max - min);
|
||||
const hours = diff / (1000 * 60 * 60);
|
||||
|
||||
return Math.max(1, Math.round(hours));
|
||||
}
|
||||
Reference in New Issue
Block a user