Add indepth languages analysis (#325)

This commit is contained in:
Simon Lecoq
2021-05-25 20:41:53 +02:00
committed by GitHub
parent 38e85eec11
commit 22d442a03c
5 changed files with 139 additions and 5 deletions

View File

@@ -1,3 +1,6 @@
//Imports
import indepth_analyzer from "./indepth.mjs"
//Setup
export default async function({login, data, imports, q, account}, {enabled = false} = {}) {
//Plugin execution
@@ -7,7 +10,7 @@ export default async function({login, data, imports, q, account}, {enabled = fal
return null
//Load inputs
let {ignored, skipped, colors, details, threshold, limit} = imports.metadata.plugins.languages.inputs({data, account, q})
let {ignored, skipped, colors, details, threshold, limit, indepth} = imports.metadata.plugins.languages.inputs({data, account, q})
threshold = (Number(threshold.replace(/%$/, "")) || 0) / 100
skipped.push(...data.shared["repositories.skipped"])
if (!limit)
@@ -43,6 +46,12 @@ export default async function({login, data, imports, q, account}, {enabled = fal
}
}
//Indepth mode
if (indepth) {
console.debug(`metrics/compute/${login}/plugins > languages > switching to indepth mode (this may take some time)`)
Object.assign(languages, await indepth_analyzer({login, data, imports}, {skipped, ignored}))
}
//Compute languages stats
console.debug(`metrics/compute/${login}/plugins > languages > computing stats`)
languages.favorites = Object.entries(languages.stats).sort(([_an, a], [_bn, b]) => b - a).slice(0, limit).map(([name, value]) => ({name, value, size:value, color:languages.colors[name], x:0})).filter(({value}) => value / languages.total > threshold)