Add people plugin (#48)

This commit is contained in:
Simon Lecoq
2021-01-11 18:58:00 +01:00
committed by GitHub
parent c5723ad7f3
commit 4ef1b7367b
12 changed files with 279 additions and 7 deletions

View File

@@ -142,6 +142,7 @@
stars:{enabled:input.bool("plugin_stars")},
stargazers:{enabled:input.bool("plugin_stargazers")},
activity:{enabled:input.bool("plugin_activity")},
people:{enabled:input.bool("plugin_people")},
}
let q = Object.fromEntries(Object.entries(plugins).filter(([key, plugin]) => plugin.enabled).map(([key]) => [key, true]))
info("Plugins enabled", Object.entries(plugins).filter(([key, plugin]) => plugin.enabled).map(([key]) => key))
@@ -223,6 +224,15 @@
for (const option of ["filter"])
info(`Activity ${option}`, q[`activity.${option}`] = input.array(`plugin_activity_${option}`))
}
//People
if (plugins.people.enabled) {
for (const option of ["limit", "size"])
info(`People ${option}`, q[`people.${option}`] = input.number(`plugin_people_${option}`))
for (const option of ["types"])
info(`People ${option}`, q[`people.${option}`] = input.array(`plugin_people_${option}`))
for (const option of ["identicons"])
info(`People ${option}`, q[`people.${option}`] = input.bool(`plugin_people_${option}`))
}
//Repositories to use
const repositories = input.number("repositories")

View File

@@ -90,7 +90,7 @@
//Additional SVG transformations
if (/svg/.test(mime)) {
//Optimize rendering
if ((conf.optimize)&&(!q.raw)) {
if ((conf.settings?.optimize)&&(!q.raw)) {
console.debug(`metrics/compute/${login} > optimize`)
const svgo = new SVGO({full:true, plugins:[{cleanupAttrs:true}, {inlineStyles:false}]})
const {data:optimized} = await svgo.optimize(rendered)

View File

@@ -316,6 +316,30 @@
}
})
}
//People query
if (/^query People /.test(query)) {
console.debug(`metrics/compute/mocks > mocking graphql api result > People`)
const type = query.match(/(?<type>followers|following)[(]/)?.groups?.type ?? "(unknown type)"
return /after: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"/m.test(query) ? ({
user:{
[type]:{
edges:[],
}
}
}) : ({
user:{
[type]:{
edges:new Array(Math.ceil(20+80*Math.random())).fill(null).map(() => ({
cursor:"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
node:{
login:"user",
avatarUrl:"https://github.com/identicons/user.png",
}
}))
}
}
})
}
//Unmocked call
return target(...args)
}