Repository navigation
Conversation
- Rename teamCode to teamName across WeeklyGrading schema, controller, and index - Normalize save dates to Sunday midnight UTC to prevent duplicate records - Update GET /api/weekly-grading to accept weekStart param for week range queries - Add DELETE /api/weekly-grading/reviewer endpoint for reviewer removal - Add POST /api/pr-grading-config/sync-reviewers to auto-populate team configs from SQ submissions, excluding promoted team members, split by last name A-M/N-Z - Calculate prsNeeded from userProfile.weeklycommittedHours - Add controller tests for weeklyGradingController and prGradingConfigController
|
There was a problem hiding this comment.
PR Review & Local Testing Update
I pulled down frontend branch pr-grading-screen-frontend and backend branch pr-grading-screen-backend to test the changes locally.
When running the frontend test suite (npm test), I encountered 17 failing tests across 3 test files:
Test Files 3 failed | 314 passed | 1 skipped (318)
Tests 17 failed | 2123 passed | 14 skipped (2154)
sawantgayatri19
left a comment
There was a problem hiding this comment.
Summary of Changes Reviewed:
Schema Unification: Verified schema alignment from teamCode to teamName in weeklyGrading.js and updated compound unique indexes.
Controllers & Routes: Checked refactored endpoints and controller methods in weeklyGradingController.js, weeklyGradingRouter.js, prGradingConfigController.js, and prGradingConfigRouter.js, including Sunday midnight UTC date normalization and the POST /api/pr-grading-config/sync-reviewers sync logic.
Testing: Confirmed inclusion of new unit test suites covering the controller methods and synchronization logic.
Current Blockers & Action Items:
SonarQube Quality Gate Failed: The SonarQube Cloud Analysis reported an E Security Rating on New Code violation that must be fixed by the author.
Local Test Failures: As noted by iAbhi001, pulling down this backend branch alongside frontend PR #5414 results in 17 failing tests during local execution that need to be resolved.
sitaram1921
left a comment
There was a problem hiding this comment.
Hi Rithika,
I reviewed this against development and exercised the endpoints locally. The core diagnosis in your description is right, the teamCode / teamName mismatch really was why the screen fell back to mock data, and the write-up is clear. A few things need sorting before this can go in.
Note I could not follow your test steps end to end: the paired frontend #5414 does not compile. routes.jsx ends up importing PRGradingDashboard twice (the branch adds it at line 162 while development already has it at line 200), which is a Babel parse error in the app router, so no page loads. That is a #5414 issue and I will raise it there, but it does mean the grading screen itself is untested.
iAbhi001
left a comment
There was a problem hiding this comment.
PR Review & Local Testing Approval
I pulled down and tested backend branch pr-2256 alongside frontend PR #4608.
Local Execution & Setup:
- Server started successfully on port 4500 with MongoDB connected.
- Verified test suite and local endpoints.
Verified Backend Functionality:
- Issue Tracking Aggregations: Tested data fetching for both Longest Open and Most Expensive issue endpoints.
- Model Reference Fix: Confirmed the
injuryIssueschema reference update tobuildingProjectallows project filtering to return proper data instead of empty arrays. - Query & Filter Parameters: Verified query params (
projectId,startDate,endDate) handle aggregation criteria accurately for specific project IDs as well as'all'.
Approving changes.
vidiyala99
left a comment
There was a problem hiding this comment.
Reviewed 4861598. The PR's suites pass (prGradingConfigController.test.js + weeklyGradingController.test.js, 44/44). They start from an empty in-memory database, though, so they don't cover what happens to a database that already has weeklyGradings. I tested that case with a small probe against an in-memory MongoDB set up the way existing databases are today (the old { teamCode, date, reviewer } unique index plus one old-schema document), using this branch's WeeklyGrading model:
-
Existing grades become invisible. The old document (
teamCode: "Alpha") is not found byWeeklyGrading.find({ teamName: "Alpha" }), which returns 0. Every grade saved before this change would disappear from the grading screen. A migration that copiesteamCodeintoteamName(or$renames it) is needed. -
The old unique index breaks saves for a second team. Renaming the field in the schema doesn't drop
teamCode_1_date_1_reviewer_1from MongoDB; Mongoose only adds the new indexes. New documents have noteamCode, which that index treats asnull. Saving reviewer "Bob" for 2026-10-11 under team "Alpha" works, but then saving "Bob" for the same date under team "Beta" fails:E11000 duplicate key error ... index: teamCode_1_date_1_reviewer_1 dup key: { teamCode: null, ... }The same migration should drop the old index (
db.weeklyGradings.dropIndex('teamCode_1_date_1_reviewer_1')). -
The branch is 514 commits behind
development, and the same controller is also being changed in #2077 (duplicate PR numbers, which still usesteamCode). Please mergedevelopmentand coordinate with #2077, so whichever lands second doesn't reintroduceteamCode.
Requesting changes for items 1 and 2.
vidiyala99
left a comment
There was a problem hiding this comment.
Re-tested the new head 0f1c128 ("support legacy weekly grading team codes") with a probe through the controller, against an in-memory MongoDB set up like an existing database (the old unique { teamCode, date, reviewer } index plus one old-schema grade with teamCode: "Alpha" only):
| Check | 4861598 (my last review) |
0f1c128 |
|---|---|---|
Old grade shows up for team Alpha (getWeeklyGrading, week of Oct 4) |
not found | found (Alice) |
| Save reviewer Bob for Oct 11 under Alpha, then under Beta | Beta failed with E11000 ... teamCode_1_date_1_reviewer_1 dup key: { teamCode: null } |
both 200 |
| Save Alpha/Alice/Oct 4 again (updating the old grade) | n/a | 200, still one document, now with teamName and teamCode both "Alpha", version 2 |
| Delete Alpha/Alice for that week | n/a | 200, document removed |
So both of my items are fixed without a migration: reads and deletes match either field, and every save writes teamCode alongside teamName, so the old unique index never sees null. Updating an old grade also upgrades it in place. The PR's suites pass (prGradingConfigController.test.js + weeklyGradingController.test.js, 45/45, including the new legacy test), and the branch now includes development, and (per the last two commits) the unrelated task controller change is gone.
Two small follow-ups, not blocking:
- The schema comment says
teamCodestays "until the production migration runs". It would help to open a tracking issue for that migration (copyteamCodeintoteamName, then dropteamCode_1_date_1_reviewer_1), so the dual-field code can be removed later. - #2077 changes this same controller; whichever merges second should keep the
$orreads and theteamCodewrite.
Approving.
|








Description
The PR grading screen (
/pr-grading-screen) was broken — it always showed mock data instead of real data. The root cause was a field name mismatch between two collections:weeklyGradingsusedteamCodewhileprGradingConfigsusedteamName. The frontend readsteamNamefrom the config and passes it as the?team=query param, but the backend was querying byteamCode, so every request returned an empty array and the frontend fell back to fake data.This PR fixes that mismatch and adds the remaining backend capabilities needed for the grading screen to work end-to-end in production.
Implements: PR Grading Screen backend support
Related PRs:
This backend PR is related to the frontend PR #5414. To test this backend PR you need to checkout frontend PR #5414.
Main changes explained:
Update
src/models/prAnalytics/weeklyGrading.js— renamed fieldteamCode→teamNamein the schema and updated the compound unique index to matchUpdate
src/controllers/prAnalytics/weeklyGradingController.js— replaced allteamCodereferences withteamName, changed?date=param to?weekStart=for 7-day range queries, added Sunday midnight UTC normalization on save to prevent duplicate records, addeddeleteReviewerGradinghandlerUpdate
src/routes/prAnalytics/weeklyGradingRouter.js— registered newDELETE /api/weekly-grading/reviewerrouteUpdate
src/controllers/prAnalytics/prGradingConfigController.js— addedsyncReviewersmethod that auto-populatesreviewerNamesin team configs by querying SQ submissions (hgnFormResponses), excluding users already on a dev team (teams.members), splitting by last name A–M / N–Z, and calculatingprsNeededfromuserProfile.weeklycommittedHoursUpdate
src/routes/prAnalytics/prGradingConfigRouter.js— registered newPOST /api/pr-grading-config/sync-reviewersroute, updated constructor to acceptUserProfile,HgnFormResponse, andTeammodelsUpdate
src/startup/routes.js— passesuserProfile,hgnFormResponses, andteammodels toprGradingConfigRouterCreate
src/controllers/prAnalytics/weeklyGradingController.test.js— 22 unit tests covering all three controller methodsCreate
src/controllers/prAnalytics/prGradingConfigController.test.js— 22 unit tests covering all four controller methods including sync logicCreate
docs/pr-grading-screen-backend-changes.md— full documentation of all changes, reasoning, DB migration commands, and outstanding items for the next developerHow to test:
npm installand start the server withnpm start/pr-grading-screenreviewerNamesdb.weeklyGradingswith a Sunday-midnight UTC datenpm test— verify all tests passNote:
POST /api/pr-grading-config/sync-reviewersassumes "promoted to a dev team" means the user's_idappears inteams.members.userId. If the promotion tracking mechanism changes in the future, this query needs updating.