Skip to content

Commit

Permalink
Accept more than 100 events in activity plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
lowlighter committed May 5, 2021
1 parent a06ba37 commit f9aa59b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 11 additions & 1 deletion source/plugins/activity/index.mjs
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion source/plugins/activity/metadata.yml
Expand Up @@ -20,9 +20,10 @@ inputs:
type: number
default: 5
min: 1
max: 100
max: 1000

# Filter events by age
# Note that it only filter fetched events, you may need to increase "plugin_activity_limit" to display older events
# Set to 0 to disable age filtering
plugin_activity_days:
description: Maximum event age
Expand Down

0 comments on commit f9aa59b

Please sign in to comment.