export type ProgressTimestamp = number | { timestamp: number } | null; export const getCalendar = ( progressTimestamps: ProgressTimestamp[] | null ): Record => { const calendar: Record = {}; progressTimestamps?.forEach(progress => { if (progress === null) return; if (typeof progress === 'number') { calendar[Math.floor(progress / 1000)] = 1; } else { calendar[Math.floor(progress.timestamp / 1000)] = 1; } }); return calendar; }; export const getPoints = ( progressTimestamps: ProgressTimestamp[] | null ): number => { return progressTimestamps?.length ?? 1; };