MCPcopy Index your code
hub / github.com/Dimillian/CodexMonitor / getUsageLabels

Function getUsageLabels

src/features/app/utils/usageLabels.ts:49–76  ·  view source on GitHub ↗
(
  accountRateLimits: RateLimitSnapshot | null,
  showRemaining: boolean,
)

Source from the content-addressed store, hash-verified

47}
48
49export function getUsageLabels(
50 accountRateLimits: RateLimitSnapshot | null,
51 showRemaining: boolean,
52): UsageLabels {
53 const usagePercent = accountRateLimits?.primary?.usedPercent;
54 const globalUsagePercent = accountRateLimits?.secondary?.usedPercent;
55 const sessionPercent =
56 typeof usagePercent === "number"
57 ? showRemaining
58 ? 100 - clampPercent(usagePercent)
59 : clampPercent(usagePercent)
60 : null;
61 const weeklyPercent =
62 typeof globalUsagePercent === "number"
63 ? showRemaining
64 ? 100 - clampPercent(globalUsagePercent)
65 : clampPercent(globalUsagePercent)
66 : null;
67
68 return {
69 sessionPercent,
70 weeklyPercent,
71 sessionResetLabel: formatResetLabel(accountRateLimits?.primary?.resetsAt),
72 weeklyResetLabel: formatResetLabel(accountRateLimits?.secondary?.resetsAt),
73 creditsLabel: formatCreditsLabel(accountRateLimits),
74 showWeekly: Boolean(accountRateLimits?.secondary),
75 };
76}

Callers 3

buildHomeUsageViewModelFunction · 0.90
Sidebar.tsxFile · 0.90
buildTraySessionUsageFunction · 0.90

Calls 3

formatResetLabelFunction · 0.85
formatCreditsLabelFunction · 0.85
clampPercentFunction · 0.70

Tested by

no test coverage detected