Commit 696b6c9
Changed files (10)
src
all-badges
collect
src/all-badges/pr-collaboration/pr-collaboration-10.png
Binary file
src/all-badges/pr-collaboration/pr-collaboration-15.png
Binary file
src/all-badges/pr-collaboration/pr-collaboration-20.png
Binary file
src/all-badges/pr-collaboration/pr-collaboration-25.png
Binary file
src/all-badges/pr-collaboration/pr-collaboration-5.png
Binary file
src/all-badges/pr-collaboration/pr-collaboration.ts
@@ -0,0 +1,57 @@
+import { BadgePresenter, Present } from '../../badges.js'
+
+export default new (class implements BadgePresenter {
+ url = new URL(import.meta.url)
+ tiers = true
+ badges = [
+ 'pr-collaboration-5',
+ 'pr-collaboration-10',
+ 'pr-collaboration-15',
+ 'pr-collaboration-20',
+ 'pr-collaboration-25',
+ ] as const
+ present: Present = (data, grant) => {
+ for (const pull of data.pulls) {
+ if (pull.participants.totalCount >= 5) {
+ grant(
+ 'pr-collaboration-5',
+ 'I have participated in pull requests with 5 or more people',
+ )
+ .evidencePRsWithTitle(pull)
+ .tier(1)
+ }
+ if (pull.participants.totalCount >= 10) {
+ grant(
+ 'pr-collaboration-10',
+ 'I have participated in pull requests with 10 or more people',
+ )
+ .evidencePRsWithTitle(pull)
+ .tier(2)
+ }
+ if (pull.participants.totalCount >= 15) {
+ grant(
+ 'pr-collaboration-15',
+ 'I have participated in pull requests with 15 or more people',
+ )
+ .evidencePRsWithTitle(pull)
+ .tier(3)
+ }
+ if (pull.participants.totalCount >= 20) {
+ grant(
+ 'pr-collaboration-20',
+ 'I have participated in pull requests with 20 or more people',
+ )
+ .evidencePRsWithTitle(pull)
+ .tier(4)
+ }
+ if (pull.participants.totalCount >= 25) {
+ grant(
+ 'pr-collaboration-25',
+ 'I have participated in pull requests with 25 or more people',
+ )
+ .evidencePRsWithTitle(pull)
+ .tier(5)
+ }
+ }
+ }
+})()
src/all-badges/index.ts
@@ -14,4 +14,5 @@ export const allBadges = [
await import('./chore-commit/chore-commit.js'),
await import('./delorean/delorean.js'),
await import('./covid-19/covid-19.js'),
+ await import('./pr-collaboration/pr-collaboration.js'),
] as const
src/collect/pulls.graphql
@@ -15,6 +15,12 @@ query PullsQuery($username: String!, $num: Int = 100, $cursor: String) {
}
name
}
+ participants(first: 20) {
+ totalCount
+ nodes {
+ login
+ }
+ }
}
pageInfo {
hasNextPage
src/collect/pulls.ts
@@ -15,6 +15,12 @@ export type PullsQuery = {
}
name: string
}
+ participants: {
+ totalCount: number
+ nodes: Array<{
+ login: string
+ }>
+ }
}>
}
pageInfo: {
src/badges.ts
@@ -83,4 +83,12 @@ class Evidence {
)
return this
}
+
+ evidencePRsWithTitle(...pulls: Pull[]) {
+ this.evidence(
+ 'Pull requests:\n\n' +
+ pulls.map((x) => `- ${linkPull(x)}: ${x.title}`).join('\n'),
+ )
+ return this
+ }
}