Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Base: load all commits rather than only last year #440

Merged
merged 2 commits into from
Aug 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion source/plugins/base/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

//Setup
export default async function({login, graphql, data, q, queries, imports}, conf) {
export default async function({login, graphql, rest, data, q, queries, imports}, conf) {
//Load inputs
console.debug(`metrics/compute/${login}/base > started`)
let {repositories, "repositories.forks":_forks, "repositories.affiliations":_affiliations, "repositories.batch":_batch} = imports.metadata.plugins.base.inputs({data, q, account:"bypass"}, {repositories:conf.settings.repositories ?? 100})
Expand Down Expand Up @@ -49,6 +49,17 @@ export default async function({login, graphql, data, q, queries, imports}, conf)
data.user[type].nodes.splice(repositories)
console.debug(`metrics/compute/${login}/base > loaded ${data.user[type].nodes.length} ${type}`)
}
//For user accounts, attempt to load whole commit history rather than last year
if (account === "user") {
try {
console.debug(`metrics/compute/${login}/base > loading user commits history`)
const {data:{total_count:total = 0}} = await rest.search.commits({q:`author:${login}`})
data.user.contributionsCollection.totalCommitContributions = Math.max(total, data.user.contributionsCollection.totalCommitContributions)
}
catch {
console.debug(`metrics/compute/${login}/base > falling back to last year commits history`)
}
}
//Shared options
let {"repositories.skipped":skipped, "commits.authoring":authoring} = imports.metadata.plugins.base.inputs({data, q, account:"bypass"})
data.shared = {"repositories.skipped":skipped, "commits.authoring":authoring, "repositories.batch":_batch}
Expand Down