Add options to configure which language categories to display (#477)

This commit is contained in:
Nixinova
2021-08-17 22:08:49 +12:00
committed by GitHub
parent 34004e8909
commit 7534c37ab8
5 changed files with 45 additions and 12 deletions

View File

@@ -1,5 +1,5 @@
//Imports
import { indepth as indepth_analyzer, recent as recent_analyzer } from "./analyzers.mjs"
import {indepth as indepth_analyzer, recent as recent_analyzer} from "./analyzers.mjs"
//Setup
export default async function({login, data, imports, q, rest, account}, {enabled = false, extras = false} = {}) {
@@ -17,7 +17,7 @@ export default async function({login, data, imports, q, rest, account}, {enabled
}
//Load inputs
let {ignored, skipped, colors, aliases, details, threshold, limit, indepth, sections, "recent.load":_recent_load, "recent.days":_recent_days} = imports.metadata.plugins.languages.inputs({data, account, q})
let {ignored, skipped, colors, aliases, details, threshold, limit, indepth, sections, categories, "recent.categories":_recent_categories, "recent.load":_recent_load, "recent.days":_recent_days} = imports.metadata.plugins.languages.inputs({data, account, q})
threshold = (Number(threshold.replace(/%$/, "")) || 0) / 100
skipped.push(...data.shared["repositories.skipped"])
if (!limit)
@@ -57,13 +57,13 @@ export default async function({login, data, imports, q, rest, account}, {enabled
//Recently used languages
if ((sections.includes("recently-used"))&&(context.mode === "user")) {
console.debug(`metrics/compute/${login}/plugins > languages > using recent analyzer`)
languages["stats.recent"] = await recent_analyzer({login, data, imports, rest, account}, {skipped, days:_recent_days, load:_recent_load})
languages["stats.recent"] = await recent_analyzer({login, data, imports, rest, account}, {skipped, categories:_recent_categories ?? categories, days:_recent_days, load:_recent_load})
}
//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, repositories}, {skipped}))
Object.assign(languages, await indepth_analyzer({login, data, imports, repositories}, {skipped, categories}))
console.debug(`metrics/compute/${login}/plugins > languages > indepth analysis missed ${languages.missed} commits`)
}
}