MCPcopy Create free account
hub / github.com/arctic-cli/interface / displayStats

Function displayStats

packages/arctic/src/cli/cmd/stats.ts:163–224  ·  view source on GitHub ↗
(stats: SessionStats, view: "all" | "overview" | "models" | "cost", dateFilter?: DateFilter)

Source from the content-addressed store, hash-verified

161}
162
163function displayStats(stats: SessionStats, view: "all" | "overview" | "models" | "cost", dateFilter?: DateFilter) {
164 const daysToShow = calculateDaysToShow(stats)
165 const favoriteModel = getFavoriteModel(stats)
166 const tokenComparison = getTokenComparison(stats)
167
168 console.log()
169
170 if (dateFilter) {
171 console.log(`${colors.bold}Showing stats for: ${colors.primary}${dateFilter.label}${colors.reset}`)
172 console.log()
173 }
174
175 if (view === "all" || view === "overview") {
176 if (!dateFilter) {
177 renderActivityHeatmap(stats.dailyActivity, daysToShow)
178 console.log()
179 }
180
181 // favorite model and total tokens row
182 const favModelText = `${colors.bold}Favorite model:${colors.reset} ${colors.primary}${favoriteModel ?? "N/A"}${colors.reset}`
183 const totalTokensText = `${colors.bold}Total tokens:${colors.reset} ${colors.primary}${formatNumber(stats.totalTokens)}${colors.reset}`
184 console.log(`${favModelText} ${totalTokensText}`)
185 console.log()
186
187 // two column stats
188 const col1 = [
189 `${colors.bold}Sessions:${colors.reset} ${colors.primary}${stats.totalSessions}${colors.reset}`,
190 `${colors.bold}Current streak:${colors.reset} ${colors.primary}${stats.currentStreak} days${colors.reset}`,
191 `${colors.bold}Active days:${colors.reset} ${colors.primary}${stats.activeDays}${dateFilter ? "" : `/${daysToShow}`}${colors.reset}`,
192 ]
193 const col2 = [
194 `${colors.bold}Longest session:${colors.reset} ${colors.primary}${formatDuration(stats.longestSession)}${colors.reset}`,
195 `${colors.bold}Longest streak:${colors.reset} ${colors.primary}${stats.longestStreak} days${colors.reset}`,
196 `${colors.bold}Peak hour:${colors.reset} ${colors.primary}${formatHourRange(stats.peakHour)}${colors.reset}`,
197 ]
198
199 for (let i = 0; i < col1.length; i++) {
200 console.log(`${col1[i].padEnd(50)}${col2[i]}`)
201 }
202
203 if (tokenComparison) {
204 console.log()
205 console.log(`${colors.primary}You've used ~${tokenComparison}x more tokens than War and Peace${colors.reset}`)
206 }
207
208 if (!dateFilter) {
209 console.log()
210 console.log(`${colors.muted}Stats from the last ${daysToShow} days${colors.reset}`)
211 }
212 console.log()
213 }
214
215 if (view === "all" || view === "models") {
216 renderModelUsage(stats.modelUsage)
217 console.log()
218 }
219
220 if (view === "all" || view === "cost") {

Callers 1

stats.tsFile · 0.85

Calls 10

calculateDaysToShowFunction · 0.85
getFavoriteModelFunction · 0.85
getTokenComparisonFunction · 0.85
renderActivityHeatmapFunction · 0.85
renderModelUsageFunction · 0.85
renderCostOverviewFunction · 0.85
formatNumberFunction · 0.70
formatDurationFunction · 0.70
formatHourRangeFunction · 0.70
logMethod · 0.45

Tested by

no test coverage detected