feat: add admin stats page with token usage
This commit is contained in:
@@ -300,3 +300,37 @@ export async function deletePlayerCharacter(id: string): Promise<boolean> {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// ============ ADMIN STATS ============
|
||||
|
||||
interface StoryStats {
|
||||
id: string;
|
||||
title: string;
|
||||
messageCount: number;
|
||||
tokens: number;
|
||||
lastPlayed: string | null;
|
||||
}
|
||||
|
||||
interface AdminStats {
|
||||
totalStories: number;
|
||||
totalSessions: number;
|
||||
totalTokens: number;
|
||||
stories: StoryStats[];
|
||||
}
|
||||
|
||||
export async function getAdminStats(): Promise<AdminStats | null> {
|
||||
try {
|
||||
const response = await fetch(`${API_URL}/api/admin/stats`, {
|
||||
credentials: "include",
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return await response.json();
|
||||
} catch (error) {
|
||||
console.error("Failed to get admin stats:", error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user