Skip to content

Conversation

Copy link

Copilot AI commented Feb 9, 2026

Admin panel became unresponsive with 8000+ users as it loaded all records into the browser at once.

Backend Changes

  • Limit initial queries: Cap to 1000 active + 1000 deleted records for users and projects
  • Server-side search endpoints: POST /admin/users/search and POST /admin/projects/search
  • Multi-field aggregation: Search across email, name, project name, owner info, and IDs using MongoDB pipelines
// Before: Load everything
const activeUsers = await User.find({}, projection).lean().exec()

// After: Limit initial load, search server-side
const activeUsers = await User.find({}, projection).limit(1000).lean().exec()

Frontend Changes

  • Debounced remote search: 300ms for users, 500ms for projects with AbortController for cancellation
  • Conditional "Show All": Only display when ≤200 hidden users or ≤500 hidden projects
  • Search state management: searchResults overrides local data when actively searching
useEffect(() => {
  if (!searchText.length) {
    setSearchResults(null)
    return
  }
  const abortController = new AbortController()
  const timer = setTimeout(() => {
    searchUsers(searchText, abortController.signal)
      .then(data => setSearchResults(data.users))
  }, 300)
  return () => {
    clearTimeout(timer)
    abortController.abort()
  }
}, [searchText])

Additional Fixes

  • Race condition in search input handling
  • User selection logic to use filtered dataset
  • Password security in update endpoint

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI mentioned this pull request Feb 9, 2026
1 task
Copilot AI changed the title [WIP] Optimize admin tools for handling large user datasets Optimize admin tools for large datasets with server-side search Feb 9, 2026
Copilot AI requested a review from Musicminion February 9, 2026 06:46
@Musicminion Musicminion closed this Feb 9, 2026
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