Fix/db performance#366
Conversation
…ystem performance and database connections
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThis PR removes the admin monitoring dashboard and its server-side monitoring router/integration, disables global TRPC refetch-on-focus/reconnect defaults while enabling notifications refetch on window focus, derives Prisma pool sizing from DATABASE_URL, and replaces several query-batching helpers with Promise.all/direct counts. ChangesMonitoring System Removal and Query Behavior Update
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/components/notifications/NotificationCenter.tsx (1)
27-35:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winConsider adding
refetchOnWindowFocusto the notifications list query for consistency.Only
unreadCountQuery(line 33) enablesrefetchOnWindowFocus, butnotificationsQuery(lines 27-30) does not. This creates a brief inconsistency window: when the user returns to the tab, the badge count updates immediately but the notifications list remains stale until the next polling interval. While both queries userefetchIntervalfor eventual consistency, users might see a mismatch between the badge number and the visible list.🔄 Proposed fix to align refetch behavior
const notificationsQuery = api.notifications.get.useQuery( { limit: 10, offset: 0 }, - { enabled: !!user, refetchInterval: POLLING_INTERVALS.NOTIFICATIONS }, + { + enabled: !!user, + refetchOnWindowFocus: true, + refetchInterval: POLLING_INTERVALS.NOTIFICATIONS + }, )🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/components/notifications/NotificationCenter.tsx` around lines 27 - 35, The notifications list query (notificationsQuery created via api.notifications.get.useQuery) lacks refetchOnWindowFocus while unreadCountQuery includes it, causing badge/list inconsistencies; update notificationsQuery's options to include refetchOnWindowFocus: true (alongside enabled and refetchInterval) so both queries refresh when the window regains focus and stay consistent with unreadCountQuery.
🧹 Nitpick comments (1)
src/server/prisma-client.ts (1)
6-6: ⚡ Quick winRemove redundant
[::1]entry.When parsing a URL like
postgres://[::1]:5432/db, theurl.hostnameproperty returns::1without brackets. The brackets are only URL delimiters for IPv6 addresses. The[::1]entry will never match and can be removed.🧹 Proposed fix
-const LOCAL_DATABASE_HOSTS = new Set(['localhost', '127.0.0.1', '0.0.0.0', '::1', '[::1]']) +const LOCAL_DATABASE_HOSTS = new Set(['localhost', '127.0.0.1', '0.0.0.0', '::1'])🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/server/prisma-client.ts` at line 6, Remove the redundant IPv6 bracketed entry from the LOCAL_DATABASE_HOSTS set: update the constant LOCAL_DATABASE_HOSTS (where it's defined) to delete the string '[::1]' so the set contains '::1' (unbracketed) only, ensuring hostname checks correctly match IPv6 loopback addresses.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/components/notifications/NotificationCenter.tsx`:
- Around line 27-35: The notifications list query (notificationsQuery created
via api.notifications.get.useQuery) lacks refetchOnWindowFocus while
unreadCountQuery includes it, causing badge/list inconsistencies; update
notificationsQuery's options to include refetchOnWindowFocus: true (alongside
enabled and refetchInterval) so both queries refresh when the window regains
focus and stay consistent with unreadCountQuery.
---
Nitpick comments:
In `@src/server/prisma-client.ts`:
- Line 6: Remove the redundant IPv6 bracketed entry from the
LOCAL_DATABASE_HOSTS set: update the constant LOCAL_DATABASE_HOSTS (where it's
defined) to delete the string '[::1]' so the set contains '::1' (unbracketed)
only, ensuring hostname checks correctly match IPv6 loopback addresses.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: ff0a4415-1736-40b2-89c7-23d2469e613e
📒 Files selected for processing (15)
src/app/admin/components/AdminNavIcon.tsxsrc/app/admin/config/routes.tssrc/app/admin/data.tssrc/app/admin/monitoring/components/BundleSizeMonitor.tsxsrc/app/admin/monitoring/components/DatabaseConnectionMonitor.tsxsrc/app/admin/monitoring/components/PerformanceMetrics.tsxsrc/app/admin/monitoring/page.tsxsrc/components/notifications/NotificationCenter.tsxsrc/lib/api.tsxsrc/lib/dynamic-imports.tsxsrc/server/api/root.tssrc/server/api/routers/system.tssrc/server/init.tssrc/server/prisma-client.tssrc/server/utils/connection-monitor.ts
💤 Files with no reviewable changes (11)
- src/server/api/routers/system.ts
- src/app/admin/monitoring/components/BundleSizeMonitor.tsx
- src/app/admin/monitoring/page.tsx
- src/app/admin/monitoring/components/PerformanceMetrics.tsx
- src/server/utils/connection-monitor.ts
- src/app/admin/monitoring/components/DatabaseConnectionMonitor.tsx
- src/lib/dynamic-imports.tsx
- src/server/init.ts
- src/app/admin/data.ts
- src/server/api/root.ts
- src/app/admin/components/AdminNavIcon.tsx
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/app/listings/ListingsPage.tsx (1)
68-95:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winAvoid showing role-based UI from stale
users.medata after sign-out
src/app/listings/ListingsPage.tsxgates theapi.users.mequery withenabled: isSignedIn === true, but the render logic still usesuserQuery.datadirectly (e.g.,{userQuery.data && ...}), and there’s no app-side sign-out handler found that invalidates/clearsusers.meon auth transitions. Gate those UI checks withisSignedIn(or invalidateusers.meon sign-out) so signed-out views can’t temporarily use cached role data.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/app/listings/ListingsPage.tsx` around lines 68 - 95, The page currently reads userQuery.data directly which can be stale after sign-out; update render and logic to always gate role-sensitive UI with isSignedIn (e.g., use "isSignedIn && userQuery.data" instead of "userQuery.data") or, alternatively, ensure users.me is cleared on sign-out by invalidating/removing the query via the react-query/queryClient when sign-out occurs; target the api.users.me.useQuery/userQuery and any places that reference userQuery.data (and userPreferencesQuery) so role-based UI only renders when isSignedIn is true or the query is explicitly cleared.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/app/listings/ListingsPage.tsx`:
- Around line 68-95: The page currently reads userQuery.data directly which can
be stale after sign-out; update render and logic to always gate role-sensitive
UI with isSignedIn (e.g., use "isSignedIn && userQuery.data" instead of
"userQuery.data") or, alternatively, ensure users.me is cleared on sign-out by
invalidating/removing the query via the react-query/queryClient when sign-out
occurs; target the api.users.me.useQuery/userQuery and any places that reference
userQuery.data (and userPreferencesQuery) so role-based UI only renders when
isSignedIn is true or the query is explicitly cleared.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 738bdfbd-a5ac-4c7b-b966-65f89fb72f4a
📒 Files selected for processing (7)
src/app/listings/ListingsPage.tsxsrc/server/api/routers/listingReports.tssrc/server/api/routers/mobile/admin.tssrc/server/api/routers/socs.tssrc/server/api/routers/users.tssrc/server/services/report-stats.service.tssrc/server/utils/query-performance.ts
💤 Files with no reviewable changes (1)
- src/server/utils/query-performance.ts
Description
Reduces unnecessary database pressure in production and removes monitoring code that was giving us noisy, misleading signals.
Changes included:
pgadapter pool per serverless instance instead of relying on URL params that the adapter does not use.No Vercel/Supabase env var changes are required for this PR.
Type of change
How Has This Been Tested?
Screenshots (if applicable)
N/A. This removes an unused admin monitoring screen and does not add user-facing UI.
Checklist
Notes for reviewers
Summary by CodeRabbit
Removed Features
Bug Fixes
Chores