feat(admin): add observability dashboard - #91
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 776299800f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| isLoading={usersQuery.isLoading || activeUsersQuery.isLoading} | ||
| isError={usersQuery.isError || activeUsersQuery.isError} | ||
| hasData={inactiveUsers.length > 0} |
There was a problem hiding this comment.
Stop labeling users offline when the active-user query fails
When /users/admin/all succeeds but /users/admin/active fails, activeUsersQuery.data ?? [] makes inactiveUsers contain every user, and the non-empty hasData value causes QueryContent to ignore isError. The dashboard consequently labels all users “Не в сети,” including users whose status is unknown; this block should render an error unless both source queries have usable data.
AGENTS.md reference: AGENTS.md:L34-L35
Useful? React with 👍 / 👎.
| useEffect(() => { | ||
| const timer = window.setInterval(() => setNow(Date.now()), 1000); | ||
| return () => window.clearInterval(timer); |
There was a problem hiding this comment.
Keep the live clock out of the whole dashboard
While the page is open, this one-second state update re-renders the entire AdminPage, rebuilding every user, duel, submission, group, and tournament row merely to update ranked-search wait times. Because the admin endpoints include complete historical lists, accounts with sizable histories will pay this reconciliation cost every second; isolate the clock in the ranked-search table or update only those cells.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9556b54fb0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| const skipAdminQueries = { skip: !isAdmin }; | ||
| const usersQuery = useGetAdminUsersQuery(undefined, skipAdminQueries); | ||
| const activeUsersQuery = useGetAdminActiveUsersQuery(undefined, skipAdminQueries); |
There was a problem hiding this comment.
Refresh the volatile admin lists
When an administrator keeps /admin open while backend state changes, these RTK Query subscriptions use the default one-time fetch with no polling, focus/reconnect refetch, cache invalidation tags, or realtime handler. Consequently active users, ranked searchers, pending/active duels, testing submissions, and tournaments remain frozen at their initial snapshots indefinitely—even as the displayed search wait time continues advancing—so add polling, realtime invalidation, or an explicit refresh mechanism for these volatile lists.
AGENTS.md reference: AGENTS.md:L37-L37
Useful? React with 👍 / 👎.
Summary
/admindashboard with five collapsible sections for users, duels, submissions, groups, and tournamentsAcceptedin green, and every other terminal verdict in red/adminwith a dedicated access-denied screen without starting admin requests or clearing their sessionBackend dependency and contract gaps
This PR depends on DIvanCode/CoDuels-Backend#337. Its admin submission-list DTO provides
duel_idandtask_key, and its regular duel/submission read endpoints allow administrator access.The current backend contract does not expose the Friendly/Group/Tournament origin or group/tournament references on active and finished
DuelDtorecords. Those lists therefore show rated versus unrated mode but cannot yet be grouped by origin.TournamentDtoalso exposescreated_at, not a tournament start time, so the dashboard labels that column as creation time.Verification
pnpm test— 26 files, 82 tests passedpnpm lint— passed; 4 pre-existing repository warnings remainpnpm fsd:lint— existing baseline remains at 12 errors and 11 warnings; the admin change adds no new findingVITE_BASE_URL=/api pnpm build— passeddistwas served with Vite preview and smoke-tested in headless Chrome:/admin, remained authenticated, saw “Нет доступа”, and made 0 admin requests/admin, made all 11 admin requests, and saw all 5 dashboard sectionsAcceptedin green,Wrong answerin red, andRunningas yellow “Проверяется”/duel/77/submissions/101?task=Band rendered its Accepted detail#rootwithout uncaught exceptions or an application error-boundaryWhat to test manually
Prerequisites: an administrator account, a non-admin account, Backend PR 337 available in the test environment, and representative active/inactive users, pending/in-progress/finished duels, submissions, groups, and tournaments.
/admin.Acceptedrows are green, and every other completed verdict is red./duel/{duelId}/submissions/{submissionId}?task={taskKey}, the correct task, and the selected submission detail without a redirect./admin; expect “Нет доступа”, no redirect to/auth, and a preserved authenticated session.Closes #89