MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / aggregateClaudeCodeStatsForRange

Function aggregateClaudeCodeStatsForRange

source code/utils/stats.ts:720–745  ·  view source on GitHub ↗
(
  range: StatsDateRange,
)

Source from the content-addressed store, hash-verified

718 * For 'all', uses the cached aggregation. For other ranges, processes files directly.
719 */
720export async function aggregateClaudeCodeStatsForRange(
721 range: StatsDateRange,
722): Promise<ClaudeCodeStats> {
723 if (range === 'all') {
724 return aggregateClaudeCodeStats()
725 }
726
727 const allSessionFiles = await getAllSessionFiles()
728 if (allSessionFiles.length === 0) {
729 return getEmptyStats()
730 }
731
732 // Calculate fromDate based on range
733 const today = new Date()
734 const daysBack = range === '7d' ? 7 : 30
735 const fromDate = new Date(today)
736 fromDate.setDate(today.getDate() - daysBack + 1) // +1 to include today
737 const fromDateStr = toDateString(fromDate)
738
739 // Process session files for the date range
740 const stats = await processSessionFiles(allSessionFiles, {
741 fromDate: fromDateStr,
742 })
743
744 return processedStatsToClaudeCodeStats(stats)
745}
746
747/**
748 * Convert ProcessedStats to ClaudeCodeStats.

Callers 2

StatsContentFunction · 0.85

Calls 6

aggregateClaudeCodeStatsFunction · 0.85
getAllSessionFilesFunction · 0.85
getEmptyStatsFunction · 0.85
toDateStringFunction · 0.85
processSessionFilesFunction · 0.85

Tested by

no test coverage detected