master
1import { define, PullRequest } from '#src'
2
3export default define({
4 url: import.meta.url,
5 tiers: true,
6 badges: [
7 'pr-collaboration-5',
8 'pr-collaboration-10',
9 'pr-collaboration-15',
10 'pr-collaboration-20',
11 'pr-collaboration-25',
12 ] as const,
13 present(data, grant) {
14 for (const pull of data.pulls.sort(byParticipantsCount)) {
15 if (pull.participants.totalCount >= 5) {
16 grant(
17 'pr-collaboration-5',
18 'I have participated in pull requests with 5 or more people',
19 )
20 .evidencePRsWithTitle(pull)
21 .tier(1)
22 }
23 if (pull.participants.totalCount >= 10) {
24 grant(
25 'pr-collaboration-10',
26 'I have participated in pull requests with 10 or more people',
27 )
28 .evidencePRsWithTitle(pull)
29 .tier(2)
30 }
31 if (pull.participants.totalCount >= 15) {
32 grant(
33 'pr-collaboration-15',
34 'I have participated in pull requests with 15 or more people',
35 )
36 .evidencePRsWithTitle(pull)
37 .tier(3)
38 }
39 if (pull.participants.totalCount >= 20) {
40 grant(
41 'pr-collaboration-20',
42 'I have participated in pull requests with 20 or more people',
43 )
44 .evidencePRsWithTitle(pull)
45 .tier(4)
46 }
47 if (pull.participants.totalCount >= 25) {
48 grant(
49 'pr-collaboration-25',
50 'I have participated in pull requests with 25 or more people',
51 )
52 .evidencePRsWithTitle(pull)
53 .tier(5)
54 }
55 }
56 },
57})
58
59function byParticipantsCount(a: PullRequest, b: PullRequest) {
60 return a.participants.totalCount - b.participants.totalCount
61}