From 586d44923f8dfc47a19d7bba76a8de1f52651405 Mon Sep 17 00:00:00 2001 From: lowlighter <22963968+lowlighter@users.noreply.github.com> Date: Mon, 2 Aug 2021 10:21:39 +0200 Subject: [PATCH 1/2] Base: load all commits rather than only last year --- source/plugins/base/index.mjs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/source/plugins/base/index.mjs b/source/plugins/base/index.mjs index b0196af5902..40035ebf222 100644 --- a/source/plugins/base/index.mjs +++ b/source/plugins/base/index.mjs @@ -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}) @@ -49,6 +49,15 @@ 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 {} + } //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} From b6814fde112cc9c372cbd6544e97802e706ac54f Mon Sep 17 00:00:00 2001 From: lowlighter <22963968+lowlighter@users.noreply.github.com> Date: Mon, 2 Aug 2021 10:27:04 +0200 Subject: [PATCH 2/2] Update index.mjs --- source/plugins/base/index.mjs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/plugins/base/index.mjs b/source/plugins/base/index.mjs index 40035ebf222..6d09256eeef 100644 --- a/source/plugins/base/index.mjs +++ b/source/plugins/base/index.mjs @@ -56,7 +56,9 @@ export default async function({login, graphql, rest, data, q, queries, imports}, 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 {} + 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"})