Add plugin_anilist_limit_characters and plugin_languages_threshold options (#89)
This commit is contained in:
@@ -30,4 +30,5 @@ It is also possible to use a predefined set of colors from [colorsets.json](colo
|
||||
plugin_languages_skipped: my-test-repo # List of repositories to skip
|
||||
plugin_languages_colors: "0:orange, javascript:#ff0000, ..." # Make most used languages orange and JavaScript red
|
||||
plugin_languages_details: bytes-size, percentage # Additionally display total bytes size and percentage
|
||||
plugin_languages_threshold: 2% # Hides all languages less than 2% (🚧 @master feature)
|
||||
```
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
return null
|
||||
|
||||
//Load inputs
|
||||
let {ignored, skipped, colors, details} = imports.metadata.plugins.languages.inputs({data, account, q})
|
||||
let {ignored, skipped, colors, details, threshold} = imports.metadata.plugins.languages.inputs({data, account, q})
|
||||
threshold = (Number(threshold.replace(/%$/, ""))||0)/100
|
||||
|
||||
//Custom colors
|
||||
const colorsets = JSON.parse(`${await imports.fs.readFile(`${imports.__module(import.meta.url)}/colorsets.json`)}`)
|
||||
@@ -41,7 +42,7 @@
|
||||
|
||||
//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, 8).map(([name, value]) => ({name, value, size:value, color:languages.colors[name], x:0}))
|
||||
languages.favorites = Object.entries(languages.stats).sort(([an, a], [bn, b]) => b - a).slice(0, 8).map(([name, value]) => ({name, value, size:value, color:languages.colors[name], x:0})).filter(({value}) => value/languages.total > threshold)
|
||||
const visible = {total:Object.values(languages.favorites).map(({size}) => size).reduce((a, b) => a + b, 0)}
|
||||
for (let i = 0; i < languages.favorites.length; i++) {
|
||||
languages.favorites[i].value /= visible.total
|
||||
|
||||
@@ -47,4 +47,10 @@ inputs:
|
||||
values:
|
||||
- bytes-size # Languages total size written in bytes
|
||||
- percentage # Languages proportions in %
|
||||
default: ""
|
||||
default: ""
|
||||
|
||||
# Minimum threshold (in percentage) to reach for languages to be displayed
|
||||
plugin_languages_threshold:
|
||||
description: Minimum threshold
|
||||
type: string
|
||||
default: 0%
|
||||
@@ -33,6 +33,13 @@
|
||||
plugin_languages: yes
|
||||
plugin_languages_details: percentage
|
||||
|
||||
- name: Language plugin (with threshold)
|
||||
uses: lowlighter/metrics@latest
|
||||
with:
|
||||
token: MOCKED_TOKEN
|
||||
plugin_languages: yes
|
||||
plugin_languages_threshold: 2%
|
||||
|
||||
- name: Language plugin (complete)
|
||||
uses: lowlighter/metrics@latest
|
||||
with:
|
||||
@@ -42,3 +49,4 @@
|
||||
plugin_languages_skipped: metrics
|
||||
plugin_languages_colors: rainbow
|
||||
plugin_languages_details: bytes-size, percentage
|
||||
plugin_languages_threshold: 2%
|
||||
|
||||
Reference in New Issue
Block a user