Fix duplicate session billing and align pricing with DeepSeek ×3.
Serialize billSessionUsage with row locks, expose rates on recharge, add compensation script and admin usage views. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+22
-4
@@ -41,6 +41,7 @@ import type {
|
||||
SessionEvent,
|
||||
SessionListResponse,
|
||||
UsageRecord,
|
||||
UsageSummary,
|
||||
BalanceUpdate,
|
||||
} from '../types';
|
||||
|
||||
@@ -299,8 +300,14 @@ export async function getMe(): Promise<{
|
||||
return portalFetch('/auth/me');
|
||||
}
|
||||
|
||||
export async function getMyUsage(): Promise<UsageRecord[]> {
|
||||
const result = await portalFetch<{ records: UsageRecord[] }>('/auth/usage');
|
||||
export async function getMyUsageSummary(): Promise<UsageSummary> {
|
||||
const result = await portalFetch<{ summary: UsageSummary }>('/auth/usage/summary');
|
||||
return result.summary;
|
||||
}
|
||||
|
||||
export async function getMyUsage(limit = 20): Promise<UsageRecord[]> {
|
||||
const query = limit ? `?limit=${encodeURIComponent(String(limit))}` : '';
|
||||
const result = await portalFetch<{ records: UsageRecord[] }>(`/auth/usage${query}`);
|
||||
return result.records ?? [];
|
||||
}
|
||||
|
||||
@@ -1010,8 +1017,19 @@ export async function getAdminDashboardSummary(): Promise<AdminDashboardSummary>
|
||||
return result.summary;
|
||||
}
|
||||
|
||||
export async function listAdminUsage(userId?: string): Promise<UsageRecord[]> {
|
||||
const query = userId ? `?userId=${encodeURIComponent(userId)}` : '';
|
||||
export async function getAdminUsageSummary(userId?: string): Promise<UsageSummary> {
|
||||
const params = new URLSearchParams();
|
||||
if (userId) params.set('userId', userId);
|
||||
const query = params.toString() ? `?${params.toString()}` : '';
|
||||
const result = await portalFetch<{ summary: UsageSummary }>(`/admin-api/usage/summary${query}`);
|
||||
return result.summary;
|
||||
}
|
||||
|
||||
export async function listAdminUsage(userId?: string, limit = 20): Promise<UsageRecord[]> {
|
||||
const params = new URLSearchParams();
|
||||
if (userId) params.set('userId', userId);
|
||||
if (limit) params.set('limit', String(limit));
|
||||
const query = params.toString() ? `?${params.toString()}` : '';
|
||||
const result = await portalFetch<{ records: UsageRecord[] }>(`/admin-api/usage${query}`);
|
||||
return result.records ?? [];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user