Skip to content

Commit

Permalink
Add iteration for update (#291)
Browse files Browse the repository at this point in the history
  • Loading branch information
iterion authored Sep 11, 2023
1 parent 07276c7 commit a0406a9
Show file tree
Hide file tree
Showing 9 changed files with 3,513 additions and 3,048 deletions.
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nodejs 16.20.1
nodejs 20.6.1
3,169 changes: 1,815 additions & 1,354 deletions dist/weekly-contributions/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/weekly-contributions/index.js.map

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions dist/weekly-contributions/licenses.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/weekly-contributions/sourcemap-register.js

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@
"yarn": "^1.22.19"
},
"devDependencies": {
"@types/node": "^16.10.5",
"@typescript-eslint/parser": "^6.3.0",
"@vercel/ncc": "^0.31.1",
"eslint": "^8.46.0",
"eslint-plugin-github": "^4.9.2",
"eslint-plugin-jest": "^27.2.3",
"eslint-plugin-prettier": "^5.0.0",
"@types/node": "^20.1",
"@typescript-eslint/parser": "^6.3",
"@vercel/ncc": "^0.38",
"eslint": "^8",
"eslint-plugin-github": "^4",
"eslint-plugin-jest": "^27",
"eslint-plugin-prettier": "^5",
"jest": "^27.2.5",
"js-yaml": "^4.1.0",
"prettier": "^3.0.1",
Expand Down
112 changes: 58 additions & 54 deletions src/weekly-contributions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,32 +49,6 @@ async function main() {
.map(({name}) => name)
.filter(name => !name.startsWith('_'))

const prsResponse: {
[repoName: string]: {
pullRequests: {
nodes: {
author: {
login: string
}
repository: {
name: string
id: string
}
state: PRStates
number: number
title: string
url: string
updatedAt: string
}[]
}
}
} = await octokit.graphql(
`
query{
${repos.map(makeInnerPRQuery).join('\n')}
}
`
)
interface PRGroupedByAuthor {
[login: string]: {
PRs: {
Expand All @@ -93,37 +67,67 @@ async function main() {
}
const prGroupedByAuthor: PRGroupedByAuthor = {}
const PRsToGetCommentsFor: {repo: string; PRNum: number}[] = []
Object.values(prsResponse).forEach(repo => {
repo.pullRequests.nodes.forEach(
({author, repository, state, url, title, updatedAt, number}) => {
const login = author.login
if (login === 'dependabot') return
if (cutOffDate.valueOf() > new Date(updatedAt).valueOf()) return
if (!prGroupedByAuthor[login]) {
prGroupedByAuthor[login] = {
PRs: [],
PRComments: [],
issuesOpened: [],
issuesClosed: [],
issuesComments: []
}
const chunkSize = 25
for (let i = 0; i < repos.length; i += chunkSize) {
const reposChunk = repos.slice(i, i + chunkSize)
const prsResponse: {
[repoName: string]: {
pullRequests: {
nodes: {
author: {
login: string
}
repository: {
name: string
id: string
}
state: PRStates
number: number
title: string
url: string
updatedAt: string
}[]
}
prGroupedByAuthor[login].PRs.push({
repo: repository.name,
number,
author: author.login,
url,
state,
title
})

PRsToGetCommentsFor.push({
repo: repository.name,
PRNum: number
})
}
} = await octokit.graphql(
`
query{
${reposChunk.map(makeInnerPRQuery).join('\n')}
}
`
)
})
Object.values(prsResponse).forEach(repo => {
repo.pullRequests.nodes.forEach(
({author, repository, state, url, title, updatedAt, number}) => {
const login = author.login
if (login === 'dependabot') return
if (cutOffDate.valueOf() > new Date(updatedAt).valueOf()) return
if (!prGroupedByAuthor[login]) {
prGroupedByAuthor[login] = {
PRs: [],
PRComments: [],
issuesOpened: [],
issuesClosed: [],
issuesComments: []
}
}
prGroupedByAuthor[login].PRs.push({
repo: repository.name,
number,
author: author.login,
url,
state,
title
})

PRsToGetCommentsFor.push({
repo: repository.name,
PRNum: number
})
}
)
})
}

const commentsResponse: {
[repo: string]: {
Expand Down
2 changes: 1 addition & 1 deletion weekly-contributions/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ outputs:
markdown:
description: Output summary
runs:
using: 'node16'
using: 'node20'
main: '../dist/weekly-contributions/index.js'
Loading

0 comments on commit a0406a9

Please sign in to comment.