fix: use authoritative metrics in progression pipeline - #10
Merged
Merged
Conversation
- Implemented getContributorMetrics in src/lib/metrics/contributor-metrics.ts - Authoritatively computes merged contributions on official approved projects - Strictly excludes self-reviews, dismissed reviews, and non-approved repositories - Deduplicates multiple review events on the same pull request - Connected getContributorMetrics to progression evaluation pipeline and work dashboard - Added full unit test coverage for zero metrics, contributor/active/core thresholds, self-review exclusion, and dismissed reviews
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.
Summary
Replaced ad-hoc and incomplete metric evaluation in
src/lib/progression/pipeline.tswith a dedicated, authoritativegetContributorMetrics(userId, db)function located insrc/lib/metrics/contributor-metrics.ts.Why
Previously,
pipeline.tsevaluated progression using hardcoded dummy counts:This prevented contributors who legitimately resolved issues and completed peer code reviews from ever advancing to Core Contributor status. Furthermore, metric calculation was duplicated between the progression pipeline and dashboard views.
Changes
getContributorMetrics(userId, db)insrc/lib/metrics/contributor-metrics.ts:isOfficial: true,contributionEnabled: true,approvedAt IS NOT NULL).issueClaims(status = 'completed').approved/changes_requested), and deduplicates multiple review events on the same PR.src/lib/progression/pipeline.tsto consumegetContributorMetricsand log verified metric counts into promotion audit records.src/app/dashboard/work/page.tsxto usegetContributorMetricsso the contributor workspace displays the exact same authoritative progression metrics.src/lib/metrics/contributor-metrics.test.tsverifying zero counts, contributor promotion, active contributor promotion, core contributor advancement, self-review exclusion, duplicate review deduplication, and unapproved repository rejection.Tests
npm test: 17 passed / 17 test files, 68 / 68 tests passingnpx tsc --noEmit: 0 errorsnpm run lint: 0 errors, 0 warningsnpm run build: 19 / 19 routes generated cleanlyMigration
Risk
Low. Refactors metric calculations to an authoritative server-side helper with strict data integrity rules and full test coverage.
Verification