Skip to content

Anushka - PR Review Team Admin Dashboard – Remove Reviewer should hide reviewers, not delete them - #2461

Open
anushkaadwivedii wants to merge 1 commit into
developmentfrom
anushka/hide-removed-reviewers
Open

anushkaadwivedii wants to merge 1 commit into
developmentfrom
anushka/hide-removed-reviewers

Conversation

@anushkaadwivedii

@anushkaadwivedii anushkaadwivedii commented Nov 4, 2026 •

Copy link
Copy Markdown

Description

Removing a reviewer currently permanently deletes a weekly grading document. This change hides the selected team's reviewer for the selected week while retaining their graded PRs, review counts, version history, and other weeks' records.

Implements task 45 in the PR Review Team Admin and Analytics Dashboard document (HGN task 1587).
Source: https://docs.google.com/document/d/11KglDgr_l3-8NdTLMGfu6YGmpGj-BSip_LD8IQbCtp8/edit

Original task

00-original-task

Related PRS (if any):

Main changes explained:

  • Add isRemoved, removedAt, and removedBy to the weekly grading model.
  • Replace permanent deletion with a scoped update of all matching reviewer snapshots for the selected team/week.
  • Filter removed entries from grading-page responses, including legacy records that predate the new flag.
  • Preserve graded PRs, counts, version history, other reviewers, teams, and weeks. No global model filter is added, so historical/reporting queries retain access to removed records.
  • Keep accessPRTeamDashboard authorization and authenticated requestor auditing.
  • Share a UTC week range between GET and removal so server timezone/DST cannot shift the selected week boundaries.
  • Add router/database regression coverage including duplicate snapshots, repeated removals, stale saves, audit data, JWT authentication, and actual permission checks.

How to test:

  1. Check out this branch and install the repository dependencies.
  2. Run the weeklyGradingController unit/integration tests and weeklyGradingRouter test. The integration tests start their own disposable MongoDB server; do not point them at a shared database.
  3. On a local frontend/backend with disposable fixture data, open /pr-grading-dashboard with accessPRTeamDashboard permission.
  4. Seed a reviewer in the current week and a previous week, plus another reviewer. Confirm Cancel leaves the first reviewer visible.
  5. Remove the first reviewer for the current week. Refresh the page: only the other reviewer remains in that week.
  6. Select the previous week: the original reviewer and their graded PRs remain visible.
  7. Inspect the database: the selected-week document still exists with grades/history intact, isRemoved: true, a removal timestamp, and the authenticated remover ID.
  8. Confirm the analytics endpoint returns the same seeded insight data after removal.
  9. Repeat as a user without permission: removal returns 403 and the data remains unchanged. Repeating a successful removal returns 404 without rewriting the original audit timestamp.

Screenshots or videos of changes:

Before removal

01-before-removal

Hidden after refresh

02-hidden-after-refresh

Previous week retained

03-previous-week-retained

Records and PRs retained

04-records-and-prs-retained

Dark-mode confirmation

05-dark-mode-confirmation

Dark mode after refresh

06-dark-mode-after-refresh

Validation

  • 28/28 focused tests pass using real disposable MongoDB, real application JWT middleware, routes, models, and permission checks.
  • Tests pass in Pacific and UTC timezones; all 28 also pass on the required Node v20.19.4.
  • Prettier passes for all four changed files.
  • Changed controller/model coverage: 96.94% statements, 89.18% branches, 100% functions, 96.87% lines in the final Pacific run.
  • Original controller fails five of the new regression cases; fixed controller passes all ten integration cases.
  • Changed files: ESLint 0 errors (2 warnings); git diff --check passes.
  • Browser verification uses the unchanged frontend grading component from development commit 78e13192a, wired to the local fixed backend with disposable fixtures. Cancel, Remove, refresh persistence, and previous-week visibility were exercised. Removal and refresh persistence also passed with the existing dark-mode theme enabled.

Note:

Existing records need no migration: a missing removal flag is treated as visible. The API path and successful removal response stay compatible with the frontend. This change cannot recover documents already permanently deleted before deployment.

@sonarqubecloud

sonarqubecloud Bot commented Nov 4, 2026

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant