MCPcopy
hub / github.com/codeaashu/claude-code / aggregateClaudeCodeStatsForRange

Function aggregateClaudeCodeStatsForRange

src/utils/stats.ts:718–743  ·  view source on GitHub ↗
(
  range: StatsDateRange,
)

Source from the content-addressed store, hash-verified

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