Skip to content

Conversation

@maynetee
Copy link
Owner

@maynetee maynetee commented Feb 3, 2026

The DashboardPage (frontend/src/features/dashboard/dashboard-page.tsx) makes 5-7 independent API calls on mount: channels list, collections list, stats overview, messages-by-day, messages-by-channel, trust stats, and optionally collection-specific stats. While React Query parallelizes independent calls, the channels/collections queries must complete first (they gate the enabled flag on downstream queries), creating a 2-stage waterfall: stage 1 loads channels+collections, stage 2 fires 3-4 stats queries.

Mendel and others added 8 commits February 3, 2026 08:57
…syncio.gather

- Added asyncio import for parallel query execution
- Implemented /stats/dashboard endpoint that fetches all stats concurrently
- Uses asyncio.gather to execute 6 stats queries in parallel:
  * get_overview_stats
  * get_messages_by_day
  * get_messages_by_channel
  * get_trust_stats
  * get_api_usage_stats
  * get_translation_metrics
- Returns unified dashboard response with all statistics
- Includes response caching and proper authentication
- Added comprehensive tests for endpoint structure and concurrency
…shboard endpoint

- Added collection_id: Optional[UUID] = Query(None) parameter to get_dashboard_stats
- Parameter follows existing pattern for optional query parameters
- Enables collection-specific dashboard filtering (filtering logic to be implemented)
… response

Added DashboardData interface that combines StatsOverview, MessagesByDay[],
MessagesByChannel[], and TrustStats to match the backend /stats/dashboard endpoint
response schema. Follows existing patterns with JSDoc comments and snake_case naming.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Added statsApi.dashboard(collectionId?: string) method that calls
/api/stats/dashboard with optional collection_id parameter.

- Imported DashboardData type from types.ts
- Added JSDoc documentation following existing patterns
- Method accepts optional collectionId string parameter
- Passes collection_id as query param when provided
- Returns Promise<DashboardData> with unified dashboard statistics

This method enables the frontend to fetch all dashboard data in a
single API call, eliminating the waterfall of separate stats requests.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Fixes:
- Changed backend field name from 'trust' to 'trust_stats' for consistency
- Added ApiUsageStats and TranslationMetrics schemas to backend
- Added response_model=DashboardResponse to dashboard endpoint
- Updated backend tests to expect 'trust_stats' field
- Added ApiUsageStats and TranslationMetrics TypeScript interfaces
- Updated DashboardData interface with api_usage and translation_metrics fields

Verified:
- All Python files pass syntax validation
- Backend schema imports successfully
- All field names now match between backend and frontend
- Response validation enabled via response_model parameter

QA Fix Session: 1

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@maynetee maynetee merged commit 6f53223 into main Feb 3, 2026
0 of 2 checks passed
@maynetee maynetee deleted the auto-claude/025-add-a-unified-stats-dashboard-endpoint-to-eliminat branch February 3, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants