Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions lib/data-processing/generateMarkdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
16 changes: 15 additions & 1 deletion lib/scoring/getContributorScore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ export interface ContributorScore {
rating5Count: number

score: number

// Point source breakdown
prPoints: number
reviewPoints: number
discussionPoints: number
}

/**
Expand All @@ -48,6 +53,9 @@ export function getContributorScore({
rating3Count: 0,
rating4Count: 0,
rating5Count: 0,
prPoints: 0,
reviewPoints: 0,
discussionPoints: 0,
}

// Impact values for scoring
Expand All @@ -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
}
}

Expand Down Expand Up @@ -101,6 +111,10 @@ export function getContributorScore({
}

result.score += reviewPoints
result.reviewPoints = reviewPoints

// Discussion points are currently 0 (not implemented yet)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not implemented???

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

about that i was a little confused, the current scoring system isnt accounting for discussion points right? thats sort of why i have set it to 0?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

result.discussionPoints = 0

return result
}
9 changes: 9 additions & 0 deletions tests/__snapshots__/test-generate-markdown.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions tests/test-generate-markdown.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down