feat(maintainer): add composite trust score badge#659
Conversation
|
@RutujaGharat-11 is attempting to deploy a commit to the codersogs-3057's projects Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Pull request overview
This PR introduces a single composite “Trust {score}” badge for PR authors in the maintainer queue by adding a server-computed trust score derived from author level, XP, merged PR count, and account age.
Changes:
- Added
computeTrustScore()utility (0–100) with unit tests validating normalization, weighting, and rounding. - Computed and attached
authorTrustScoreserver-side when building maintainer queue rows and CSV export rows. - Updated the maintainer dashboard UI to render one “Trust {score}” badge instead of separate Level/XP/Merged indicators.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/lib/maintainer/trust.ts | Adds pure trust-score computation utility with a weighted formula. |
| src/lib/maintainer/trust.test.ts | Adds unit tests for the trust-score utility. |
| src/lib/maintainer/queue.ts | Extends MaintainerPrRow to include authorTrustScore. |
| src/lib/maintainer/queue.test.ts | Updates queue test helpers for the new row shape. |
| src/app/actions/maintainer/queue.ts | Computes and populates authorTrustScore for queue rows from profile + derived metrics. |
| src/app/actions/maintainer/analytics.ts | Computes and populates authorTrustScore for CSV export rows. |
| src/app/(app)/maintainer/page.tsx | Updates UI to display a single “Trust {score}” badge. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Normalize inputs to [0, 1] range | ||
| const normLevel = Math.min(Math.max(0, level) / 5, 1); | ||
| const normXp = Math.min(Math.max(0, xp) / 5000, 1); | ||
| const normMergedPrs = Math.min(Math.max(0, mergedPrs) / 10, 1); | ||
| const normAccountAge = Math.min(Math.max(0, accountAgeDays) / 90, 1); | ||
|
|
||
| // Apply weights | ||
| const score = normLevel * 40 + normXp * 20 + normMergedPrs * 30 + normAccountAge * 10; |
| it('should return 0 for zero or negative values', () => { | ||
| expect(computeTrustScore(0, 0, 0, 0)).toBe(0); | ||
| expect(computeTrustScore(-1, -100, -5, -10)).toBe(0); | ||
| }); |
| const createdTime = p.created_at ? new Date(p.created_at).getTime() : Date.now(); | ||
| const accountAgeDays = Math.max( | ||
| 0, | ||
| Math.floor((Date.now() - createdTime) / (1000 * 60 * 60 * 24)), | ||
| ); |
| const createdTime = p.created_at ? new Date(p.created_at).getTime() : Date.now(); | ||
| const accountAgeDays = Math.max( | ||
| 0, | ||
| Math.floor((Date.now() - createdTime) / (1000 * 60 * 60 * 24)), | ||
| ); |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
can you please fix the conflict |
|
@RutujaGharat-11 please solve the merge conflict please |
|
@RutujaGharat-11 this is the last time i am reminding u that this PR got merge conflict issue please solve it , if not done then we have to close this PR unfortunately |
Summary
Implements a composite Trust Score badge for PR authors.
Changes
computeTrustScore()utility with a weighted scoring formula.authorTrustScoreto the maintainer queue model.Trust {score}badge instead of separate Level, XP, and Merged PR indicators.Closes #454