feat(plugins/topics): add labels alias (#776) [skip ci]

This commit is contained in:
Simon Lecoq
2022-01-16 00:32:51 +01:00
committed by GitHub
parent db2be65db1
commit 29b445d5b5
4 changed files with 89 additions and 48 deletions

View File

@@ -8,6 +8,7 @@ export default async function({login, data, imports, q, account}, {enabled = fal
//Load inputs
let {sort, mode, limit} = imports.metadata.plugins.topics.inputs({data, account, q})
const type = {starred:"labels", labels:"labels", mastered:"icons", icons:"icons"}[mode]
const shuffle = (sort === "random")
//Start puppeteer and navigate to topics
@@ -51,8 +52,8 @@ export default async function({login, data, imports, q, account}, {enabled = fal
topics = imports.shuffle(topics)
}
//Limit topics (starred mode)
if ((mode === "starred") && (limit > 0)) {
//Limit topics (labels)
if ((type === "labels") && (limit > 0)) {
console.debug(`metrics/compute/${login}/plugins > topics > keeping only ${limit} topics`)
const removed = topics.splice(limit)
if (removed.length)
@@ -72,14 +73,14 @@ export default async function({login, data, imports, q, account}, {enabled = fal
topic.description = imports.htmlescape(topic.description)
}
//Filter topics with icon (mastered mode)
if (mode === "mastered") {
//Filter topics with icon (icons)
if (type === "icons") {
console.debug(`metrics/compute/${login}/plugins > topics > filtering topics with icon`)
topics = topics.filter(({icon}) => icon)
}
//Limit topics (mastered mode)
if ((mode === "mastered") && (limit > 0)) {
//Limit topics (icons)
if ((type === "icons") && (limit > 0)) {
console.debug(`metrics/compute/${login}/plugins > topics > keeping only ${limit} topics`)
topics.splice(limit)
}