feat(plugins/starlists): add plugin_starlists_shuffle_repositories (#769)
This commit is contained in:
@@ -7,7 +7,7 @@ export default async function({login, q, imports, data, account}, {enabled = fal
|
|||||||
return null
|
return null
|
||||||
|
|
||||||
//Load inputs
|
//Load inputs
|
||||||
let {limit, ignored, only, "limit.repositories":_limit} = imports.metadata.plugins.starlists.inputs({data, account, q})
|
let {limit, ignored, only, "limit.repositories":_limit, "shuffle.repositories":_shuffle} = imports.metadata.plugins.starlists.inputs({data, account, q})
|
||||||
|
|
||||||
//Start puppeteer and navigate to star lists
|
//Start puppeteer and navigate to star lists
|
||||||
console.debug(`metrics/compute/${login}/plugins > starlists > starting browser`)
|
console.debug(`metrics/compute/${login}/plugins > starlists > starting browser`)
|
||||||
@@ -26,7 +26,7 @@ export default async function({login, q, imports, data, account}, {enabled = fal
|
|||||||
repositories:[]
|
repositories:[]
|
||||||
}))))
|
}))))
|
||||||
const count = lists.length
|
const count = lists.length
|
||||||
lists = lists.slice(0, limit).filter(({name}) => (only.includes(name.toLocaleLowerCase())) || ((!only.length)&&((!name)||(!ignored.includes(name.toLocaleLowerCase())))))
|
lists = lists.filter(({name}) => (name)&&((only.includes(name.toLocaleLowerCase()))||((!only.length)&&(!ignored.includes(name.toLocaleLowerCase()))))).slice(0, limit)
|
||||||
console.debug(`metrics/compute/${login}/plugins > starlists > extracted ${lists.length} lists`)
|
console.debug(`metrics/compute/${login}/plugins > starlists > extracted ${lists.length} lists`)
|
||||||
|
|
||||||
//Fetch star list content
|
//Fetch star list content
|
||||||
@@ -38,6 +38,8 @@ export default async function({login, q, imports, data, account}, {enabled = fal
|
|||||||
description:element.querySelector(".py-1")?.innerText ?? ""
|
description:element.querySelector(".py-1")?.innerText ?? ""
|
||||||
})))
|
})))
|
||||||
list.repositories.push(...repositories)
|
list.repositories.push(...repositories)
|
||||||
|
if (_shuffle)
|
||||||
|
list.repositories = imports.shuffle(list.repositories)
|
||||||
list.repositories = list.repositories.slice(0, _limit)
|
list.repositories = list.repositories.slice(0, _limit)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,12 @@ inputs:
|
|||||||
min: 0
|
min: 0
|
||||||
max: 100
|
max: 100
|
||||||
|
|
||||||
|
# Shuffle displayed repositories for varied outputs
|
||||||
|
plugin_starlists_shuffle_repositories:
|
||||||
|
description: Shuffle displayed repositories
|
||||||
|
type: boolean
|
||||||
|
default: yes
|
||||||
|
|
||||||
# List of star lists that will be ignored
|
# List of star lists that will be ignored
|
||||||
plugin_starlists_ignored:
|
plugin_starlists_ignored:
|
||||||
description: Star lists to skip
|
description: Star lists to skip
|
||||||
@@ -39,7 +45,7 @@ inputs:
|
|||||||
# List of star lists to display
|
# List of star lists to display
|
||||||
# Using this option is equivalent of using "plugin_starlists_ignored" with all star lists but the ones listed
|
# Using this option is equivalent of using "plugin_starlists_ignored" with all star lists but the ones listed
|
||||||
plugin_starlists_only:
|
plugin_starlists_only:
|
||||||
description: Start lists to display
|
description: Star lists to display
|
||||||
type: array
|
type: array
|
||||||
format: comma-separated
|
format: comma-separated
|
||||||
default: ""
|
default: ""
|
||||||
|
|||||||
Reference in New Issue
Block a user