Accept more than 100 events in activity plugin

This commit is contained in:
lowlighter
2021-05-05 23:05:45 +02:00
parent a06ba37c3b
commit f9aa59b3d5
2 changed files with 13 additions and 2 deletions

View File

@@ -19,11 +19,21 @@ export default async function({login, data, rest, q, account, imports}, {enabled
if (!days)
days = Infinity
skipped.push(...data.shared["repositories.skipped"])
const pages = Math.ceil(limit/100)
const codelines = 2
//Get user recent activity
console.debug(`metrics/compute/${login}/plugins > activity > querying api`)
const {data:events} = context.mode === "repository" ? await rest.activity.listRepoEvents({owner:context.owner, repo:context.repo}) : await rest.activity.listEventsForAuthenticatedUser({username:login, per_page:100})
const events = []
try {
for (let page = 1; page <= pages; page++) {
console.debug(`metrics/compute/${login}/plugins > activity > loading page ${page}`)
events.push(...(context.mode === "repository" ? await rest.activity.listRepoEvents({owner:context.owner, repo:context.repo}) : await rest.activity.listEventsForAuthenticatedUser({username:login, per_page:100})).data)
}
}
catch {
console.debug(`metrics/compute/${login}/plugins > activity > no more page to load`)
}
console.debug(`metrics/compute/${login}/plugins > activity > ${events.length} events loaded`)
//Extract activity events