mirror of
https://github.com/nomadkaraoke/karaoke-gen.git
synced 2026-11-28 01:49:00 +09:00
## Summary - Filter out E2E test data from admin dashboard by default (emails ending in `@inbox.testmail.app`) - Add "Show test data" toggle in admin header that persists to localStorage - Add `exclude_test` query parameter to all admin list/stats endpoints (defaults to `true`) - Add streaming limits with warnings to prevent memory issues on large datasets ## Changes **Backend:** - New `backend/utils/test_data.py` with `is_test_email()` utility - Updated admin stats endpoint with test data filtering - Updated users list, jobs list, beta stats, and audio searches endpoints - Added USERS_STREAM_LIMIT (2000) and JOBS_STREAM_LIMIT (10000) with warning logs **Frontend:** - New `frontend/lib/admin-settings.ts` zustand store for admin preferences - Toggle switch in admin layout header - All admin pages pass `exclude_test: !showTestData` to API calls **Docs:** - Updated API.md with exclude_test parameter documentation ## Test Plan - [x] Backend tests pass (68 passed) - [x] Frontend tests pass (128 passed) - [x] Frontend build succeeds - [x] CodeRabbit review passed - [ ] Manual: Visit `/admin` - stats should show lower numbers by default - [ ] Manual: Toggle "Show test data" ON - counts should increase - [ ] Manual: Toggle persists across page refreshes <!-- @coderabbitai ignore --> 🤖 Generated with [Claude Code](https://claude.ai/code) --------- Co-authored-by: Claude <noreply@anthropic.com>
30 lines
741 B
TypeScript
30 lines
741 B
TypeScript
/**
|
|
* Admin settings store for persisting admin dashboard preferences.
|
|
*
|
|
* Uses zustand with localStorage persistence for settings like
|
|
* whether to show test data in admin views.
|
|
*/
|
|
import { create } from 'zustand'
|
|
import { persist } from 'zustand/middleware'
|
|
|
|
interface AdminSettings {
|
|
/**
|
|
* When false (default), test data (e.g., @inbox.testmail.app users) is hidden.
|
|
* When true, all data including test data is shown.
|
|
*/
|
|
showTestData: boolean
|
|
setShowTestData: (show: boolean) => void
|
|
}
|
|
|
|
export const useAdminSettings = create<AdminSettings>()(
|
|
persist(
|
|
(set) => ({
|
|
showTestData: false,
|
|
setShowTestData: (show) => set({ showTestData: show }),
|
|
}),
|
|
{
|
|
name: 'admin-settings',
|
|
}
|
|
)
|
|
)
|