Skip to content

Commit

Permalink
Merge pull request #113 from mntnr/pr-titles
Browse files Browse the repository at this point in the history
feat(queries): add titles for PRs and issues
  • Loading branch information
Berkmann18 authored May 26, 2023
2 parents 8445110 + fc777aa commit 0dd24f9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
6 changes: 5 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,11 @@ $ name-your-contributors -u mntnr -r name-your-contributors --after 2017-11-10
"login": "RichardLitt",
"name": "Richard Littauer",
"url": "https://github.com/RichardLitt",
"count": 1
"count": 1,
"titles": [
"Add example output to the README",
"Get email for users"
]
}
],
"issueCommentators": [
Expand Down
4 changes: 3 additions & 1 deletion src/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ const mergeExtendedContributions = xs => {
labels.forEach(label => p.labels.add(label))
}
p.count += x.count
p.titles.push(x.title)
} else {
m.set(key, {
// Poor man's clone
Expand All @@ -198,7 +199,8 @@ const mergeExtendedContributions = xs => {
url: x.author.url,
count: x.count,
email: x.author.email,
labels: new Set(labels)
labels: new Set(labels),
titles: [x.title]
})
}
}
Expand Down
14 changes: 7 additions & 7 deletions test/queries-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ test('merge', t => {
})

test('extended merge', t => {
const testusers = [{ author: { login: 'x', name: 'x', url: 'x' }, count: 1, labels: { nodes: [{ name: 'a' }] } },
{ author: { login: 'y', name: 'x', url: 'x' }, count: 1, labels: { nodes: [] } },
{ author: { login: 'x', name: 'x', url: 'x' }, count: 3, labels: { nodes: [{ name: 'b' }] } },
{ author: { login: 'z', name: 'x', url: 'x' }, count: 2, labels: { nodes: [{ name: 'c' }] } }]
const testusers = [{ author: { login: 'x', name: 'x', url: 'x' }, count: 1, labels: { nodes: [{ name: 'a' }] }, title: 'c' },
{ author: { login: 'y', name: 'x', url: 'x' }, count: 1, labels: { nodes: [] }, title: 'v' },
{ author: { login: 'x', name: 'x', url: 'x' }, count: 3, labels: { nodes: [{ name: 'b' }] }, title: 'b' },
{ author: { login: 'z', name: 'x', url: 'x' }, count: 2, labels: { nodes: [{ name: 'c' }] }, title: 'n' }]

t.deepEqual(q.mergeExtendedContributions(testusers), [
{ login: 'x', count: 4, name: 'x', url: 'x', email: undefined, labels: ['a', 'b'] },
{ login: 'y', count: 1, name: 'x', url: 'x', email: undefined, labels: [] },
{ login: 'z', count: 2, name: 'x', url: 'x', email: undefined, labels: ['c'] }
{ login: 'x', count: 4, name: 'x', url: 'x', email: undefined, labels: ['a', 'b'], titles: ['c', 'b'] },
{ login: 'y', count: 1, name: 'x', url: 'x', email: undefined, labels: [], titles: ['v'] },
{ login: 'z', count: 2, name: 'x', url: 'x', email: undefined, labels: ['c'], titles: ['n'] }
])
})

Expand Down

0 comments on commit 0dd24f9

Please sign in to comment.