Amaresh: Fix oversized TimeEntry/users response slowing the Dashboard - #2327
Open
amaresh2001 wants to merge 1 commit into
Open
Amaresh: Fix oversized TimeEntry/users response slowing the Dashboard#2327amaresh2001 wants to merge 1 commit into
amaresh2001 wants to merge 1 commit into
Conversation
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
The Dashboard's "Team Member Tasks" widget calls
POST /api/TimeEntry/users(getTimeEntriesForUsersList). That query populatedpersonIdwith no field projection, so the entire UserProfile document (~60 fields including the password hash,weeklySummaries,badgeCollection,permissions, etc.) was attached to every time-entry row, not once per person. On teams with a lot of logged time, this multiplies into a multi-MB response and stalls the widget / Dashboard load.The other three populates in the same function (
projectId,taskId,wbsId) are already trimmed to the fields the response actually returns; this change bringspersonIdin line.The frontend only reads two fields off each row's
userProfile:_idandemail(inTimelog/TimeEntry.jsx, rendered viaTeamMemberTasks.jsx), so the populate is narrowed to exactly those.Link to issue
Related PRS (if any):
Backend-only. No frontend PR needed.
Main changes explained:
src/controllers/timeEntryController.jsingetTimeEntriesForUsersList, change.populate('personId')to.populate('personId', '_id email')so only the fields the client uses are returned instead of the full UserProfile per row.How to test:
npm install, start the backendPOST /api/TimeEntry/usersrequestuserProfileit should now contain only_idandemail(previously ~60 fields includingpassword)Screenshots or videos of changes:
Before:

After:

userProfileper row{ _id, email }~98% smaller. The same ratio applied to the reported production payload takes it from ~15 MB to roughly ~300 KB.
Note: