Skip to content

Priyanka: Prevent duplicate PR entries and retain added PRs - #5630

Open
muthapriyanka wants to merge 5 commits into
developmentfrom
Priyanka_pr_grading_duplicates_persistence
Open

muthapriyanka wants to merge 5 commits into
developmentfrom
Priyanka_pr_grading_duplicates_persistence

Conversation

@muthapriyanka

@muthapriyanka muthapriyanka commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Description

The Weekly PR grading screen allowed the same PR number to be added more than once for a reviewer. Newly added PRs also disappeared after refreshing the page because they were held only in browser state.

task

This PR prevents duplicate PR numbers for the same reviewer and saves newly added PRs through the existing weekly-grading API. Saved entries are loaded again for the selected team and week after refresh. A frontend/backend pair counts as one reviewed entry.

Related PRs

Main changes explained

  • Updated the Add PR flow to check for a number already listed for the reviewer, including numbers inside a pair.
  • Added an error message for duplicate entries and failed saves. A PR is shown as added only after the save succeeds.
  • Added loading and merging of saved PRs with the screen’s existing sample reviewer data.
  • Updated custom test-team navigation so the team and week can be identified after refresh.
  • Added tests for duplicate checks, save/load behavior, failed saves, and reopening a custom team.
  • Saved grade changes through the weekly-grading API and restored them after refresh.
  • Sent both teamCode and teamName when saving for backend compatibility.

How to test

  1. Check out this PR branch, install dependencies if needed, and run the frontend and backend locally.
  2. Log in and open /pr-grading-test. Select a original to open the Weekly PR grading screen.
  3. Add a new PR number. Confirm it appears and the reviewed count increases by one.
  4. Refresh the page. Confirm the added PR number and count remain.
  5. Try adding that number again to the same reviewer. Confirm an error appears and the count does not increase.
  6. Add a new pair such as 9981 + 9982. Confirm it appears as one reviewed entry. Try reusing either number for that reviewer and confirm it is rejected.
  7. Change a PR’s grade, refresh the page, and confirm the new grade remains selected.
  8. Run the focused tests:
    node node_modules/vitest/vitest.mjs run src/components/PRGradingScreen/PRGradingScreen.duplicates.test.jsx src/components/PRGradingScreen/PRGradingScreenContainer.test.jsx src/components/PRGradingScreen/prGradingPersistence.test.js

Videos of changes

Recording.mp4

@netlify

netlify Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for highestgoodnetwork-dev ready!

Name Link
🔨 Latest commit f164f2d
🔍 Latest deploy log https://app.netlify.com/projects/highestgoodnetwork-dev/deploys/6ade4995e3c423f4f59a30a3
😎 Deploy Preview https://deploy-preview-5630--highestgoodnetwork-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

vidiyala99
vidiyala99 previously approved these changes Oct 7, 2026

@vidiyala99 vidiyala99 left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested c57b5ab as Administrator on /pr-grading-test → 91NePRT (Original), light mode. The vitest suites in PRGradingScreen/ pass (3 files, 11 tests). Saves to /weekly-grading/save were intercepted in the browser so nothing was written to the shared database.

What works:

  • Adding 3100 for Abi (already listed inside the pair 3100 + 1410) shows "This PR number has already been added for this reviewer." and the count stays at 8 (screenshot 1). 9999 + 3100 is rejected the same way.
  • Adding 9998 sends one save request and the count goes from 8 to 9 (screenshot 2).
  • When the save returns 500, 9997 is not added, the count stays at 9 and "Could not save this PR. Please try again." is shown (screenshot 2).

Suggestions (none blocking):

  1. Coordinate with OneCommunityGlobal/HGNRest#2286. This sends teamCode in the save body and team= on the GET, while that PR renames teamCode to teamName in the weekly-grading model and controller. Whichever merges second needs to match the other, or saves will fail.
  2. The stored prsReviewed includes the sample PRs. The request for 9998 was {"reviewer":"Abi","prsReviewed":9,"gradedPrs":[{"prNumbers":"9998"}]}: 9 counts the 8 sample entries that only exist in the frontend, while the saved record has 1 PR. The screen recalculates the count on load, so it looks right here, but anything else reading weeklyGradings gets a wrong number.
  3. The record is keyed by team name (pr-grading-screen:<teamName>). Renaming a custom team, or two custom teams with the same name, would lose or share saved PRs. The team _id would be a stable key.
  4. Only the add is saved. A grade changed after adding is still local, so after a refresh a saved PR is back to "Okay". Fine if that's planned for a follow-up, but worth saying in the description.
Image Image

@muthapriyanka muthapriyanka changed the title Prevent duplicate PR entries and retain added PRs Priyanka: Prevent duplicate PR entries and retain added PRs Oct 8, 2026
@muthapriyanka muthapriyanka added the High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible label Oct 14, 2026

@AaditTrivedi AaditTrivedi left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed by Aadit Trivedi.

The branch has merge conflicts with development in src/components/PRGradingScreen/PRGradingScreen.jsx and PRGradingScreen.module.css (checked with git merge-tree). Both files were changed by #5491 and #5493, which are now merged, so this PR needs to be rebuilt on top of their version of the grading screen.

When rebasing, please also check the open points from the PR Review Team dashboard status report: the task's "freeze reviewed PRs" part isn't covered, it filters on teamCode, which BE #2286 renames to teamName, and grade changes reportedly don't persist after a refresh.

Required action
Please update the branch with development and resolve the conflicts. Happy to test once it's updated.

AlekyaJogini
AlekyaJogini previously approved these changes Oct 16, 2026

@AlekyaJogini AlekyaJogini left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed by Alekya.

How I tested
Checked out the PR branch (commit 25d7dcf) on Node 20.19.4 with the backend on development. Ran the three focused test files (3 files, 16 tests pass). Logged in as my Admin test account and opened /pr-grading-test , 91NePRT (Original). After the screen loaded I set Chrome DevTools to Offline so no save could reach the shared database.

Verified working

  • Adding 2045 for Abi (already listed) shows "This PR number has already been added for this reviewer." and the count stays at 9.
Screenshot 2026-10-15 at 11 31 10 PM
  • Adding 3100 (part of the existing pair 3100 + 1410) is rejected the same way and the count stays at 9.
Screenshot 2026-10-15 at 11 32 01 PM
  • Adding a new number (9997) while the save fails shows "Could not save this PR. Please try again.", the number is not added and the count stays at 9.
Screenshot 2026-10-15 at 11 32 30 PM

Not tested

  • Adding a new pair (for example 9981 + 9982)

@rahulrubugunday rahulrubugunday left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally on Priyanka_pr_grading_duplicates_persistence at 25d7dcf as DevAdmin, with backend on development, on the weekly PR grading screen (91NePRT test team).

  • Added a test PR (9999) to a reviewer with no PRs. PR reviewed count went from 0 to 1 and matches the PR numbers listed.
  • Adding 9999 again for the same reviewer is blocked with "This PR number has already been added for this reviewer."
  • Changed the grade for 9999 from Okay to Exceptional.
  • After refreshing the page, 9999 is still in the reviewer's row and still graded Exceptional. PRs saved earlier by others also load correctly.

The fix works, but the branch has merge conflicts with development in PRGradingScreen.jsx and PRGradingScreen.module.css, so it can't be merged as is. Please resolve them and I'll re-test.

Requesting changes.

Image Image Image Image

@snehitakandula snehitakandula left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed on this PR's branch (pr-5630) at the latest commit 25d7dcf, frontend only, with backend on development. Tested as Admin on /pr-grading-test → 91NePRT (Original), focusing on the pair case listed as not tested in the earlier review.

Verified:

  1. Tests: npx vitest run src/components/PRGradingScreen passes (3 files, 16 tests).
  2. New pair counts as one entry: adding 9981 + 9982 for Lin Khant shows it as a single entry next to 2468, and the reviewed count is 2.
  3. Pair persists after refresh: 9981 + 9982 is still listed for Lin Khant after reloading the page.
  4. Numbers inside a pair are protected:
    • Adding 9981 alone is rejected with "This PR number has already been added for this reviewer."
    • Adding 9982 + 9983 is also rejected, since 9982 is already used in the existing pair.

Requesting changes: merge conflicts
GitHub reports conflicts in src/components/PRGradingScreen/PRGradingScreen.jsx and PRGradingScreen.module.css, from #5491 and #5493 (confirming @AaditTrivedi and @rahulrubugunday). Please rebuild on the latest development. The duplicate checks and persistence work as described, so they should carry over once rebased.

Screenshots:

Tests passing (16/16):
Image

Pair 9981 + 9982 added as one entry:
Image

9981 rejected as a duplicate:

Image

Requesting changes.

@iAbhi001
iAbhi001 self-requested a review October 18, 2026 02:48

@iAbhi001 iAbhi001 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally on branch pr-5630 (25d7dcf) frontend-only with backend on development as Admin on /pr-grading-test, focusing on the previously untested pair scenarios. All 16 unit tests across 3 files pass, adding a pair (9981 + 9982) correctly aggregates into a single reviewed entry, and the entry persists reliably across page reloads. Duplicate validation works as intended by blocking individual numbers from existing pairs as well as overlapping new pairs. However, requesting changes due to active merge conflicts with latest development from recent merges in the component and styling files; please rebase onto development to resolve the conflicts so this can proceed.

vidiyala99
vidiyala99 previously approved these changes Oct 21, 2026

@vidiyala99 vidiyala99 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed at e9f6097 (my earlier review was dismissed by the new commits).

Tested the Weekly PR grading screen in a browser in light and dark mode (the component rendered on its own with a mocked store). /weekly-grading and /weekly-grading/save were replaced by a small stateful mock that behaves like the HGNRest controller (rejects grades outside Unsatisfactory/Okay/Exceptional/No Correct Image, merges saved PRs per PR number), so nothing touched a real database. The vitest suites in PRGradingScreen/ pass (4 files, 28 tests).

Results:

  • Changing a grade now saves: 2200 to Exceptional and 4100 to Cannot find image both survive a refresh (screenshot 2).
  • Cannot find image is sent as No Correct Image (the backend enum value) and shown as Cannot find image again after reload. Before this commit that choice was never saved.
  • Adding 9998 for Abi saves and is still listed after refresh with the count at 3. Adding 3100 (already inside 3100 + 1410) shows "This PR number has already been added for this reviewer." and nothing is saved (screenshot 1).
  • When the save returns 500, "Could not save this grade. Please try again." is shown and the previous grade stays checked (screenshot 3).
  • The save body now carries both teamCode and teamName, so it keeps working whichever way HGNRest#2286 lands.

Dark mode (screenshot 4) renders the same state. The page wrapper is not part of my harness, so I only judged the grading panels themselves.

Still true from my first review, none blocking:

  1. The saved record is keyed by team name (pr-grading-screen:<teamName>), so two custom teams with the same name would share data. The team _id would be a stable key.
  2. prsReviewed in the saved record counts the sample PRs that only exist in the frontend (Abi's record said 3 with 2 stored PRs). The screen recalculates on load, so it looks right here, but anything else reading weeklyGradings gets the larger number.
1-after-actions-light 2-after-refresh-light 3-failed-grade-save-light 4-refresh-dark

@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants