feat(plugins/lines): add plugin_lines_delay to mitigate first query results (#1530)
This commit is contained in:
@@ -7,7 +7,7 @@ export default async function({login, data, imports, rest, q, account}, {enabled
|
|||||||
return null
|
return null
|
||||||
|
|
||||||
//Load inputs
|
//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"])
|
skipped.push(...data.shared["repositories.skipped"])
|
||||||
|
|
||||||
//Context
|
//Context
|
||||||
@@ -25,9 +25,16 @@ export default async function({login, data, imports, rest, q, account}, {enabled
|
|||||||
//Get contributors stats from repositories
|
//Get contributors stats from repositories
|
||||||
console.debug(`metrics/compute/${login}/plugins > lines > querying api`)
|
console.debug(`metrics/compute/${login}/plugins > lines > querying api`)
|
||||||
const repos = {}, weeks = {}
|
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((
|
let response = []
|
||||||
{value},
|
for (let i = 0; i < (delay ? 2 : 1); i++) {
|
||||||
) => value)
|
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
|
//Compute changed lines
|
||||||
console.debug(`metrics/compute/${login}/plugins > lines > computing total diff`)
|
console.debug(`metrics/compute/${login}/plugins > lines > computing total diff`)
|
||||||
|
|||||||
@@ -63,4 +63,18 @@ inputs:
|
|||||||
Will display the last `n` years, relative to current year
|
Will display the last `n` years, relative to current year
|
||||||
type: number
|
type: number
|
||||||
default: 1
|
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
|
zero: disable
|
||||||
2
source/templates/classic/style.css
vendored
2
source/templates/classic/style.css
vendored
@@ -891,7 +891,7 @@
|
|||||||
font-family: SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;
|
font-family: SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
white-space: pre;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
.added {
|
.added {
|
||||||
color: rgb(63, 185, 80);
|
color: rgb(63, 185, 80);
|
||||||
|
|||||||
Reference in New Issue
Block a user