mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-23 09:38:02 +00:00
Add dedicated API endpoint to fetch Claude account OAuth usage data asynchronously, improving user experience by eliminating the need for multiple page refreshes to view session window statistics. Backend changes: - Add GET /admin/claude-accounts/usage endpoint for batch fetching - Implement fetchOAuthUsage() to call Claude API /api/oauth/usage - Add buildClaudeUsageSnapshot() to construct frontend data structure - Add updateClaudeUsageSnapshot() to persist data to Redis - Add _toNumberOrNull() helper for safe type conversion - Update getAllAccounts() to return claudeUsage from Redis cache Data structure: - Store three window types: 5h, 7d, 7d-Opus - Track utilization percentage and reset timestamps - Calculate remaining seconds for each window Performance optimizations: - Concurrent batch requests using Promise.allSettled - Graceful error handling per account - Non-blocking async execution