mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 02:08:27 +00:00
refactor: dedupe provider usage fetch logic and tests
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { fetchJson } from "./provider-usage.fetch.shared.js";
|
||||
import { buildUsageHttpErrorSnapshot, fetchJson } from "./provider-usage.fetch.shared.js";
|
||||
import { clampPercent, PROVIDER_LABELS } from "./provider-usage.shared.js";
|
||||
import type { ProviderUsageSnapshot, UsageWindow } from "./provider-usage.types.js";
|
||||
|
||||
@@ -30,12 +30,10 @@ export async function fetchCopilotUsage(
|
||||
);
|
||||
|
||||
if (!res.ok) {
|
||||
return {
|
||||
return buildUsageHttpErrorSnapshot({
|
||||
provider: "github-copilot",
|
||||
displayName: PROVIDER_LABELS["github-copilot"],
|
||||
windows: [],
|
||||
error: `HTTP ${res.status}`,
|
||||
};
|
||||
status: res.status,
|
||||
});
|
||||
}
|
||||
|
||||
const data = (await res.json()) as CopilotUsageResponse;
|
||||
|
||||
Reference in New Issue
Block a user