claude-usage-dashboard 1.5.7 → 1.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/server/routes/api.js +16 -1
package/package.json
CHANGED
package/server/routes/api.js
CHANGED
|
@@ -6,7 +6,7 @@ import { filterByDateRange, autoGranularity, aggregateByTime, aggregateBySession
|
|
|
6
6
|
import { calculateRecordCost, PLAN_DEFAULTS } from '../pricing.js';
|
|
7
7
|
import { createQuotaFetcher } from '../quota.js';
|
|
8
8
|
import { getSubscriptionInfo } from '../credentials.js';
|
|
9
|
-
import { updateQuotaCycleSnapshot, loadQuotaCycles } from '../quota-cycles.js';
|
|
9
|
+
import { updateQuotaCycleSnapshot, loadQuotaCycles, computeCycleData } from '../quota-cycles.js';
|
|
10
10
|
|
|
11
11
|
export function createApiRouter(logBaseDir, options = {}) {
|
|
12
12
|
const router = Router();
|
|
@@ -146,6 +146,21 @@ export function createApiRouter(logBaseDir, options = {}) {
|
|
|
146
146
|
options.snapshotDir
|
|
147
147
|
);
|
|
148
148
|
if (data.currentCycle) {
|
|
149
|
+
// Recompute current cycle from parsed records — in sync mode this
|
|
150
|
+
// includes all machines' data, matching /api/cost and /api/usage.
|
|
151
|
+
// The snapshot's utilization % (from the quota API) is preserved.
|
|
152
|
+
const records = refreshRecords();
|
|
153
|
+
const cycleRecords = filterByDateRange(
|
|
154
|
+
records, data.currentCycle.start, data.currentCycle.resets_at
|
|
155
|
+
);
|
|
156
|
+
const quotaShim = {
|
|
157
|
+
seven_day: { utilization: data.currentCycle.overall.utilization },
|
|
158
|
+
seven_day_opus: { utilization: data.currentCycle.models?.opus?.utilization || 0 },
|
|
159
|
+
seven_day_sonnet: { utilization: data.currentCycle.models?.sonnet?.utilization || 0 },
|
|
160
|
+
};
|
|
161
|
+
const fresh = computeCycleData(cycleRecords, quotaShim);
|
|
162
|
+
Object.assign(data.currentCycle, fresh);
|
|
163
|
+
|
|
149
164
|
const start = new Date(data.currentCycle.start);
|
|
150
165
|
const now = new Date();
|
|
151
166
|
data.currentCycle.daysElapsed = Math.round(((now - start) / (1000 * 60 * 60 * 24)) * 10) / 10;
|