diff --git a/lib/data-processing/generateMarkdown.ts b/lib/data-processing/generateMarkdown.ts index ede92fef..6ffd857f 100644 --- a/lib/data-processing/generateMarkdown.ts +++ b/lib/data-processing/generateMarkdown.ts @@ -178,6 +178,33 @@ export async function generateMarkdown( markdown += "- 💎 Incredible Comments: Exceptional participation with high-quality content\n\n" + // Generate Point Source Breakdown + markdown += "## Point Source Breakdown\n\n" + markdown += + "This table shows where each contributor's weekly score comes from:\n\n" + markdown += + "| Contributor | PR Points | Review Points | Discussion Points | Total Score | PR % | Review % | Discussion % |\n" + markdown += + "|-------------|-----------|---------------|-------------------|-------------|------|----------|-------------|\n" + + // Sort by total score + const sortedForBreakdown = Object.entries(contributorScores).sort( + (a, b) => b[1].score - a[1].score, + ) + + for (const [contributor, effort] of sortedForBreakdown) { + const total = effort.score || 0 + const prPct = + total > 0 ? ((effort.prPoints / total) * 100).toFixed(1) : "0.0" + const reviewPct = + total > 0 ? ((effort.reviewPoints / total) * 100).toFixed(1) : "0.0" + const discussionPct = + total > 0 ? ((effort.discussionPoints / total) * 100).toFixed(1) : "0.0" + + markdown += `| [${contributor}](#${contributor.replace(/\s/g, "-")}) | ${effort.prPoints} | ${effort.reviewPoints} | ${effort.discussionPoints} | ${total} | ${prPct}% | ${reviewPct}% | ${discussionPct}% |\n` + } + markdown += "\n" + // Generate Review Table markdown += "## Review Table\n\n" diff --git a/lib/scoring/getContributorScore.ts b/lib/scoring/getContributorScore.ts index d0825cb5..f11e9e27 100644 --- a/lib/scoring/getContributorScore.ts +++ b/lib/scoring/getContributorScore.ts @@ -23,6 +23,11 @@ export interface ContributorScore { rating5Count: number score: number + + // Point source breakdown + prPoints: number + reviewPoints: number + discussionPoints: number } /** @@ -48,6 +53,9 @@ export function getContributorScore({ rating3Count: 0, rating4Count: 0, rating5Count: 0, + prPoints: 0, + reviewPoints: 0, + discussionPoints: 0, } // Impact values for scoring @@ -72,7 +80,9 @@ export function getContributorScore({ result[`rating${pr.starRating}Count`]++ if (result[`rating${pr.starRating}Count`] <= 12) { - result.score += 2 ** ((pr.starRating ?? 0) - 1) + const prScore = 2 ** ((pr.starRating ?? 0) - 1) + result.score += prScore + result.prPoints += prScore } } @@ -101,6 +111,10 @@ export function getContributorScore({ } result.score += reviewPoints + result.reviewPoints = reviewPoints + + // Discussion points are currently 0 (not implemented yet) + result.discussionPoints = 0 return result } diff --git a/tests/__snapshots__/test-generate-markdown.test.ts.snap b/tests/__snapshots__/test-generate-markdown.test.ts.snap index 81369f95..2f440fd3 100644 --- a/tests/__snapshots__/test-generate-markdown.test.ts.snap +++ b/tests/__snapshots__/test-generate-markdown.test.ts.snap @@ -33,6 +33,15 @@ pie - 🔶 Great Informative Comments: Thoughtful participation that adds value - 💎 Incredible Comments: Exceptional participation with high-quality content +## Point Source Breakdown + +This table shows where each contributor's weekly score comes from: + +| Contributor | PR Points | Review Points | Discussion Points | Total Score | PR % | Review % | Discussion % | +|-------------|-----------|---------------|-------------------|-------------|------|----------|-------------| +| [alice](#alice) | 5 | 0 | 0 | 5 | 100.0% | 0.0% | 0.0% | +| [bob](#bob) | 2 | 0 | 0 | 2 | 100.0% | 0.0% | 0.0% | + ## Review Table [reviews-received-hover]: ## "Number of reviews received for PRs for this contributor" diff --git a/tests/test-generate-markdown.test.ts b/tests/test-generate-markdown.test.ts index f90288b4..6eed9717 100644 --- a/tests/test-generate-markdown.test.ts +++ b/tests/test-generate-markdown.test.ts @@ -157,6 +157,9 @@ describe("generateMarkdown", () => { expect(markdown).toContain("Fix bug Y") expect(markdown).toContain("Update docs") expect(markdown).toContain("Discussion Contribution Legend") + expect(markdown).toContain("Point Source Breakdown") + expect(markdown).toContain("PR Points") + expect(markdown).toContain("Review Points") expect(markdown).toContain("Repository Owners") expect(markdown).toContain("Repositories by Owner") expect(markdown).toMatchSnapshot("markdown")