fix(plugins/languages): improved timeout messages (#1004) [skip ci]
This commit is contained in:
@@ -3,11 +3,18 @@ import linguist from "linguist-js"
|
|||||||
|
|
||||||
/**Indepth analyzer */
|
/**Indepth analyzer */
|
||||||
export async function indepth({login, data, imports, repositories, gpg}, {skipped, categories, timeout}) {
|
export async function indepth({login, data, imports, repositories, gpg}, {skipped, categories, timeout}) {
|
||||||
return new Promise(async (solve, reject) => {
|
return new Promise(async solve => {
|
||||||
|
//Results
|
||||||
|
const results = {partial:false, total:0, lines:{}, stats:{}, colors:{}, commits:0, files:0, missed:{lines:0, bytes:0, commits:0}, verified:{signature:0}}
|
||||||
|
|
||||||
//Timeout
|
//Timeout
|
||||||
if (Number.isFinite(timeout)) {
|
if (Number.isFinite(timeout)) {
|
||||||
console.debug(`metrics/compute/${login}/plugins > languages > timeout set to ${timeout}m`)
|
console.debug(`metrics/compute/${login}/plugins > languages > timeout set to ${timeout}m`)
|
||||||
setTimeout(() => reject(`Reached maximum execution time of ${timeout}m for analysis`), timeout * 60 * 1000)
|
setTimeout(() => {
|
||||||
|
results.partial = true
|
||||||
|
console.debug(`metrics/compute/${login}/plugins > languages > reached maximum execution time of ${timeout}m for analysis`)
|
||||||
|
solve(results)
|
||||||
|
}, timeout * 60 * 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
//GPG keys imports
|
//GPG keys imports
|
||||||
@@ -35,8 +42,11 @@ export async function indepth({login, data, imports, repositories, gpg}, {skippe
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Compute repositories stats from fetched repositories
|
//Compute repositories stats from fetched repositories
|
||||||
const results = {total:0, lines:{}, stats:{}, colors:{}, commits:0, files:0, missed:{lines:0, bytes:0, commits:0}, verified:{signature:0}}
|
|
||||||
for (const repository of repositories) {
|
for (const repository of repositories) {
|
||||||
|
//Early break
|
||||||
|
if (results.partial)
|
||||||
|
break
|
||||||
|
|
||||||
//Skip repository if asked
|
//Skip repository if asked
|
||||||
if ((skipped.includes(repository.name.toLocaleLowerCase())) || (skipped.includes(`${repository.owner.login}/${repository.name}`.toLocaleLowerCase()))) {
|
if ((skipped.includes(repository.name.toLocaleLowerCase())) || (skipped.includes(`${repository.owner.login}/${repository.name}`.toLocaleLowerCase()))) {
|
||||||
console.debug(`metrics/compute/${login}/plugins > languages > skipped repository ${repository.owner.login}/${repository.name}`)
|
console.debug(`metrics/compute/${login}/plugins > languages > skipped repository ${repository.owner.login}/${repository.name}`)
|
||||||
@@ -77,16 +87,24 @@ export async function indepth({login, data, imports, repositories, gpg}, {skippe
|
|||||||
|
|
||||||
/**Recent languages activity */
|
/**Recent languages activity */
|
||||||
export async function recent({login, data, imports, rest, account}, {skipped = [], categories, days = 0, load = 0, tempdir = "recent", timeout}) {
|
export async function recent({login, data, imports, rest, account}, {skipped = [], categories, days = 0, load = 0, tempdir = "recent", timeout}) {
|
||||||
return new Promise(async (solve, reject) => {
|
return new Promise(async solve => {
|
||||||
|
//Results
|
||||||
|
const results = {partial:false, total:0, lines:{}, stats:{}, colors:{}, commits:0, files:0, missed:{lines:0, bytes:0, commits:0}, days}
|
||||||
|
|
||||||
//Timeout
|
//Timeout
|
||||||
if (Number.isFinite(timeout)) {
|
if (Number.isFinite(timeout)) {
|
||||||
console.debug(`metrics/compute/${login}/plugins > languages > timeout set to ${timeout}m`)
|
console.debug(`metrics/compute/${login}/plugins > languages > timeout set to ${timeout}m`)
|
||||||
setTimeout(() => reject(`Reached maximum execution time of ${timeout}m for analysis`), timeout * 60 * 1000)
|
setTimeout(() => {
|
||||||
|
results.partial = true
|
||||||
|
console.debug(`metrics/compute/${login}/plugins > languages > reached maximum execution time of ${timeout}m for analysis`)
|
||||||
|
solve(results)
|
||||||
|
return
|
||||||
|
}, timeout * 60 * 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get user recent activity
|
//Get user recent activity
|
||||||
console.debug(`metrics/compute/${login}/plugins > languages > querying api`)
|
console.debug(`metrics/compute/${login}/plugins > languages > querying api`)
|
||||||
const commits = [], pages = Math.ceil(load / 100), results = {total:0, lines:{}, stats:{}, colors:{}, commits:0, files:0, missed:{lines:0, bytes:0, commits:0}, days}
|
const commits = [], pages = Math.ceil(load / 100)
|
||||||
try {
|
try {
|
||||||
for (let page = 1; page <= pages; page++) {
|
for (let page = 1; page <= pages; page++) {
|
||||||
console.debug(`metrics/compute/${login}/plugins > languages > loading page ${page}`)
|
console.debug(`metrics/compute/${login}/plugins > languages > loading page ${page}`)
|
||||||
|
|||||||
@@ -84,6 +84,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
<% if ({"most-used":plugins.languages.partial, "recently-used":plugins.languages["stats.recent"]?.partial}[section]) { %>
|
||||||
|
<div class="row footnote warning">
|
||||||
|
<div class="field">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M8.22 1.754a.25.25 0 00-.44 0L1.698 13.132a.25.25 0 00.22.368h12.164a.25.25 0 00.22-.368L8.22 1.754zm-1.763-.707c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0114.082 15H1.918a1.75 1.75 0 01-1.543-2.575L6.457 1.047zM9 11a1 1 0 11-2 0 1 1 0 012 0zm-.25-5.25a.75.75 0 00-1.5 0v2.5a.75.75 0 001.5 0v-2.5z"></path></svg>
|
||||||
|
Reached maximum execution time for analysis, partial results are displayed
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% } %>
|
||||||
<% } %>
|
<% } %>
|
||||||
</section>
|
</section>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|||||||
@@ -276,6 +276,12 @@
|
|||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
.footnote.warning {
|
||||||
|
color: #D79533;
|
||||||
|
}
|
||||||
|
.footnote.warning svg {
|
||||||
|
fill: #D79533;
|
||||||
|
}
|
||||||
|
|
||||||
/* Follow-up */
|
/* Follow-up */
|
||||||
.followup.legend {
|
.followup.legend {
|
||||||
|
|||||||
Reference in New Issue
Block a user