* Creates a stats loading promise that never rejects. * Always loads all-time stats for the heatmap.
()
| 68 | * Always loads all-time stats for the heatmap. |
| 69 | */ |
| 70 | function createAllTimeStatsPromise(): Promise<StatsResult> { |
| 71 | return aggregateClaudeCodeStatsForRange('all') |
| 72 | .then((data): StatsResult => { |
| 73 | if (!data || data.totalSessions === 0) { |
| 74 | return { type: 'empty' }; |
| 75 | } |
| 76 | return { type: 'success', data }; |
| 77 | }) |
| 78 | .catch((err): StatsResult => { |
| 79 | const message = err instanceof Error ? err.message : 'Failed to load stats'; |
| 80 | return { type: 'error', message }; |
| 81 | }); |
| 82 | } |
| 83 | |
| 84 | export function Stats({ onClose }: Props): React.ReactNode { |
| 85 | // Always load all-time stats first (for heatmap) |
no test coverage detected