Merge branch 'master' of https://github.com/lowlighter/metrics
This commit is contained in:
11
action.yml
11
action.yml
@@ -195,6 +195,12 @@ inputs:
|
||||
description: Maximum number of entries to display per section
|
||||
default: 2
|
||||
|
||||
# Number of entries to display in characters section
|
||||
# Set to 0 to disable limitations
|
||||
plugin_anilist_limit_characters:
|
||||
description: Maximum number of entries to display in characters section
|
||||
default: 22
|
||||
|
||||
# Shuffle AniList data for varied outputs
|
||||
plugin_anilist_shuffle:
|
||||
description: Shuffle AniList data
|
||||
@@ -297,6 +303,11 @@ inputs:
|
||||
description: Additional details
|
||||
default: ""
|
||||
|
||||
# Minimum threshold (in percentage) to reach for languages to be displayed
|
||||
plugin_languages_threshold:
|
||||
description: Minimum threshold
|
||||
default: 0%
|
||||
|
||||
# ====================================================================================
|
||||
# 👨💻 Lines of code changed
|
||||
|
||||
|
||||
@@ -37,4 +37,5 @@ These sections can also be filtered by media type, which can be either `anime`,
|
||||
plugin_anilist_limit: 2 # Limit to 2 entry per section (characters section excluded)
|
||||
plugin_anilist_shuffle: yes # Shuffle data for more varied outputs
|
||||
plugin_anilist_user: .user.login # Use same username as GitHub login
|
||||
plugin_anilist_limit_characters: 22 # Limit to 22 characters in characters section (🚧 @master feature)
|
||||
```
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
return null
|
||||
|
||||
//Load inputs
|
||||
let {limit, medias, sections, shuffle, user} = imports.metadata.plugins.anilist.inputs({data, account, q})
|
||||
let {limit, "limit.characters":limit_characters, medias, sections, shuffle, user} = imports.metadata.plugins.anilist.inputs({data, account, q})
|
||||
|
||||
//Initialization
|
||||
const result = {user:{stats:null, genres:[]}, lists:Object.fromEntries(medias.map(type => [type, {}])), characters:[], sections}
|
||||
@@ -79,11 +79,18 @@
|
||||
const {data:{data:{User:{favourites:{characters:{nodes, pageInfo:cursor}}}}}} = await imports.axios.post("https://graphql.anilist.co", {variables:{name:user, page}, query:queries.anilist.characters()})
|
||||
page++
|
||||
next = cursor.hasNextPage
|
||||
for (const {name:{full:name}, image:{medium:artwork}} of nodes)
|
||||
for (const {name:{full:name}, image:{medium:artwork}} of nodes) {
|
||||
console.debug(`metrics/compute/${login}/plugins > anilist > processing ${name}`)
|
||||
characters.push({name, artwork:artwork ? await imports.imgb64(artwork) : "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mOcOnfpfwAGfgLYttYINwAAAABJRU5ErkJggg=="})
|
||||
}
|
||||
} while (next)
|
||||
//Format and save results
|
||||
result.characters = shuffle ? imports.shuffle(characters) : characters
|
||||
//Limit results
|
||||
if (limit_characters > 0) {
|
||||
console.debug(`metrics/compute/${login}/plugins > anilist > keeping only ${limit_characters} characters`)
|
||||
result.characters.splice(limit_characters)
|
||||
}
|
||||
}
|
||||
|
||||
//Results
|
||||
|
||||
@@ -42,6 +42,14 @@ inputs:
|
||||
default: 2
|
||||
min: 0
|
||||
|
||||
# Number of entries to display in characters section
|
||||
# Set to 0 to disable limitations
|
||||
plugin_anilist_limit_characters:
|
||||
description: Maximum number of entries to display in characters section
|
||||
type: number
|
||||
default: 22
|
||||
min: 0
|
||||
|
||||
# Shuffle AniList data for varied outputs
|
||||
plugin_anilist_shuffle:
|
||||
description: Shuffle AniList data
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
token: NOT_NEEDED
|
||||
plugin_anilist: yes
|
||||
plugin_anilist_limit: 0
|
||||
plugin_anilist_limit_characters: 10
|
||||
plugin_anilist_shuffle: no
|
||||
plugin_anilist_user: user
|
||||
|
||||
@@ -56,5 +57,6 @@
|
||||
plugin_anilist_medias: manga, anime
|
||||
plugin_anilist_sections: favorites, watching, reading, characters
|
||||
plugin_anilist_limit: 0
|
||||
plugin_anilist_limit_characters: 22
|
||||
plugin_anilist_shuffle: no
|
||||
plugin_anilist_user: user
|
||||
|
||||
@@ -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