mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-05-08 23:25:16 +00:00
Merge pull request #28 from chmsant/feat/menubar-30day-window
feat: add rolling 30-day window to menubar status
This commit is contained in:
commit
fc99087e3a
2 changed files with 21 additions and 1 deletions
|
|
@ -127,6 +127,7 @@ program
|
|||
const todayRange = getDateRange('today').range
|
||||
const todayData = buildPeriodData('Today', await parseAllSessions(todayRange, pf))
|
||||
const weekData = buildPeriodData('7 Days', await parseAllSessions(getDateRange('week').range, pf))
|
||||
const thirtyDayData = buildPeriodData('30 Days', await parseAllSessions(getDateRange('30days').range, pf))
|
||||
const monthData = buildPeriodData('Month', await parseAllSessions(getDateRange('month').range, pf))
|
||||
const todayProviders: ProviderCost[] = []
|
||||
for (const p of await getAllProviders()) {
|
||||
|
|
@ -134,7 +135,7 @@ program
|
|||
const cost = data.reduce((s, proj) => s + proj.totalCostUSD, 0)
|
||||
if (cost > 0) todayProviders.push({ name: p.displayName, cost })
|
||||
}
|
||||
console.log(renderMenubarFormat(todayData, weekData, monthData, todayProviders))
|
||||
console.log(renderMenubarFormat(todayData, weekData, thirtyDayData, monthData, todayProviders))
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ export type ProviderCost = {
|
|||
export function renderMenubarFormat(
|
||||
today: PeriodData,
|
||||
week: PeriodData,
|
||||
thirtyDays: PeriodData,
|
||||
month: PeriodData,
|
||||
todayProviders?: ProviderCost[],
|
||||
): string {
|
||||
|
|
@ -130,6 +131,24 @@ export function renderMenubarFormat(
|
|||
lines.push(`--${bar} ${name} ${formatCost(model.cost).padStart(8)} ${String(model.calls).padStart(5)} calls | font=Menlo size=11`)
|
||||
}
|
||||
|
||||
lines.push(`30 Days ${formatCost(thirtyDays.cost)} ${thirtyDays.calls.toLocaleString()} calls | size=14`)
|
||||
const tdMaxCat = Math.max(...thirtyDays.categories.map(c => c.cost), 0.01)
|
||||
const tdMaxModel = Math.max(...thirtyDays.models.filter(m => m.name !== '<synthetic>').map(m => m.cost), 0.01)
|
||||
lines.push(`--Activity | size=12 color=#FF8C42`)
|
||||
for (const cat of thirtyDays.categories.slice(0, 8)) {
|
||||
const bar = miniBar(cat.cost, tdMaxCat)
|
||||
const name = cat.name.padEnd(14)
|
||||
lines.push(`--${bar} ${name} ${formatCost(cat.cost).padStart(8)} ${String(cat.turns).padStart(4)} turns | font=Menlo size=11`)
|
||||
}
|
||||
lines.push(`-----`)
|
||||
lines.push(`--Models | size=12 color=#FF8C42`)
|
||||
for (const model of thirtyDays.models.slice(0, 5)) {
|
||||
if (model.name === '<synthetic>') continue
|
||||
const bar = miniBar(model.cost, tdMaxModel)
|
||||
const name = model.name.padEnd(14)
|
||||
lines.push(`--${bar} ${name} ${formatCost(model.cost).padStart(8)} ${String(model.calls).padStart(5)} calls | font=Menlo size=11`)
|
||||
}
|
||||
|
||||
lines.push(`Month ${formatCost(month.cost)} ${month.calls.toLocaleString()} calls | size=14`)
|
||||
const monthMaxCat = Math.max(...month.categories.map(c => c.cost), 0.01)
|
||||
const monthMaxModel = Math.max(...month.models.filter(m => m.name !== '<synthetic>').map(m => m.cost), 0.01)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue