Add plugin_anilist_limit_characters and plugin_languages_threshold options (#89)
This commit is contained in:
@@ -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_limit: 2 # Limit to 2 entry per section (characters section excluded)
|
||||||
plugin_anilist_shuffle: yes # Shuffle data for more varied outputs
|
plugin_anilist_shuffle: yes # Shuffle data for more varied outputs
|
||||||
plugin_anilist_user: .user.login # Use same username as GitHub login
|
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
|
return null
|
||||||
|
|
||||||
//Load inputs
|
//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
|
//Initialization
|
||||||
const result = {user:{stats:null, genres:[]}, lists:Object.fromEntries(medias.map(type => [type, {}])), characters:[], sections}
|
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()})
|
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++
|
page++
|
||||||
next = cursor.hasNextPage
|
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=="})
|
characters.push({name, artwork:artwork ? await imports.imgb64(artwork) : "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mOcOnfpfwAGfgLYttYINwAAAABJRU5ErkJggg=="})
|
||||||
|
}
|
||||||
} while (next)
|
} while (next)
|
||||||
//Format and save results
|
//Format and save results
|
||||||
result.characters = shuffle ? imports.shuffle(characters) : characters
|
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
|
//Results
|
||||||
|
|||||||
@@ -42,6 +42,14 @@ inputs:
|
|||||||
default: 2
|
default: 2
|
||||||
min: 0
|
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
|
# Shuffle AniList data for varied outputs
|
||||||
plugin_anilist_shuffle:
|
plugin_anilist_shuffle:
|
||||||
description: Shuffle AniList data
|
description: Shuffle AniList data
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
token: NOT_NEEDED
|
token: NOT_NEEDED
|
||||||
plugin_anilist: yes
|
plugin_anilist: yes
|
||||||
plugin_anilist_limit: 0
|
plugin_anilist_limit: 0
|
||||||
|
plugin_anilist_limit_characters: 10
|
||||||
plugin_anilist_shuffle: no
|
plugin_anilist_shuffle: no
|
||||||
plugin_anilist_user: user
|
plugin_anilist_user: user
|
||||||
|
|
||||||
@@ -56,5 +57,6 @@
|
|||||||
plugin_anilist_medias: manga, anime
|
plugin_anilist_medias: manga, anime
|
||||||
plugin_anilist_sections: favorites, watching, reading, characters
|
plugin_anilist_sections: favorites, watching, reading, characters
|
||||||
plugin_anilist_limit: 0
|
plugin_anilist_limit: 0
|
||||||
|
plugin_anilist_limit_characters: 22
|
||||||
plugin_anilist_shuffle: no
|
plugin_anilist_shuffle: no
|
||||||
plugin_anilist_user: user
|
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_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_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_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
|
return null
|
||||||
|
|
||||||
//Load inputs
|
//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
|
//Custom colors
|
||||||
const colorsets = JSON.parse(`${await imports.fs.readFile(`${imports.__module(import.meta.url)}/colorsets.json`)}`)
|
const colorsets = JSON.parse(`${await imports.fs.readFile(`${imports.__module(import.meta.url)}/colorsets.json`)}`)
|
||||||
@@ -41,7 +42,7 @@
|
|||||||
|
|
||||||
//Compute languages stats
|
//Compute languages stats
|
||||||
console.debug(`metrics/compute/${login}/plugins > languages > computing 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)}
|
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++) {
|
for (let i = 0; i < languages.favorites.length; i++) {
|
||||||
languages.favorites[i].value /= visible.total
|
languages.favorites[i].value /= visible.total
|
||||||
|
|||||||
@@ -48,3 +48,9 @@ inputs:
|
|||||||
- bytes-size # Languages total size written in bytes
|
- bytes-size # Languages total size written in bytes
|
||||||
- percentage # Languages proportions in %
|
- 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: yes
|
||||||
plugin_languages_details: percentage
|
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)
|
- name: Language plugin (complete)
|
||||||
uses: lowlighter/metrics@latest
|
uses: lowlighter/metrics@latest
|
||||||
with:
|
with:
|
||||||
@@ -42,3 +49,4 @@
|
|||||||
plugin_languages_skipped: metrics
|
plugin_languages_skipped: metrics
|
||||||
plugin_languages_colors: rainbow
|
plugin_languages_colors: rainbow
|
||||||
plugin_languages_details: bytes-size, percentage
|
plugin_languages_details: bytes-size, percentage
|
||||||
|
plugin_languages_threshold: 2%
|
||||||
|
|||||||
Reference in New Issue
Block a user