feat(plugins/habits): add plugin_habits_languages_threshold (#1138) [skip ci]
This commit is contained in:
@@ -10,7 +10,8 @@ export default async function({login, data, rest, imports, q, account}, {enabled
|
||||
return null
|
||||
|
||||
//Load inputs
|
||||
let {from, days, facts, charts, "charts.type": _charts, trim, "languages.limit": limit} = imports.metadata.plugins.habits.inputs({data, account, q}, defaults)
|
||||
let {from, days, facts, charts, "charts.type": _charts, trim, "languages.limit": limit, "languages.threshold": threshold} = imports.metadata.plugins.habits.inputs({data, account, q}, defaults)
|
||||
threshold = (Number(threshold.replace(/%$/, "")) || 0) / 100
|
||||
|
||||
//Initialization
|
||||
const habits = {facts, charts, trim, lines: {average: {chars: 0}}, commits: {fetched: 0, hour: NaN, hours: {}, day: NaN, days: {}}, indents: {style: "", spaces: 0, tabs: 0}, linguist: {available: false, ordered: [], languages: {}}}
|
||||
@@ -105,7 +106,7 @@ export default async function({login, data, rest, imports, q, account}, {enabled
|
||||
habits.linguist.available = true
|
||||
const {total, stats} = await recent_analyzer({login, data, imports, rest, account}, {days, load: from || 1000, tempdir: "habits"})
|
||||
habits.linguist.languages = Object.fromEntries(Object.entries(stats).map(([language, value]) => [language, value / total]))
|
||||
habits.linguist.ordered = Object.entries(habits.linguist.languages).sort(([_an, a], [_bn, b]) => b - a).slice(0, limit || Infinity)
|
||||
habits.linguist.ordered = Object.entries(habits.linguist.languages).sort(([_an, a], [_bn, b]) => b - a).filter(([_, value]) => value > threshold).slice(0, limit || Infinity)
|
||||
}
|
||||
else {
|
||||
console.debug(`metrics/compute/${login}/plugins > habits > linguist not available`)
|
||||
|
||||
@@ -85,4 +85,10 @@ inputs:
|
||||
default: 8
|
||||
min: 0
|
||||
max: 8
|
||||
zero: disable
|
||||
zero: disable
|
||||
|
||||
plugin_habits_languages_threshold:
|
||||
description: |
|
||||
Display threshold (percentage)
|
||||
type: string
|
||||
default: 0%
|
||||
Reference in New Issue
Block a user