Compare commits
1 Commits
cf7ad047d3
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 461773c677 |
@@ -60,8 +60,18 @@ function usageColor(fraction: number): { r: number; g: number; b: number } {
|
|||||||
|
|
||||||
function findWindowLimits(report: UsageReport): UsageWindows {
|
function findWindowLimits(report: UsageReport): UsageWindows {
|
||||||
const windowId = (limit: UsageLimit) => (limit.window?.id ?? limit.scope.windowId ?? "").toLowerCase();
|
const windowId = (limit: UsageLimit) => (limit.window?.id ?? limit.scope.windowId ?? "").toLowerCase();
|
||||||
const current = report.limits.find(limit => ["5h", "primary"].includes(windowId(limit))) ?? report.limits[0];
|
const limitId = (limit: UsageLimit) => (limit.id ?? "").toLowerCase();
|
||||||
const week = report.limits.find(limit => ["7d", "secondary"].includes(windowId(limit))) ?? report.limits.find(limit => limit !== current);
|
|
||||||
|
// Match by Window ID
|
||||||
|
const currentByWindow = report.limits.find(limit => ["5h", "primary"].includes(windowId(limit)));
|
||||||
|
const weekByWindow = report.limits.find(limit => ["7d", "secondary"].includes(windowId(limit)));
|
||||||
|
|
||||||
|
// Match by Limit ID (Z.ai Uses Generic "quota" Window IDs for Both Limits)
|
||||||
|
const currentByLimit = report.limits.find(limit => ["zai:tokens"].includes(limitId(limit)));
|
||||||
|
const weekByLimit = report.limits.find(limit => ["zai:requests"].includes(limitId(limit)));
|
||||||
|
|
||||||
|
const current = currentByWindow ?? currentByLimit ?? report.limits[0];
|
||||||
|
const week = weekByWindow ?? weekByLimit ?? report.limits.find(limit => limit !== current);
|
||||||
return { current, week };
|
return { current, week };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user