diff --git a/source/plugins/lines/index.mjs b/source/plugins/lines/index.mjs index 1888c6cc..fa0f35b2 100644 --- a/source/plugins/lines/index.mjs +++ b/source/plugins/lines/index.mjs @@ -7,7 +7,7 @@ export default async function({login, data, imports, rest, q, account}, {enabled return null //Load inputs - let {skipped, sections, "repositories.limit": _repositories_limit, "history.limit": _history_limit} = imports.metadata.plugins.lines.inputs({data, account, q}) + let {skipped, sections, "repositories.limit": _repositories_limit, "history.limit": _history_limit, delay} = imports.metadata.plugins.lines.inputs({data, account, q}) skipped.push(...data.shared["repositories.skipped"]) //Context @@ -25,9 +25,16 @@ export default async function({login, data, imports, rest, q, account}, {enabled //Get contributors stats from repositories console.debug(`metrics/compute/${login}/plugins > lines > querying api`) const repos = {}, weeks = {} - const response = [...await Promise.allSettled(repositories.map(async ({repo, owner}) => imports.filters.repo(`${owner}/${repo}`, skipped) ? {handle: `${owner}/${repo}`, stats: (await rest.repos.getContributorsStats({owner, repo})).data} : {}))].filter(({status}) => status === "fulfilled").map(( - {value}, - ) => value) + let response = [] + for (let i = 0; i < (delay ? 2 : 1); i++) { + response = [...await Promise.allSettled(repositories.map(async ({repo, owner}) => imports.filters.repo(`${owner}/${repo}`, skipped) ? {handle: `${owner}/${repo}`, stats: (await rest.repos.getContributorsStats({owner, repo})).data} : {}))].filter(({status}) => status === "fulfilled").map(( + {value}, + ) => value) + if (delay) { + console.debug(`metrics/compute/${login}/plugins > lines > waiting ${delay}s while waiting for contributor stats to be updated`) + await new Promise(resolve => setTimeout(resolve, delay*1000)) + } + } //Compute changed lines console.debug(`metrics/compute/${login}/plugins > lines > computing total diff`) diff --git a/source/plugins/lines/metadata.yml b/source/plugins/lines/metadata.yml index ace65be5..68dfd223 100644 --- a/source/plugins/lines/metadata.yml +++ b/source/plugins/lines/metadata.yml @@ -63,4 +63,18 @@ inputs: Will display the last `n` years, relative to current year type: number default: 1 + zero: disable + + plugin_lines_delay: + description: | + Delay before performing a second query + + When non-zero, will perform a second query after specified delay (in seconds). + The GitHub endpoint used may return inaccurate results on first query (these values seems to be cached on the fly), + after returning correct results upon performing another query. + + Using this option may mitigate the occurrence of weird values. + type: number + default: 0 + min: 0 zero: disable \ No newline at end of file diff --git a/source/templates/classic/style.css b/source/templates/classic/style.css index 441efa65..f4b8e51a 100644 --- a/source/templates/classic/style.css +++ b/source/templates/classic/style.css @@ -891,7 +891,7 @@ font-family: SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace; font-weight: bold; font-size: 12px; - white-space: pre; + white-space: nowrap; } .added { color: rgb(63, 185, 80);